Skip to content

Inconsistent handling of spacing with inline math delimiters ($) #11311

@benniekiss

Description

@benniekiss

Explain the problem.

The way pandoc handles spacing after opening math delimiters and before closing math delimiters is inconsistent. For opening delimiters, a newline after the delimiter will render the inline content invalid; however, a newline before a closing delimiter still renders the content as inline math.

Here is an example showing the newline after the opening delimiter -- Opening

Here is an example showing the newline before the closing delimiter -- Closing

I believe the inconsistency is because of the follow two lines in the code, where one tests whether the opening is followed by space, and the other tests whether a spaceChar is followed by $. However, I do not know haskell, nor have I tested any potential changes. However, if this is the intended behavior, I believe the documentation should be updated to mention the difference in space handling.

when (op == "$") $ notFollowedBy space

<|> (T.pack <$> many1 spaceChar <* notFollowedBy (char '$'))

Pandoc version?

v3.8.2.1 macOS 26

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions