@@ -34,7 +34,7 @@ import qualified Data.Set as Set
34import Data.Text (Text)
34import Data.Text (Text)
35import qualified Data.Text as T
35import qualified Data.Text as T
36import System.FilePath (addExtension, replaceExtension, takeExtension)
36import System.FilePath (addExtension, replaceExtension, takeExtension)
37−import Text.Pandoc.BCP47 (Lang (..), renderLang)
37+import Text.Pandoc.BCP47 (renderLang)
38import Text.Pandoc.Builder as B
38import Text.Pandoc.Builder as B
39import Text.Pandoc.Class.PandocPure (PandocPure)
39import Text.Pandoc.Class.PandocPure (PandocPure)
40import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
40import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
@@ -58,11 +58,12 @@ import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
58 theoremEnvironment)
58 theoremEnvironment)
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)
61−import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
61+import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
62 babelLangToBCP47, setDefaultLanguage)
62 babelLangToBCP47, setDefaultLanguage)
63import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
63import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
64import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
64import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
65 nameCommands, charCommands,
65 nameCommands, charCommands,
66+ biblatexInlineCommands,
66 verbCommands, rawInlineOr,
67 verbCommands, rawInlineOr,
67 listingsLanguage)
68 listingsLanguage)
68import Text.Pandoc.Shared
69import Text.Pandoc.Shared
@@ -350,8 +351,7 @@ unescapeURL = T.concat . go . T.splitOn "\\"
351inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
352inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
352inlineCommands = M.unions
353inlineCommands = M.unions
353− [ inlineLanguageCommands
354− , accentCommands tok
354+ [ accentCommands tok
355 , citationCommands inline
355 , citationCommands inline
356 , siunitxCommands tok
356 , siunitxCommands tok
357 , acronymCommands
357 , acronymCommands
@@ -359,6 +359,8 @@ inlineCommands = M.unions
359 , nameCommands
359 , nameCommands
360 , verbCommands
360 , verbCommands
361 , charCommands
361 , charCommands
362+ , inlineLanguageCommands tok
363+ , biblatexInlineCommands tok
364 rest = M.fromList
366 rest = M.fromList
@@ -373,12 +375,6 @@ inlineCommands = M.unions
373 , ("texttt", ttfamily)
375 , ("texttt", ttfamily)
374 , ("sout", extractSpaces strikeout <$> tok)
376 , ("sout", extractSpaces strikeout <$> tok)
375 , ("alert", skipopts >> spanWith ("",["alert"],[]) <$> tok) -- beamer
377 , ("alert", skipopts >> spanWith ("",["alert"],[]) <$> tok) -- beamer
376− , ("lq", return (str "‘"))
377− , ("rq", return (str "’"))
378− , ("textquoteleft", return (str "‘"))
379− , ("textquoteright", return (str "’"))
380− , ("textquotedblleft", return (str "“"))
381− , ("textquotedblright", return (str "”"))
382 , ("textsuperscript", extractSpaces superscript <$> tok)
378 , ("textsuperscript", extractSpaces superscript <$> tok)
383 , ("textsubscript", extractSpaces subscript <$> tok)
379 , ("textsubscript", extractSpaces subscript <$> tok)
384 , ("textbf", extractSpaces strong <$> tok)
380 , ("textbf", extractSpaces strong <$> tok)
@@ -447,11 +443,6 @@ inlineCommands = M.unions
447 , ("toggletrue", braced >>= setToggle True)
443 , ("toggletrue", braced >>= setToggle True)
448 , ("togglefalse", braced >>= setToggle False)
444 , ("togglefalse", braced >>= setToggle False)
449 , ("iftoggle", try $ ifToggle >> inline)
445 , ("iftoggle", try $ ifToggle >> inline)
451− , ("RN", romanNumeralUpper)
452− , ("Rn", romanNumeralLower)
454− , ("foreignlanguage", foreignlanguage)
455 -- include
446 -- include
456 , ("input", rawInlineOr "input" $ include "input")
447 , ("input", rawInlineOr "input" $ include "input")
457 -- soul package
448 -- soul package
@@ -460,24 +451,6 @@ inlineCommands = M.unions
460 , ("uline", underline <$> tok)
451 , ("uline", underline <$> tok)
461 -- plain tex stuff that should just be passed through as raw tex
452 -- plain tex stuff that should just be passed through as raw tex
462 , ("ifdim", ifdim)
453 , ("ifdim", ifdim)
464− , ("mkbibquote", spanWith nullAttr . doubleQuoted <$> tok)
465− , ("mkbibemph", spanWith nullAttr . emph <$> tok)
466− , ("mkbibitalic", spanWith nullAttr . emph <$> tok)
467− , ("mkbibbold", spanWith nullAttr . strong <$> tok)
469− spanWith nullAttr . (\x -> str "(" <> x <> str ")") <$> tok)
471− spanWith nullAttr . (\x -> str "[" <> x <> str "]") <$> tok)
472− , ("autocap", spanWith nullAttr <$> tok)
473− , ("textnormal", spanWith ("",["nodecor"],[]) <$> tok)
475− (\x -> spanWith ("",[],[("bibstring",x)]) (str x)) . untokenize
477− , ("adddot", pure (str "."))
478− , ("adddotspace", pure (spanWith nullAttr (str "." <> space)))
479− , ("addabbrvspace", pure space)
480− , ("hyphen", pure (str "-"))
483lettrine :: PandocMonad m => LP m Inlines
456lettrine :: PandocMonad m => LP m Inlines
@@ -502,26 +475,6 @@ alterStr :: (Text -> Text) -> Inline -> Inline
502alterStr f (Str xs) = Str (f xs)
475alterStr f (Str xs) = Str (f xs)
503alterStr _ x = x
476alterStr _ x = x
505−foreignlanguage :: PandocMonad m => LP m Inlines
507− babelLang <- untokenize <$> braced
508− case babelLangToBCP47 babelLang of
509− Just lang -> spanWith ("", [], [("lang", renderLang lang)]) <$> tok
512−inlineLanguageCommands :: PandocMonad m => M.Map Text (LP m Inlines)
513−inlineLanguageCommands = M.fromList $ mk <$> M.toList polyglossiaLangToBCP47
515− mk (polyglossia, bcp47Func) =
516− ("text" <> polyglossia, inlineLanguage bcp47Func)
518−inlineLanguage :: PandocMonad m => (Text -> Lang) -> LP m Inlines
519−inlineLanguage bcp47Func = do
520− o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')
522− let lang = renderLang $ bcp47Func o
523− extractSpaces (spanWith ("", [], [("lang", lang)])) <$> tok
525hyperlink :: PandocMonad m => LP m Inlines
478hyperlink :: PandocMonad m => LP m Inlines
526hyperlink = try $ do
479hyperlink = try $ do
527 src <- untokenize <$> braced
480 src <- untokenize <$> braced
@@ -542,31 +495,6 @@ hypertargetInline = try $ do
542 ils <- grouped inline
495 ils <- grouped inline
543 return $ spanWith (ref, [], []) ils
496 return $ spanWith (ref, [], []) ils
545−romanNumeralUpper :: (PandocMonad m) => LP m Inlines
547− str . toRomanNumeral <$> romanNumeralArg
549−romanNumeralLower :: (PandocMonad m) => LP m Inlines
551− str . T.toLower . toRomanNumeral <$> romanNumeralArg
553−romanNumeralArg :: (PandocMonad m) => LP m Int
554−romanNumeralArg = spaces *> (parser <|> inBraces)
564− s <- untokenize <$> many1 (satisfyTok isWordTok)
565− let (digits, rest) = T.span isDigit s
566− unless (T.null rest) $
567− Prelude.fail "Non-digits in argument to \\Rn or \\RN"
570newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a
498newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a
571newToggle name = do
499newToggle name = do
572 updateState $ \st ->
500 updateState $ \st ->