aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-10-08 22:47:32 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-10-08 22:47:32 -0700
commit9a6c42590f42601329db3fb42296db1a04ee3ff5 (patch)
tree83ca50c1cb8f3e9ae916dc139460ef4d8f0409c6
parent307ea358cbaef5fe1104a9ed587dde6119df3a7d (diff)
downloadpandoc-9a6c42590f42601329db3fb42296db1a04ee3ff5.tar.gz
LaTeX reader: Fix parsing of "show name" in newtheorem.
Previously we were just treating it as a string and ignoring accents and formatting. See #6734.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs11
-rw-r--r--src/Text/Pandoc/Readers/LaTeX/Parsing.hs2
-rw-r--r--test/command/1608.md2
3 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 4805bcdde..c42a21465 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1690,7 +1690,7 @@ newtheorem = do
sp
series <- option Nothing $ Just . untokenize <$> bracketedToks
sp
- showName <- untokenize <$> braced
+ showName <- tok
sp
syncTo <- option Nothing $ Just . untokenize <$> bracketedToks
sty <- sLastTheoremStyle <$> getState
@@ -1769,8 +1769,9 @@ theoremEnvironment name = do
Just ident ->
updateState $ \s ->
s{ sLabels = M.insert ident
- [Str (theoremName tspec), Str "\160",
- Str (renderDottedNum num)] (sLabels s) }
+ (B.toList $
+ theoremName tspec <> "\160" <>
+ str (renderDottedNum num)) (sLabels s) }
Nothing -> return ()
return $ space <> B.text (renderDottedNum num)
else return mempty
@@ -1778,8 +1779,8 @@ theoremEnvironment name = do
PlainStyle -> B.strong
DefinitionStyle -> B.strong
RemarkStyle -> B.emph
- let title = titleEmph (B.text (theoremName tspec) <> number)
- <> optTitle <> "." <> space
+ let title = titleEmph (theoremName tspec <> number)
+ <> optTitle <> "." <> space
return $ divWith (fromMaybe "" mblabel, [name], []) $ addTitle title
$ case theoremStyle tspec of
PlainStyle -> walk italicize bs
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
index c349fe3b1..6d6d4f3ec 100644
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -122,7 +122,7 @@ data TheoremStyle =
data TheoremSpec =
TheoremSpec
- { theoremName :: Text
+ { theoremName :: Inlines
, theoremStyle :: TheoremStyle
, theoremSeries :: Maybe Text
, theoremSyncTo :: Maybe Text
diff --git a/test/command/1608.md b/test/command/1608.md
index e9fd5232a..f7ef2b839 100644
--- a/test/command/1608.md
+++ b/test/command/1608.md
@@ -33,7 +33,7 @@ These are all pretty interesting facts.
,Div ("",["lemma"],[])
[Para [Strong [Str "Lemma",Space,Str "2"],Str ".",Space,Space,Emph [Str "The",Space,Str "triangle",Space,Str "with",Space,Str "sides",Space,Str "of",Space,Str "length\160",Math InlineMath "3",Str ",",Space,Math InlineMath "4",Space,Str "and\160",Math InlineMath "5",Space,Str "is",Space,Str "right-angled."]]]
,Div ("",["proof"],[])
- [Para [Emph [Str "Proof."],Space,Str "This",Space,Str "lemma",Space,Str "follows",Space,Str "from",Space,Link ("",[],[("reference-type","ref"),("reference","def:tri")]) [Str "Definition",Str "\160",Str "1"] ("#def:tri",""),Space,Str "since",Space,Math InlineMath "3^2+4^2=9+16=25=5^2",Str ".",Str "\160\9723"]]
+ [Para [Emph [Str "Proof."],Space,Str "This",Space,Str "lemma",Space,Str "follows",Space,Str "from",Space,Link ("",[],[("reference-type","ref"),("reference","def:tri")]) [Str "Definition\160\&1"] ("#def:tri",""),Space,Str "since",Space,Math InlineMath "3^2+4^2=9+16=25=5^2",Str ".",Str "\160\9723"]]
,Div ("thm:py",["theorem"],[])
[Para [Strong [Str "Theorem",Space,Str "3"],Space,Str "(Pythagorean",Space,Str "triplets).",Space,Space,Emph [Str "Triangles",Space,Str "with",Space,Str "sides",Space,Str "of",Space,Str "length",Space,Math InlineMath "a=p^2-q^2",Str ",",Space,Math InlineMath "b=2pq",Space,Str "and",Space,Math InlineMath "c=p^2+q^2",Space,Str "are",Space,Str "right-angled",Space,Str "triangles."]]]
,Div ("",["remark"],[])