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

References in markdown links and spans parsed as citations #7632

Closed
knuesel opened this issue Oct 19, 2021 · 5 comments
Closed

References in markdown links and spans parsed as citations #7632

knuesel opened this issue Oct 19, 2021 · 5 comments
Labels

Comments

@knuesel
Copy link
Contributor

knuesel commented Oct 19, 2021

For example:

pandoc -t native
(@a) First case

[link to (@a)](url)

gives

[ OrderedList
    ( 1 , Example , TwoParens )
    [ [ Plain [ Str "First" , Space , Str "case" ] ] ]
, Para
    [ Cite
        [ Citation
            { citationId = "a"
            , citationPrefix =
                [ Str "link" , Space , Str "to" , Space , Str "(" ]
            , citationSuffix = [ Str ")" ]
            , citationMode = NormalCitation
            , citationNoteNum = 1
            , citationHash = 0
            }
        ]
        [ Str "[link" , Space , Str "to" , Space , Str "(@a)]" ]
    , Str "(url)"
    ]
]

The same occurs with spans, e.g. with

(@a) First case

[span with (@a)]{}

It seems to me the [...](...) and [...]{...} semantics should have priority over the citation semantics.

There is also a problem with pandoc-crossref that might be related. Example:

pandoc -F pandoc-crossref -t native
# Title {#sec:title}

[text (@sec:title)]{}
[ Header 1 ( "sec:title" , [] , [] ) [ Str "Title" ]
, Para [ Str "text" , Space , Str "(" , Space , Str "1){}" ]
]

so we get the string text ( 1){}, instead of text (sec. 1) inside a span.

Reproduced with pandoc master (465c28d) on Pop OS based on Ubuntu 21.04.

@knuesel knuesel added the bug label Oct 19, 2021
@jgm
Copy link
Owner

jgm commented Oct 19, 2021

I agree that this is undesirable in this case, but there's a general problem of ambiguity with citation and example list syntax.

Is this a regression from earlier versions, or has it always behaved this way?

@knuesel
Copy link
Contributor Author

knuesel commented Oct 19, 2021

It was like this already in pandoc 1.13 (the earliest version I tested).

So the current behavior has history on its side. It's causing me some headaches though: it breaks the composability of spans, which makes them a lot less useful.

For context, my use case is a bilingual document with many paragraphs of the form

[some content]{lang=fr}
[some content]{lang=de}
$$some math$$

or

[some content]{lang=fr}
[some content]{lang=de}
$some math$
[more content]{lang=fr}
[more content]{lang=de}

I make one output where both languages appear (with different styles using CSS), and also one output for each language (the other is removed by a Lua filter).

I thought spans where perfect for this but it's not working when I have equation references in the text, which led me to file this issue.

@jgm
Copy link
Owner

jgm commented Oct 19, 2021

I see the difficulty. I'll see if I can think of a solution.

@jgm jgm closed this as completed in 0a93acf Oct 20, 2021
@knuesel
Copy link
Contributor Author

knuesel commented Oct 21, 2021

Thanks for fixing this!

@jgm
Copy link
Owner

jgm commented Oct 21, 2021

One nagging worry about the fix: with this fix, [@foo]{.class} will never be parsed as a normal citation. (It will be parsed as a span containing an author-in-text citation.) That's fine with pandoc's markdown as it stands, but if we ever port over the attributes extension (now possible with commonmark), authors will expect to be able to add attributes to normal citations. Not sure how to handle this. There may be a better fix. But at the moment this is fine.

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