-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
LaTeX to HTML: 'align' environment is incorrectly converted to 'aligned' #7968
Comments
Actually your expected output is INVALID LaTeX, even though MathJax seems to accept it:
You can't put the align environment inside math mode ( |
Hard to know how to handle this. We could change the LaTeX reader so that if the Maybe we need a new extension that tells the LaTeX reader to parse just math environments as raw LaTeX. But this is a bit unprincipled; it's an extension solely motivated by one particular conversion (latex -> html with mathjax). |
Here's the diff for parsing these as raw latex when % git diff
diff --git a/src/Text/Pandoc/Readers/LaTeX/Math.hs b/src/Text/Pandoc/Readers/LaTeX/Math.hs
index 9f3d6fe53..bdb8be1b6 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Math.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Math.hs
@@ -25,6 +25,8 @@ import Control.Applicative ((<|>), optional)
import Control.Monad (guard, mzero)
import qualified Data.Map as M
import Data.Text (Text)
+import Text.Pandoc.Extensions (extensionEnabled, Extension(Ext_raw_tex))
+import Text.Pandoc.Options (ReaderOptions(readerExtensions))
dollarsMath :: PandocMonad m => LP m Inlines
dollarsMath = do
@@ -76,9 +78,15 @@ mathEnv name = do
inlineEnvironment :: PandocMonad m => LP m Inlines
inlineEnvironment = try $ do
- controlSeq "begin"
- name <- untokenize <$> braced
- M.findWithDefault mzero name inlineEnvironments
+ (name, rawstart) <- withRaw (controlSeq "begin" *> braced)
+ case M.lookup (untokenize name) inlineEnvironments of
+ Nothing -> mzero
+ Just parser -> do
+ parseRaw <- extensionEnabled Ext_raw_tex <$> getOption readerExtensions
+ if parseRaw
+ then rawInline "latex" . untokenize . (rawstart ++) . snd
+ <$> withRaw parser
+ else parser
inlineEnvironments :: PandocMonad m => M.Map Text (LP m Inlines) |
Maybe a good solution would be a Lua filter that matches Math elements beginning with |
Here you go!
|
This appears to be a duplicate of #4104; thus closing. |
Explain the problem.
I'm attempting to convert some LaTeX files to HTML (using MathJax for maths rendering) and am trying to get AMS equation numbering to work. I noticed in the generated HTML files that pandoc had converted
align
environments toaligned
, which seems to break the AMS numbering. In researching this issue I also found a Stack Exchange post about it: https://tex.stackexchange.com/questions/561133/how-to-prevent-pandoc-from-converting-align-environment-to-aligned-environment.Example:
Taken from https://tex.stackexchange.com/questions/561133/how-to-prevent-pandoc-from-converting-align-environment-to-aligned-environment. Try it yourself on the pandoc website.
Input:
Output:
Expected output:
Pandoc version?
pandoc 2.17.1.1 on Windows 10
The text was updated successfully, but these errors were encountered: