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
Converting from LaTeX to CommonMark leaves in \maketitle, even without raw_tex #4527
Comments
This might not be a CommonMark-specific issue, since the RST writer does it too:
|
There are two bugs going on here, I think, and they're both necessary to observe this bug. First, the LaTeX reader is emitting raw blocks even without
As can be seen, the raw inlines are correctly omitted. Second, the CommonMark and RST writers aren't ignoring the raw blocks. Here's the relevant code from
That's got an operator precedence bug in its logic. The corresponding code for RawInline is correctly bracketted. I'll make up a PR for that. |
Upon review, the RST raw logic is very different to the Markdown/CommonMark raw logic, defaulting to inclusion. That's probably a separate bug, and there's also the LaTeX reader bug, so merging the PR won't suffice to fully clear up the bugs here. |
I had a look at the manual to see whether the RST writer is actually working as specified. The The LaTeX reader is definitely buggy in how it's emitting raw blocks even with But this isn't ruining my day nor even mildly inconveniencing me, and you can drop the raw elements with filters as a workaround if it matters to you, so I'm not going to work on it for the time being. |
quasicomputational <notifications@github.com> writes:
I had a look at the manual to see whether the RST writer is actually working as specified. The `raw_tex` extension is described twice: in one place it says that it only affects markdown, latex, org and textile (which is wrong, it should include commonmark now); in another place, it says "Inline LaTeX is ignored in output formats other than Markdown, LaTeX, Emacs Org mode, and ConTeXt," which suggests that the RST reader is buggy in always allowing it through.
I think the documentation here just hasn't been kept up to date
properly as things have changed. We should have changed it when
we supported `raw` blocks in RST.
The LaTeX reader is definitely buggy in how it's emitting raw blocks even with `raw_tex` disabled.
Yes, agreed.
|
I tried making inclusion of raw latex blocks conditional on
We should think these through to make sure the change is not going to cause problems. |
Here's the patch diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 1dd31d402..18a5bb550 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -2271,7 +2271,9 @@ blockCommand = try $ do
let names = ordNub [name', name]
let rawDefiniteBlock = do
guard $ isBlockCommand name
- rawBlock "latex" <$> getRawCommand name (txt <> star)
+ rawcontents <- getRawCommand name (txt <> star)
+ (guardEnabled Ext_raw_tex >> return (rawBlock "latex" rawcontents))
+ <|> return mempty
-- heuristic: if it could be either block or inline, we
-- treat it if block if we have a sequence of block
-- commands followed by a newline. But we stop if we
@@ -2286,7 +2288,9 @@ blockCommand = try $ do
curr <- rawBlock "latex" <$> getRawCommand name (txt <> star)
rest <- many $ notFollowedBy startCommand *> blockCommand
lookAhead $ blankline <|> startCommand
- return $ curr <> mconcat rest
+ let contents = curr <> mconcat rest
+ (guardEnabled Ext_raw_tex >> return contents)
+ <|> return mempty
let raw = rawDefiniteBlock <|> rawMaybeBlock
lookupListDefault raw names blockCommands |
The extra puzzling thing is that the Markdown writer doesn't do this:
The text was updated successfully, but these errors were encountered: