diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-05-26 22:48:28 +0200 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-05-26 22:48:28 +0200 |
| commit | 288728a7b1743d8bb651fe3bfd2141f8710bbe34 (patch) | |
| tree | 072d719b324f9bc8599ad4ee355ed31e110af952 | |
| parent | 96d4e8128aa4f67cc8ffe21947cc6ea759a5df51 (diff) | |
provide misparsing example
| -rw-r--r-- | _pandoc.qmd | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/_pandoc.qmd b/_pandoc.qmd index 72fc6bc..14726cc 100644 --- a/_pandoc.qmd +++ b/_pandoc.qmd @@ -209,10 +209,55 @@ that API effectively is discouraged. Since a core principle of Markdown is to treat unknown markup as content, a viable alternative for an extended Markdown format -is to use a simpler Markdown Reader and then "finish up" the parsing -in a filter. +is to use use the regular Markdown Reader +and then "finish up" the parsing in a filter. + +As an example, this Semantic Markdown text: + +```markdown +[This]{:depiction} is not [a pipe]{:depiction}. +``` + +...should ideally become this as regular Markdown: + +```markdown +This is not a pipe. +``` + +...but misparsed as regular Markdown would result in this Pandoc AST: + +* `Pandoc` + * `Para` + * `Str` "[This]{:depiction}" + * `Space` + * `Str` "is" + * `Space` + * `Str` "not" + * `Space` + * `Str` "[a" + * `Space` + * `Str` "pipe]{:depiction" + * `Space` + * `Str` "#the_object}." + +...where a filter would then look for `{...}` +and reorganise the AST to become this: + +* `Pandoc` + * `Para` + * `Str` "This" + * `Space` + * `Str` "is" + * `Space` + * `Str` "not" + * `Space` + * `Str` "a" + * `Space` + * `Str` "pipe." + +The first `Str` simply needed its content reduced to "This". +The trailing part is more involved, however, +since it involves three `Str` and two `Space` elements. + This is the approach chosen for this project, as covered next in @sec-filter. - -*TODO: also mention (reiterate) when wrapping up above -that the filter API is more cumbersome* |
