Skip to content

Code with strikeout generates undesired LaTeX #5529

Closed
@mpark

Description

@mpark

pandoc 2.7.2

Consider the following markdown:

~~`hello world`~~

~~_`hello world`_~~

They generate the following LaTeX:

\sout{\texttt{hello\ world}}

\sout{\emph{\texttt{hello\ world}}}

which then outputs:
Screen Shot 2019-05-29 at 1 57 22 AM

The desired output would be:
Screen Shot 2019-05-29 at 2 00 45 AM


  1. In Escape inline verbatim spaces in LaTeX output (\texttt) #1694, escaped spaces were added to \texttt. \sout does not handle this properly.
  2. In LaTeX writer produces erroneous output for striked out code with highlighting #1294, inline highlighted code was wrapped in \mbox within strikeout. This is not applied to inline non-highlighted code. That is, removing this line would make it such that the first case would be fixed.
  3. The protectCode added in LaTeX writer produces erroneous output for striked out code with highlighting #1294 doesn't seem to walk through the elements. If it did, I think the second case would also be fixed.

My current solution is to run the following panflute filter:

def protect_code(elem, doc):
    if isinstance(elem, pf.Code):
        return pf.Span(
                   pf.RawInline('\\mbox{', 'latex'),
                   elem,
                   pf.RawInline('}', 'latex'))

def strikeout(elem, doc):
    if not isinstance(elem, pf.Strikeout):
        return None

    elem.walk(protect_code)

if __name__ == '__main__':
    pf.run_filter(strikeout)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions