From 47c360e0795a5f27e4906ea22fff388b779f270a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 15 Dec 2014 10:03:19 -0800 Subject: Improved texorpdfstring patch #1148. * Make LaTeX reader recognize texorpdfstring. * Don't use texorpdfstring unless it's actually needed. * Fix tests. --- src/Text/Pandoc/Readers/LaTeX.hs | 1 + src/Text/Pandoc/Writers/LaTeX.hs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 9420d602f..e1976035d 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -417,6 +417,7 @@ inlineCommands = M.fromList $ , ("(", mathInline $ manyTill anyChar (try $ string "\\)")) , ("[", mathDisplay $ manyTill anyChar (try $ string "\\]")) , ("ensuremath", mathInline $ braced) + , ("texorpdfstring", (\_ x -> x) <$> tok <*> tok) , ("P", lit "¶") , ("S", lit "§") , ("$", lit "$") diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ee9f7f620..2c86d1a6e 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -626,9 +626,12 @@ sectionHeader unnumbered ref level lst = do then return empty else do return $ brackets txtNoNotes - let stuffing = star <> optional <> braces (text "\\texorpdfstring" - <> braces txt - <> braces (text plain)) + let contents = if render Nothing txt == plain + then braces txt + else braces (text "\\texorpdfstring" + <> braces txt + <> braces (text plain)) + let stuffing = star <> optional <> contents book <- gets stBook opts <- gets stOptions let level' = if book || writerChapters opts then level - 1 else level -- cgit v1.2.3