From 3cf722011a0c3127ba7767f0e1219bb2cb9b4d5b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 14 Apr 2025 10:45:00 -0700 Subject: LaTeX reader: support more symbol commands. Closes #10782. `\textbaht`, `\textblank`, `\textbigcircle`, `\textbrokenbar`, `\textbullet`, `\textcentoldstyle`, `\textcopyright`, `\textdagger`, `\textdegree`, `\textdollar`, `\textdong`, `\textlira`, `\textmu`, `\textmusicalnote`, `\textonehalf`, `\textonequarter`, `\textparagraph`, `\textpertenthousand`, `\textpeso`, `\textquotesingle`, `\textregistered`, `\textsection`, `\textsterling`, `\textthreequarters`, `\textthreesuperior`, `\texttwosuperior`, `\textyen`. --- src/Text/Pandoc/Readers/LaTeX.hs | 2 ++ src/Text/Pandoc/Readers/LaTeX/Inline.hs | 43 +++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 04a2ec801..c08fc0922 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -67,6 +67,7 @@ import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands) import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands, nameCommands, charCommands, accentCommands, + miscCommands, biblatexInlineCommands, verbCommands, rawInlineOr, listingsLanguage) @@ -331,6 +332,7 @@ unescapeURL = T.concat . go . T.splitOn "\\" inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines) inlineCommands = M.unions [ accentCommands tok + , miscCommands , citationCommands inline , siunitxCommands tok , acronymCommands diff --git a/src/Text/Pandoc/Readers/LaTeX/Inline.hs b/src/Text/Pandoc/Readers/LaTeX/Inline.hs index 15a1c4828..3021345b1 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Inline.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Inline.hs @@ -14,6 +14,7 @@ module Text.Pandoc.Readers.LaTeX.Inline , verbCommands , charCommands , accentCommands + , miscCommands , nameCommands , biblatexInlineCommands , refCommands @@ -183,6 +184,43 @@ verbCommands = M.fromList , ("Verb", doverb) ] +miscCommands :: PandocMonad m => M.Map Text (LP m Inlines) +miscCommands = + M.fromList + [ ("pounds", lit "£") + , ("euro", lit "€") + , ("copyright", lit "©") + , ("textasciicircum", lit "^") + , ("textasciitilde", lit "~") + , ("textbaht", lit "฿") + , ("textblank", lit "␢") + , ("textbigcircle", lit "○") + , ("textbrokenbar", lit "¦") + , ("textbullet", lit "•") + , ("textcentoldstyle", lit "¢") + , ("textcopyright", lit "©") + , ("textdagger", lit "†") + , ("textdegree", lit "°") + , ("textdollar", lit "$") + , ("textdong", lit "₫") + , ("textlira", lit "₤") + , ("textmu", lit "μ") + , ("textmusicalnote", lit "♪") + , ("textonehalf", lit "½") + , ("textonequarter", lit "¼") + , ("textparagraph", lit "¶") + , ("textpertenthousand", lit "‱") + , ("textpeso", lit "₱") + , ("textquotesingle", lit "'") + , ("textregistered", lit "®") + , ("textsection", lit "§") + , ("textsterling", lit "£") + , ("textthreequarters", lit "¾") + , ("textthreesuperior", lit "³") + , ("texttwosuperior", lit "²") + , ("textyen", lit "¥") + ] + accentCommands :: PandocMonad m => LP m Inlines -> M.Map Text (LP m Inlines) accentCommands tok = let accent = accentWith tok @@ -198,11 +236,6 @@ accentCommands tok = , ("AE", lit "Æ") , ("oe", lit "œ") , ("OE", lit "Œ") - , ("pounds", lit "£") - , ("euro", lit "€") - , ("copyright", lit "©") - , ("textasciicircum", lit "^") - , ("textasciitilde", lit "~") , ("H", accent '\779' Nothing) -- hungarumlaut , ("`", accent '\768' (Just '`')) -- grave , ("'", accent '\769' (Just '\'')) -- acute -- cgit v1.2.3