git.iko.soy/typeable/pandoc
on master help sign in
Move enquote commands to T.P.LaTeX.Lang.
commit24e9991d6b5ecf71e85f27d24998102ba1c99e1d authorJohn MacFarlane <jgm@berkeley.edu> dateWed 3 Mar 2021, 11:22 (6 years ago) parent953cbb7
3 files changed+34−24
src/Text/Pandoc/Readers/LaTeX.hs+2−20 src/Text/Pandoc/Readers/LaTeX/Inline.hs−2 src/Text/Pandoc/Readers/LaTeX/Lang.hs+32−2
src/Text/Pandoc/Readers/LaTeX.hs+2−20
@@ -59,6 +59,7 @@ import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
5959import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
6060import Text.Pandoc.Readers.LaTeX.Macro (macroDef)
6161import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
62+ enquoteCommands,
6263 babelLangToBCP47, setDefaultLanguage)
6364import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
6465import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
@@ -293,18 +294,6 @@ quoted' f starter ender = do
293294lit :: Text -> LP m Inlines
294295lit = pure . str
295296
296−enquote :: PandocMonad m => Bool -> Maybe Text -> LP m Inlines
297−enquote starred mblang = do
298− skipopts
299− let lang = mblang >>= babelLangToBCP47
300− let langspan = case lang of
301− Nothing -> id
302− Just l -> spanWith ("",[],[("lang", renderLang l)])
303− quoteContext <- sQuoteContext <$> getState
304− if starred || quoteContext == InDoubleQuote
305− then singleQuoted . langspan <$> withQuoteContext InSingleQuote tok
306− else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok
307−
308297blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
309298blockquote cvariant mblang = do
310299 citepar <- if cvariant
@@ -359,6 +348,7 @@ inlineCommands = M.unions
359348 , nameCommands
360349 , verbCommands
361350 , charCommands
351+ , enquoteCommands tok
362352 , inlineLanguageCommands tok
363353 , biblatexInlineCommands tok
364354 , rest ]
@@ -418,14 +408,6 @@ inlineCommands = M.unions
418408 src <- braced
419409 mkImage options . unescapeURL . removeDoubleQuotes $
420410 untokenize src)
421− , ("enquote*", enquote True Nothing)
422− , ("enquote", enquote False Nothing)
423− -- foreignquote is supposed to use native quote marks
424− , ("foreignquote*", braced >>= enquote True . Just . untokenize)
425− , ("foreignquote", braced >>= enquote False . Just . untokenize)
426− -- hypehnquote uses regular quotes
427− , ("hyphenquote*", braced >>= enquote True . Just . untokenize)
428− , ("hyphenquote", braced >>= enquote False . Just . untokenize)
429411 , ("hyperlink", hyperlink)
430412 , ("hypertarget", hypertargetInline)
431413 -- hyphenat
src/Text/Pandoc/Readers/LaTeX/Inline.hs−2
@@ -155,8 +155,6 @@ romanNumeralArg = spaces *> (parser <|> inBraces)
155155 Prelude.fail "Non-digits in argument to \\Rn or \\RN"
156156 safeRead digits
157157
158−
159−
160158verbCommands :: PandocMonad m => M.Map Text (LP m Inlines)
161159verbCommands = M.fromList
162160 [ ("verb", doverb)
src/Text/Pandoc/Readers/LaTeX/Lang.hs+32−2
@@ -15,6 +15,7 @@ module Text.Pandoc.Readers.LaTeX.Lang
1515 ( setDefaultLanguage
1616 , polyglossiaLangToBCP47
1717 , babelLangToBCP47
18+ , enquoteCommands
1819 , inlineLanguageCommands
1920 )
2021where
@@ -25,8 +26,37 @@ import Text.Pandoc.Shared (extractSpaces)
2526import Text.Pandoc.BCP47 (Lang(..), renderLang)
2627import Text.Pandoc.Class (PandocMonad(..), setTranslations)
2728import Text.Pandoc.Readers.LaTeX.Parsing
28−import Text.Pandoc.Parsing (updateState, option)
29−import Text.Pandoc.Builder (Blocks, Inlines, setMeta, str, spanWith)
29+import Text.Pandoc.Parsing (updateState, option, getState, QuoteContext(..),
30+ withQuoteContext)
31+import Text.Pandoc.Builder (Blocks, Inlines, setMeta, str, spanWith,
32+ singleQuoted, doubleQuoted)
33+
34+enquote :: PandocMonad m
35+ => LP m Inlines
36+ -> Bool -> Maybe Text -> LP m Inlines
37+enquote tok starred mblang = do
38+ skipopts
39+ let lang = mblang >>= babelLangToBCP47
40+ let langspan = case lang of
41+ Nothing -> id
42+ Just l -> spanWith ("",[],[("lang", renderLang l)])
43+ quoteContext <- sQuoteContext <$> getState
44+ if starred || quoteContext == InDoubleQuote
45+ then singleQuoted . langspan <$> withQuoteContext InSingleQuote tok
46+ else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok
47+
48+enquoteCommands :: PandocMonad m
49+ => LP m Inlines -> M.Map Text (LP m Inlines)
50+enquoteCommands tok = M.fromList
51+ [ ("enquote*", enquote tok True Nothing)
52+ , ("enquote", enquote tok False Nothing)
53+ -- foreignquote is supposed to use native quote marks
54+ , ("foreignquote*", braced >>= enquote tok True . Just . untokenize)
55+ , ("foreignquote", braced >>= enquote tok False . Just . untokenize)
56+ -- hypehnquote uses regular quotes
57+ , ("hyphenquote*", braced >>= enquote tok True . Just . untokenize)
58+ , ("hyphenquote", braced >>= enquote tok False . Just . untokenize)
59+ ]
3060
3161foreignlanguage :: PandocMonad m => LP m Inlines -> LP m Inlines
3262foreignlanguage tok = do