git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: better handling of `\lettrine`.

- SmallCaps instead of Span for the part after the initial capital. - Ensure that both arguments are parsed, so that in Markdown both are treated as raw LateX. (Closes #6258.)

commit11df2a3c0f2b1b8e351ad8caaa7cdf583e1b3b2e authorJohn MacFarlane <jgm@berkeley.edu> dateTue 7 Apr 2020, 09:24 (7 years ago) parent39b742e
2 files changed+10−3
src/Text/Pandoc/Readers/LaTeX.hs+8−1 test/command/lettrine.md+2−2
src/Text/Pandoc/Readers/LaTeX.hs+8−1
@@ -923,7 +923,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
923923 , ("eqref", rawInlineOr "eqref" $ doref "eqref") -- from amsmath.sty
924924 , ("mbox", rawInlineOr "mbox" $ processHBox <$> tok)
925925 , ("hbox", rawInlineOr "hbox" $ processHBox <$> tok)
926− , ("lettrine", optional opt >> extractSpaces (spanWith ("",["lettrine"],[])) <$> tok)
926+ , ("lettrine", rawInlineOr "lettrine" $ lettrine)
927927 , ("(", mathInline . untokenize <$> manyTill anyTok (controlSeq ")"))
928928 , ("[", mathDisplay . untokenize <$> manyTill anyTok (controlSeq "]"))
929929 , ("ensuremath", mathInline . untokenize <$> braced)
@@ -1178,6 +1178,13 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
11781178 , ("ifdim", ifdim)
11791179 ]
11801180
1181+lettrine :: PandocMonad m => LP m Inlines
1182+lettrine = do
1183+ optional opt
1184+ x <- tok
1185+ y <- tok
1186+ return $ extractSpaces (spanWith ("",["lettrine"],[])) x <> smallcaps y
1187+
11811188ifdim :: PandocMonad m => LP m Inlines
11821189ifdim = do
11831190 contents <- manyTill anyTok (controlSeq "fi")
test/command/lettrine.md+2−2
@@ -4,6 +4,6 @@
44
55\lettrine[lhang=0.17]{A}{category} is
66^D
7−[Para [Span ("",["lettrine"],[]) [Str "A"],Span ("",[],[]) [Str "category"],Space,Str "is"]
8−,Para [Span ("",["lettrine"],[]) [Str "A"],Span ("",[],[]) [Str "category"],Space,Str "is"]]
7+[Para [Span ("",["lettrine"],[]) [Str "A"],SmallCaps [Str "category"],Space,Str "is"]
8+,Para [Span ("",["lettrine"],[]) [Str "A"],SmallCaps [Str "category"],Space,Str "is"]]
99```