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

Possible regression with detecting and escaping raw latex in markdown when using \iffalse #7460

Open
cderv opened this issue Jul 26, 2021 · 2 comments
Labels

Comments

@cderv
Copy link
Contributor

@cderv cderv commented Jul 26, 2021

Opening this after an answered question on pandoc-dicuss: https://groups.google.com/g/pandoc-discuss/c/nylIR9ZCSRg

Explain the problem.

I think this is a regression as it was supported before but is no more.

In our markdown doc, we have some LaTeX syntax using \iffalse{}\fi

\emph{Some text}\iffalse{Some ignored comment}\fi{}

With previous pandoc version, it was correctly seen as raw LaTeX and kept as is.

❯ cd C:\Users\chris\AppData\Local\r-pandoc\r-pandoc\2.13\

❯ echo "\emph{Some text}\iffalse{Some ignored comment}\fi{}" | ./pandoc -t latex
\emph{Some text}\iffalse{Some ignored comment}\fi{}

❯ echo "\emph{Some text}\iffalse{Some ignored comment}\fi{}" | ./pandoc -t native
[Para [RawInline (Format "tex") "\\emph{Some text}",RawInline (Format "tex") "\\iffalse{Some ignored comment}",RawInline (Format "tex") "\\fi{}"]]

but with newer pandoc it gets escaped (with nightly from today 1f1a30b) because not seen as Raw TeX I think.

❯ cd C:\Users\chris\AppData\Local\r-pandoc\r-pandoc\nightly\

❯ echo "\emph{Some text}\iffalse{Some ignored comment}\fi{}" | ./pandoc -t latex
\emph{Some text}\textbackslash iffalse\{Some ignored comment\}\fi{}

❯ echo "\emph{Some text}\iffalse{Some ignored comment}\fi{}" | ./pandoc -t native
[Para [RawInline (Format "tex") "\\emph{Some text}",Str "\\iffalse{Some",Space,Str "ignored",Space,Str "comment}",RawInline (Format "tex") "\\fi{}"]]

Second part which got escaped is not seen as RawInline anymore.

It seems to behave that way since Pandoc 2.14

❯ cd C:\Users\chris\AppData\Local\r-pandoc\r-pandoc\2.14

❯ echo "\emph{Some text}\iffalse{Some ignored comment}\fi{}" | ./pandoc -t latex
\emph{Some text}\textbackslash iffalse\{Some ignored comment\}\fi{}

Is this an expected change ? I did not find a related one in the Release notes.

Pandoc version?

  • Found in Pandoc 2.14
  • Still present in Pandoc nightly 1f1a30b
  • Working in Pandoc 2.13
@cderv
Copy link
Contributor Author

@cderv cderv commented Jan 20, 2022

It seems there was a change in pandoc 2.14 that indeed changed this behavior. I found a related issue #6096 where expected behavior was ok in Pandoc 2.13 and not after

For the record here the native representation formatted

Pandoc 2.13

[Para 
    [RawInline (Format "tex") "\\emph{Some text}"
    ,RawInline (Format "tex") "\\iffalse{Some ignored comment}"
    ,RawInline (Format "tex") "\\fi{}"]
]

Current version (2.17.0.1)

[ Para
    [ RawInline (Format "tex") "\\emph{Some text}"
    , Str "\\iffalse{Some"
    , Space
    , Str "ignored"
    , Space
    , Str "comment}"
    , RawInline (Format "tex") "\\fi{}"
    ]
]

So the content is no more identified as RawInline it seems

@jgm
Copy link
Owner

@jgm jgm commented Jan 20, 2022

This does seem like a bug, I'd have to look into it. But you can always work around this kind of thing using "raw attribute" syntax:

`\emph{Some text}\iffalse{Some ignored comment}\fi{}`{=latex}

cderv added a commit to rstudio/rmarkdown-book that referenced this issue Feb 18, 2022
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