git.iko.soy/typeable/pandoc
on master help sign in
Move enquote commands to T.P.LaTeX.Lang.
da5e9e5John MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+2−20
@@ -59,6 +59,7 @@ import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
59import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
59import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
60import Text.Pandoc.Readers.LaTeX.Macro (macroDef)
60import Text.Pandoc.Readers.LaTeX.Macro (macroDef)
61import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
61import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
62+ enquoteCommands,
62 babelLangToBCP47, setDefaultLanguage)
63 babelLangToBCP47, setDefaultLanguage)
63import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
64import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
64import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
65import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
@@ -293,18 +294,6 @@ quoted' f starter ender = do
293lit :: Text -> LP m Inlines
294lit :: Text -> LP m Inlines
294lit = pure . str
295lit = pure . str
295
296
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−
308blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
297blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
309blockquote cvariant mblang = do
298blockquote cvariant mblang = do
310 citepar <- if cvariant
299 citepar <- if cvariant
@@ -359,6 +348,7 @@ inlineCommands = M.unions
359 , nameCommands
348 , nameCommands
360 , verbCommands
349 , verbCommands
361 , charCommands
350 , charCommands
351+ , enquoteCommands tok
362 , inlineLanguageCommands tok
352 , inlineLanguageCommands tok
363 , biblatexInlineCommands tok
353 , biblatexInlineCommands tok
364 , rest ]
354 , rest ]
@@ -418,14 +408,6 @@ inlineCommands = M.unions
418 src <- braced
408 src <- braced
419 mkImage options . unescapeURL . removeDoubleQuotes $
409 mkImage options . unescapeURL . removeDoubleQuotes $
420 untokenize src)
410 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)
429 , ("hyperlink", hyperlink)
411 , ("hyperlink", hyperlink)
430 , ("hypertarget", hypertargetInline)
412 , ("hypertarget", hypertargetInline)
431 -- hyphenat
413 -- hyphenat
src/Text/Pandoc/Readers/LaTeX/Inline.hs−2
@@ -155,8 +155,6 @@ romanNumeralArg = spaces *> (parser <|> inBraces)
155 Prelude.fail "Non-digits in argument to \\Rn or \\RN"
155 Prelude.fail "Non-digits in argument to \\Rn or \\RN"
156 safeRead digits
156 safeRead digits
157
157
158−
159−
160verbCommands :: PandocMonad m => M.Map Text (LP m Inlines)
158verbCommands :: PandocMonad m => M.Map Text (LP m Inlines)
161verbCommands = M.fromList
159verbCommands = M.fromList
162 [ ("verb", doverb)
160 [ ("verb", doverb)
src/Text/Pandoc/Readers/LaTeX/Lang.hs+32−2
@@ -15,6 +15,7 @@ module Text.Pandoc.Readers.LaTeX.Lang
15 ( setDefaultLanguage
15 ( setDefaultLanguage
16 , polyglossiaLangToBCP47
16 , polyglossiaLangToBCP47
17 , babelLangToBCP47
17 , babelLangToBCP47
18+ , enquoteCommands
18 , inlineLanguageCommands
19 , inlineLanguageCommands
19 )
20 )
20where
21where
@@ -25,8 +26,37 @@ import Text.Pandoc.Shared (extractSpaces)
25import Text.Pandoc.BCP47 (Lang(..), renderLang)
26import Text.Pandoc.BCP47 (Lang(..), renderLang)
26import Text.Pandoc.Class (PandocMonad(..), setTranslations)
27import Text.Pandoc.Class (PandocMonad(..), setTranslations)
27import Text.Pandoc.Readers.LaTeX.Parsing
28import Text.Pandoc.Readers.LaTeX.Parsing
28−import Text.Pandoc.Parsing (updateState, option)
29+import Text.Pandoc.Parsing (updateState, option, getState, QuoteContext(..),
30+ withQuoteContext)
29−import Text.Pandoc.Builder (Blocks, Inlines, setMeta, str, spanWith)
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+ ]
30
60
31foreignlanguage :: PandocMonad m => LP m Inlines -> LP m Inlines
61foreignlanguage :: PandocMonad m => LP m Inlines -> LP m Inlines
32foreignlanguage tok = do
62foreignlanguage tok = do