Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclamation marks before square brackets get lost #9038

Closed
marcelotto opened this issue Aug 29, 2023 · 1 comment
Closed

Exclamation marks before square brackets get lost #9038

marcelotto opened this issue Aug 29, 2023 · 1 comment
Labels

Comments

@marcelotto
Copy link

When parsing an Obsidian-flavoured Markdown document containing an embedded document, like ![[Foo]], the produced AST omits the exclamation mark. Consequently, when regenerating the Markdown document from the AST, the exclamation mark is lost.

An additional problem is that the square brackets are escaped during the AST roundtrip, which does not happen when one of the new wikilinks_title extensions is enabled. With the exclamation mark in front, however, the double square brackets are no longer detected as links (besides losing the exclamation mark).

I'm aware of the existing issue #553 discussing transclusion support. However, my concern here is not about adding transclusion support but ensuring that no information gets lost during the AST generation and regeneration process.

Steps to Reproduce

  1. Create a Markdown document example.md with the following content:

    ![[Foo]]
  2. Parse the document to produce an AST using Pandoc: pandoc -f markdown+wikilinks_title_after_pipe -t json example.md > example.json
    This produces:

     {
       "pandoc-api-version": [
         1,
         23
       ],
       "meta": {},
       "blocks": [
         {
           "t": "Para",
           "c": [
             {
               "t": "Str",
               "c": "[[Foo]]"
             }
           ]
         }
       ]
     }
  3. Regenerate the Markdown document from the AST: pandoc -t markdown+wikilinks_title_after_pipe example.json

Expected Behavior

The regenerated Markdown document should retain the original embedded document syntax, including the exclamation mark:

![[Foo]]

Actual Behavior

The exclamation mark is missing in the regenerated Markdown document and the brackets are escaped:

\[\[Foo\]\]

Additional Information

  • I've noticed the same behavior also for exclamation marks before single square brackets (although I don't care for this in my use case).

Pandoc version

$ pandoc -v
pandoc 3.0.1
Features: +server +lua
Scripting engine: Lua 5.4

on MacOS 13.5.

@marcelotto marcelotto added the bug label Aug 29, 2023
@jgm
Copy link
Owner

jgm commented Aug 30, 2023

Actually the same issue appears with

![foo]

The problem is that makeFallback in referenceLink doesn't take account of the fact that referenceLink might be called from image.

@jgm jgm closed this as completed in cd3fcd5 Aug 30, 2023
marcelotto added a commit to marcelotto/magma that referenced this issue Nov 3, 2023
Pandoc 3.1.7 fixes issue jgm/pandoc#9038
that previously prevented usage of Obsidian transclusions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants