@@ -34,14 +34,13 @@ 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)
38−import Text.Pandoc.Builder
38+import 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,
41− readFileFromDirs, report, setResourcePath,
41+ report, setResourcePath)
43−import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError))
42+import Text.Pandoc.Error (PandocError (PandocParsecError))
44−import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
43+import Text.Pandoc.Highlighting (languagesByExtension)
45import Text.Pandoc.ImageSize (numUnit, showFl)
44import Text.Pandoc.ImageSize (numUnit, showFl)
46import Text.Pandoc.Logging
45import Text.Pandoc.Logging
47import Text.Pandoc.Options
46import Text.Pandoc.Options
@@ -49,7 +48,6 @@ import Text.Pandoc.Parsing hiding (blankline, many, mathDisplay, mathInline,
49 optional, space, spaces, withRaw, (<|>))
48 optional, space, spaces, withRaw, (<|>))
50import Text.Pandoc.Readers.LaTeX.Types (Tok (..), TokType (..))
49import Text.Pandoc.Readers.LaTeX.Types (Tok (..), TokType (..))
51import Text.Pandoc.Readers.LaTeX.Parsing
50import Text.Pandoc.Readers.LaTeX.Parsing
52−import Text.Pandoc.Readers.LaTeX.Accent (accentCommands)
53import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
51import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
54import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
52import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
55 inlineEnvironment,
53 inlineEnvironment,
@@ -58,13 +56,20 @@ import Text.Pandoc.Readers.LaTeX.Math (dollarsMath, inlineEnvironments,
58 theoremEnvironment)
56 theoremEnvironment)
59import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
57import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
60import Text.Pandoc.Readers.LaTeX.Macro (macroDef)
58import Text.Pandoc.Readers.LaTeX.Macro (macroDef)
61−import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
59+import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
62 babelLangToBCP47, setDefaultLanguage)
61 babelLangToBCP47, setDefaultLanguage)
63import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
62import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
63+import Text.Pandoc.Readers.LaTeX.Include (insertIncluded,
64+ readFileFromTexinputs)
65+import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
66+ nameCommands, charCommands,
68+ biblatexInlineCommands,
69+ verbCommands, rawInlineOr,
64import Text.Pandoc.Shared
71import Text.Pandoc.Shared
65−import qualified Text.Pandoc.Translations as Translations
66import Text.Pandoc.Walk
72import Text.Pandoc.Walk
67−import qualified Text.Pandoc.Builder as B
68import Safe
73import Safe
70-- for debugging:
75-- for debugging:
@@ -231,19 +236,10 @@ mkImage options (T.unpack -> src) = do
231 _ -> return src
236 _ -> return src
232 return $ imageWith attr (T.pack src') "" alt
237 return $ imageWith attr (T.pack src') "" alt
234−doxspace :: PandocMonad m => LP m Inlines
236− (space <$ lookAhead (satisfyTok startsWithLetter)) <|> return mempty
237− where startsWithLetter (Tok _ Word t) =
239− Just (c, _) | isLetter c -> True
241− startsWithLetter _ = False
244removeDoubleQuotes :: Text -> Text
240removeDoubleQuotes :: Text -> Text
245removeDoubleQuotes t =
241removeDoubleQuotes t =
246− Data.Maybe.fromMaybe t $ T.stripPrefix "\"" t >>= T.stripSuffix "\""
242+ fromMaybe t $ T.stripPrefix "\"" t >>= T.stripSuffix "\""
248doubleQuote :: PandocMonad m => LP m Inlines
244doubleQuote :: PandocMonad m => LP m Inlines
249doubleQuote =
245doubleQuote =
@@ -290,18 +286,6 @@ quoted' f starter ender = do
290lit :: Text -> LP m Inlines
286lit :: Text -> LP m Inlines
291lit = pure . str
287lit = pure . str
293−enquote :: PandocMonad m => Bool -> Maybe Text -> LP m Inlines
294−enquote starred mblang = do
296− let lang = mblang >>= babelLangToBCP47
297− let langspan = case lang of
299− Just l -> spanWith ("",[],[("lang", renderLang l)])
300− quoteContext <- sQuoteContext <$> getState
301− if starred || quoteContext == InDoubleQuote
302− then singleQuoted . langspan <$> withQuoteContext InSingleQuote tok
303− else doubleQuoted . langspan <$> withQuoteContext InDoubleQuote tok
305blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
289blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
306blockquote cvariant mblang = do
290blockquote cvariant mblang = do
307 citepar <- if cvariant
291 citepar <- if cvariant
@@ -317,76 +301,6 @@ blockquote cvariant mblang = do
317 optional $ symbolIn (".:;?!" :: [Char]) -- currently ignored
301 optional $ symbolIn (".:;?!" :: [Char]) -- currently ignored
318 return $ blockQuote . langdiv $ (bs <> citepar)
302 return $ blockQuote . langdiv $ (bs <> citepar)
320−doAcronym :: PandocMonad m => Text -> LP m Inlines
323− return . mconcat $ [spanWith ("",[],[("acronym-label", untokenize acro),
324− ("acronym-form", "singular+" <> form)])
325− $ str $ untokenize acro]
327−doAcronymPlural :: PandocMonad m => Text -> LP m Inlines
328−doAcronymPlural form = do
331− return . mconcat $ [spanWith ("",[],[("acronym-label", untokenize acro),
332− ("acronym-form", "plural+" <> form)]) $
333− mconcat [str $ untokenize acro, plural]]
335−doverb :: PandocMonad m => LP m Inlines
337− Tok _ Symbol t <- anySymbol
338− marker <- case T.uncons t of
339− Just (c, ts) | T.null ts -> return c
342− code . untokenize <$>
343− manyTill (notFollowedBy newlineTok >> verbTok marker) (symbol marker)
345−verbTok :: PandocMonad m => Char -> LP m Tok
346−verbTok stopchar = do
347− t@(Tok pos toktype txt) <- anyTok
348− case T.findIndex (== stopchar) txt of
351− let (t1, t2) = T.splitAt i txt
353− setInput $ Tok (incSourceColumn pos i) Symbol (T.singleton stopchar)
354− : totoks (incSourceColumn pos (i + 1)) (T.drop 1 t2) ++ inp
355− return $ Tok pos toktype t1
357−listingsLanguage :: [(Text, Text)] -> Maybe Text
358−listingsLanguage opts =
359− case lookup "language" opts of
361− Just l -> fromListingsLanguage l `mplus` Just l
363−dolstinline :: PandocMonad m => LP m Inlines
365− options <- option [] keyvals
366− let classes = maybeToList $ listingsLanguage options
367− doinlinecode classes
369−domintinline :: PandocMonad m => LP m Inlines
372− cls <- untokenize <$> braced
375−doinlinecode :: PandocMonad m => [Text] -> LP m Inlines
376−doinlinecode classes = do
377− Tok _ Symbol t <- anySymbol
378− marker <- case T.uncons t of
379− Just (c, ts) | T.null ts -> return c
381− let stopchar = if marker == '{' then '}' else marker
383− codeWith ("",classes,[]) . T.map nlToSpace . untokenize <$>
384− manyTill (verbTok stopchar) (symbol stopchar)
386−nlToSpace :: Char -> Char
390inlineCommand' :: PandocMonad m => LP m Inlines
304inlineCommand' :: PandocMonad m => LP m Inlines
391inlineCommand' = try $ do
305inlineCommand' = try $ do
392 Tok _ (CtrlSeq name) cmd <- anyControlSeq
306 Tok _ (CtrlSeq name) cmd <- anyControlSeq
@@ -405,9 +319,6 @@ inlineCommand' = try $ do
405tok :: PandocMonad m => LP m Inlines
319tok :: PandocMonad m => LP m Inlines
406tok = tokWith inline
320tok = tokWith inline
408−inBrackets :: Inlines -> Inlines
409−inBrackets x = str "[" <> x <> str "]"
411unescapeURL :: Text -> Text
322unescapeURL :: Text -> Text
412unescapeURL = T.concat . go . T.splitOn "\\"
323unescapeURL = T.concat . go . T.splitOn "\\"
@@ -420,234 +331,99 @@ unescapeURL = T.concat . go . T.splitOn "\\"
420 | otherwise = "\\" <> t
331 | otherwise = "\\" <> t
422inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
333inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
423−inlineCommands =
334+inlineCommands = M.unions
424− M.union inlineLanguageCommands $
425− M.union (accentCommands tok) $
335+ [ accentCommands tok
426− M.union (citationCommands inline) $
336+ , citationCommands inline
427− M.union (siunitxCommands tok) $
337+ , siunitxCommands tok
343+ , enquoteCommands tok
344+ , inlineLanguageCommands tok
345+ , biblatexInlineCommands tok
428− M.fromList
348+ rest = M.fromList
429− [ ("emph", extractSpaces emph <$> tok)
349+ [ ("emph", extractSpaces emph <$> tok)
430− , ("textit", extractSpaces emph <$> tok)
350+ , ("textit", extractSpaces emph <$> tok)
431− , ("textsl", extractSpaces emph <$> tok)
351+ , ("textsl", extractSpaces emph <$> tok)
432− , ("textsc", extractSpaces smallcaps <$> tok)
352+ , ("textsc", extractSpaces smallcaps <$> tok)
433− , ("textsf", extractSpaces (spanWith ("",["sans-serif"],[])) <$> tok)
353+ , ("textsf", extractSpaces (spanWith ("",["sans-serif"],[])) <$> tok)
434− , ("textmd", extractSpaces (spanWith ("",["medium"],[])) <$> tok)
354+ , ("textmd", extractSpaces (spanWith ("",["medium"],[])) <$> tok)
435− , ("textrm", extractSpaces (spanWith ("",["roman"],[])) <$> tok)
355+ , ("textrm", extractSpaces (spanWith ("",["roman"],[])) <$> tok)
436− , ("textup", extractSpaces (spanWith ("",["upright"],[])) <$> tok)
356+ , ("textup", extractSpaces (spanWith ("",["upright"],[])) <$> tok)
437− , ("texttt", ttfamily)
357+ , ("texttt", ttfamily)
438− , ("sout", extractSpaces strikeout <$> tok)
358+ , ("sout", extractSpaces strikeout <$> tok)
439− , ("alert", skipopts >> spanWith ("",["alert"],[]) <$> tok) -- beamer
359+ , ("alert", skipopts >> spanWith ("",["alert"],[]) <$> tok) -- beamer
440− , ("lq", return (str "‘"))
441− , ("rq", return (str "’"))
442− , ("textquoteleft", return (str "‘"))
443− , ("textquoteright", return (str "’"))
444− , ("textquotedblleft", return (str "“"))
445− , ("textquotedblright", return (str "”"))
446− , ("textsuperscript", extractSpaces superscript <$> tok)
360+ , ("textsuperscript", extractSpaces superscript <$> tok)
447− , ("textsubscript", extractSpaces subscript <$> tok)
361+ , ("textsubscript", extractSpaces subscript <$> tok)
448− , ("textbackslash", lit "\\")
449− , ("backslash", lit "\\")
450− , ("slash", lit "/")
451− , ("textbf", extractSpaces strong <$> tok)
362+ , ("textbf", extractSpaces strong <$> tok)
452− , ("textnormal", extractSpaces (spanWith ("",["nodecor"],[])) <$> tok)
363+ , ("textnormal", extractSpaces (spanWith ("",["nodecor"],[])) <$> tok)
453− , ("underline", underline <$> tok)
364+ , ("underline", underline <$> tok)
454− , ("ldots", lit "…")
455− , ("vdots", lit "\8942")
457− , ("mdots", lit "…")
460− , ("label", rawInlineOr "label" dolabel)
461− , ("ref", rawInlineOr "ref" $ doref "ref")
462− , ("cref", rawInlineOr "cref" $ doref "ref") -- from cleveref.sty
463− , ("vref", rawInlineOr "vref" $ doref "ref+page") -- from varioref.sty
464− , ("eqref", rawInlineOr "eqref" $ doref "eqref") -- from amsmath.sty
465− , ("mbox", rawInlineOr "mbox" $ processHBox <$> tok)
365+ , ("mbox", rawInlineOr "mbox" $ processHBox <$> tok)
466− , ("hbox", rawInlineOr "hbox" $ processHBox <$> tok)
366+ , ("hbox", rawInlineOr "hbox" $ processHBox <$> tok)
467− , ("lettrine", rawInlineOr "lettrine" lettrine)
367+ , ("lettrine", rawInlineOr "lettrine" lettrine)
468− , ("(", mathInline . untokenize <$> manyTill anyTok (controlSeq ")"))
368+ , ("(", mathInline . untokenize <$> manyTill anyTok (controlSeq ")"))
469− , ("[", mathDisplay . untokenize <$> manyTill anyTok (controlSeq "]"))
369+ , ("[", mathDisplay . untokenize <$> manyTill anyTok (controlSeq "]"))
470− , ("ensuremath", mathInline . untokenize <$> braced)
370+ , ("ensuremath", mathInline . untokenize <$> braced)
471− , ("texorpdfstring", const <$> tok <*> tok)
371+ , ("texorpdfstring", const <$> tok <*> tok)
481− , ("qed", lit "\a0\x25FB")
482− -- old TeX commands
372+ -- old TeX commands
483− , ("em", extractSpaces emph <$> inlines)
373+ , ("em", extractSpaces emph <$> inlines)
484− , ("it", extractSpaces emph <$> inlines)
374+ , ("it", extractSpaces emph <$> inlines)
485− , ("sl", extractSpaces emph <$> inlines)
375+ , ("sl", extractSpaces emph <$> inlines)
486− , ("bf", extractSpaces strong <$> inlines)
376+ , ("bf", extractSpaces strong <$> inlines)
487− , ("tt", code . stringify . toList <$> inlines)
377+ , ("tt", code . stringify . toList <$> inlines)
488− , ("rm", inlines)
378+ , ("rm", inlines)
489− , ("itshape", extractSpaces emph <$> inlines)
379+ , ("itshape", extractSpaces emph <$> inlines)
490− , ("slshape", extractSpaces emph <$> inlines)
380+ , ("slshape", extractSpaces emph <$> inlines)
491− , ("scshape", extractSpaces smallcaps <$> inlines)
381+ , ("scshape", extractSpaces smallcaps <$> inlines)
492− , ("bfseries", extractSpaces strong <$> inlines)
382+ , ("bfseries", extractSpaces strong <$> inlines)
493− , ("MakeUppercase", makeUppercase <$> tok)
383+ , ("MakeUppercase", makeUppercase <$> tok)
494− , ("MakeTextUppercase", makeUppercase <$> tok) -- textcase
384+ , ("MakeTextUppercase", makeUppercase <$> tok) -- textcase
495− , ("uppercase", makeUppercase <$> tok)
385+ , ("uppercase", makeUppercase <$> tok)
496− , ("MakeLowercase", makeLowercase <$> tok)
386+ , ("MakeLowercase", makeLowercase <$> tok)
497− , ("MakeTextLowercase", makeLowercase <$> tok)
387+ , ("MakeTextLowercase", makeLowercase <$> tok)
498− , ("lowercase", makeLowercase <$> tok)
388+ , ("lowercase", makeLowercase <$> tok)
499− , ("/", pure mempty) -- italic correction
500− , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState
501− guard $ not inTableCell
504− , (",", lit "\8198")
505− , ("@", pure mempty)
507− , ("ps", pure $ str "PS." <> space)
508− , ("TeX", lit "TeX")
509− , ("LaTeX", lit "LaTeX")
511− , ("textless", lit "<")
512− , ("textgreater", lit ">")
513− , ("thanks", skipopts >> note <$> grouped block)
389+ , ("thanks", skipopts >> note <$> grouped block)
514− , ("footnote", skipopts >> note <$> grouped block)
390+ , ("footnote", skipopts >> note <$> grouped block)
515− , ("passthrough", tok) -- \passthrough macro used by latex writer
391+ , ("passthrough", tok) -- \passthrough macro used by latex writer
516− -- for listings
392+ -- for listings
518− , ("lstinline", dolstinline)
519− , ("mintinline", domintinline)
521− , ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$>
393+ , ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$>
522− bracedUrl)
394+ bracedUrl)
523− , ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl)
395+ , ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl)
524− , ("href", do url <- bracedUrl
396+ , ("href", do url <- bracedUrl
526− link (unescapeURL $ untokenize url) "" <$> tok)
398+ link (unescapeURL $ untokenize url) "" <$> tok)
527− , ("includegraphics", do options <- option [] keyvals
399+ , ("includegraphics", do options <- option [] keyvals
528− src <- braced
400+ src <- braced
529− mkImage options . unescapeURL . removeDoubleQuotes $
401+ mkImage options . unescapeURL .
530− untokenize src)
402+ removeDoubleQuotes $ untokenize src)
531− , ("enquote*", enquote True Nothing)
532− , ("enquote", enquote False Nothing)
533− -- foreignquote is supposed to use native quote marks
534− , ("foreignquote*", braced >>= enquote True . Just . untokenize)
535− , ("foreignquote", braced >>= enquote False . Just . untokenize)
536− -- hypehnquote uses regular quotes
537− , ("hyphenquote*", braced >>= enquote True . Just . untokenize)
538− , ("hyphenquote", braced >>= enquote False . Just . untokenize)
539− , ("figurename", doTerm Translations.Figure)
540− , ("prefacename", doTerm Translations.Preface)
541− , ("refname", doTerm Translations.References)
542− , ("bibname", doTerm Translations.Bibliography)
543− , ("chaptername", doTerm Translations.Chapter)
544− , ("partname", doTerm Translations.Part)
545− , ("contentsname", doTerm Translations.Contents)
546− , ("listfigurename", doTerm Translations.ListOfFigures)
547− , ("listtablename", doTerm Translations.ListOfTables)
548− , ("indexname", doTerm Translations.Index)
549− , ("abstractname", doTerm Translations.Abstract)
550− , ("tablename", doTerm Translations.Table)
551− , ("enclname", doTerm Translations.Encl)
552− , ("ccname", doTerm Translations.Cc)
553− , ("headtoname", doTerm Translations.To)
554− , ("pagename", doTerm Translations.Page)
555− , ("seename", doTerm Translations.See)
556− , ("seealsoname", doTerm Translations.SeeAlso)
557− , ("proofname", doTerm Translations.Proof)
558− , ("glossaryname", doTerm Translations.Glossary)
559− , ("lstlistingname", doTerm Translations.Listing)
560− , ("hyperlink", hyperlink)
403+ , ("hyperlink", hyperlink)
561− , ("hypertarget", hypertargetInline)
404+ , ("hypertarget", hypertargetInline)
562− -- glossaries package
563− , ("gls", doAcronym "short")
564− , ("Gls", doAcronym "short")
565− , ("glsdesc", doAcronym "long")
566− , ("Glsdesc", doAcronym "long")
567− , ("GLSdesc", doAcronym "long")
568− , ("acrlong", doAcronym "long")
569− , ("Acrlong", doAcronym "long")
570− , ("acrfull", doAcronym "full")
571− , ("Acrfull", doAcronym "full")
572− , ("acrshort", doAcronym "abbrv")
573− , ("Acrshort", doAcronym "abbrv")
574− , ("glspl", doAcronymPlural "short")
575− , ("Glspl", doAcronymPlural "short")
576− , ("glsdescplural", doAcronymPlural "long")
577− , ("Glsdescplural", doAcronymPlural "long")
578− , ("GLSdescplural", doAcronymPlural "long")
580− , ("ac", doAcronym "short")
581− , ("acf", doAcronym "full")
582− , ("acs", doAcronym "abbrv")
583− , ("acl", doAcronym "long")
584− , ("acp", doAcronymPlural "short")
585− , ("acfp", doAcronymPlural "full")
586− , ("acsp", doAcronymPlural "abbrv")
587− , ("aclp", doAcronymPlural "long")
588− , ("Ac", doAcronym "short")
589− , ("Acf", doAcronym "full")
590− , ("Acs", doAcronym "abbrv")
591− , ("Acl", doAcronym "long")
592− , ("Acp", doAcronymPlural "short")
593− , ("Acfp", doAcronymPlural "full")
594− , ("Acsp", doAcronymPlural "abbrv")
595− , ("Aclp", doAcronymPlural "long")
596− -- hyphenat
405+ -- hyphenat
597− , ("bshyp", lit "\\\173")
598− , ("fshyp", lit "/\173")
599− , ("dothyp", lit ".\173")
600− , ("colonhyp", lit ":\173")
602− , ("nohyphens", tok)
406+ , ("nohyphens", tok)
603− , ("textnhtt", ttfamily)
407+ , ("textnhtt", ttfamily)
604− , ("nhttfamily", ttfamily)
408+ , ("nhttfamily", ttfamily)
605− -- LaTeX colors
409+ -- LaTeX colors
606− , ("textcolor", coloredInline "color")
410+ , ("textcolor", coloredInline "color")
607− , ("colorbox", coloredInline "background-color")
411+ , ("colorbox", coloredInline "background-color")
609− , ("faCheck", lit "\10003")
610− , ("faClose", lit "\10007")
612− , ("xspace", doxspace)
613− -- etoolbox
412+ -- etoolbox
614− , ("ifstrequal", ifstrequal)
413+ , ("ifstrequal", ifstrequal)
615− , ("newtoggle", braced >>= newToggle)
414+ , ("newtoggle", braced >>= newToggle)
616− , ("toggletrue", braced >>= setToggle True)
415+ , ("toggletrue", braced >>= setToggle True)
617− , ("togglefalse", braced >>= setToggle False)
416+ , ("togglefalse", braced >>= setToggle False)
618− , ("iftoggle", try $ ifToggle >> inline)
417+ , ("iftoggle", try $ ifToggle >> inline)
620− , ("RN", romanNumeralUpper)
621− , ("Rn", romanNumeralLower)
623− , ("foreignlanguage", foreignlanguage)
624− -- include
418+ -- include
625− , ("input", rawInlineOr "input" $ include "input")
419+ , ("input", rawInlineOr "input" $ include "input")
626− -- soul package
420+ -- soul package
627− , ("ul", underline <$> tok)
421+ , ("ul", underline <$> tok)
628− -- ulem package
422+ -- ulem package
629− , ("uline", underline <$> tok)
423+ , ("uline", underline <$> tok)
630− -- plain tex stuff that should just be passed through as raw tex
424+ -- plain tex stuff that should just be passed through as raw tex
631− , ("ifdim", ifdim)
425+ , ("ifdim", ifdim)
633− , ("mkbibquote", spanWith nullAttr . doubleQuoted <$> tok)
634− , ("mkbibemph", spanWith nullAttr . emph <$> tok)
635− , ("mkbibitalic", spanWith nullAttr . emph <$> tok)
636− , ("mkbibbold", spanWith nullAttr . strong <$> tok)
638− spanWith nullAttr . (\x -> str "(" <> x <> str ")") <$> tok)
640− spanWith nullAttr . (\x -> str "[" <> x <> str "]") <$> tok)
641− , ("autocap", spanWith nullAttr <$> tok)
642− , ("textnormal", spanWith ("",["nodecor"],[]) <$> tok)
644− (\x -> spanWith ("",[],[("bibstring",x)]) (str x)) . untokenize
646− , ("adddot", pure (str "."))
647− , ("adddotspace", pure (spanWith nullAttr (str "." <> space)))
648− , ("addabbrvspace", pure space)
649− , ("hyphen", pure (str "-"))
652lettrine :: PandocMonad m => LP m Inlines
428lettrine :: PandocMonad m => LP m Inlines
653lettrine = do
429lettrine = do
@@ -671,26 +447,6 @@ alterStr :: (Text -> Text) -> Inline -> Inline
671alterStr f (Str xs) = Str (f xs)
447alterStr f (Str xs) = Str (f xs)
672alterStr _ x = x
448alterStr _ x = x
674−foreignlanguage :: PandocMonad m => LP m Inlines
676− babelLang <- untokenize <$> braced
677− case babelLangToBCP47 babelLang of
678− Just lang -> spanWith ("", [], [("lang", renderLang lang)]) <$> tok
681−inlineLanguageCommands :: PandocMonad m => M.Map Text (LP m Inlines)
682−inlineLanguageCommands = M.fromList $ mk <$> M.toList polyglossiaLangToBCP47
684− mk (polyglossia, bcp47Func) =
685− ("text" <> polyglossia, inlineLanguage bcp47Func)
687−inlineLanguage :: PandocMonad m => (Text -> Lang) -> LP m Inlines
688−inlineLanguage bcp47Func = do
689− o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')
691− let lang = renderLang $ bcp47Func o
692− extractSpaces (spanWith ("", [], [("lang", lang)])) <$> tok
694hyperlink :: PandocMonad m => LP m Inlines
450hyperlink :: PandocMonad m => LP m Inlines
695hyperlink = try $ do
451hyperlink = try $ do
696 src <- untokenize <$> braced
452 src <- untokenize <$> braced
@@ -711,31 +467,6 @@ hypertargetInline = try $ do
711 ils <- grouped inline
467 ils <- grouped inline
712 return $ spanWith (ref, [], []) ils
468 return $ spanWith (ref, [], []) ils
714−romanNumeralUpper :: (PandocMonad m) => LP m Inlines
716− str . toRomanNumeral <$> romanNumeralArg
718−romanNumeralLower :: (PandocMonad m) => LP m Inlines
720− str . T.toLower . toRomanNumeral <$> romanNumeralArg
722−romanNumeralArg :: (PandocMonad m) => LP m Int
723−romanNumeralArg = spaces *> (parser <|> inBraces)
733− s <- untokenize <$> many1 (satisfyTok isWordTok)
734− let (digits, rest) = T.span isDigit s
735− unless (T.null rest) $
736− Prelude.fail "Non-digits in argument to \\Rn or \\RN"
739newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a
470newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a
740newToggle name = do
471newToggle name = do
741 updateState $ \st ->
472 updateState $ \st ->
@@ -766,9 +497,6 @@ ifToggle = do
766 report $ UndefinedToggle name' pos
497 report $ UndefinedToggle name' pos
767 return ()
498 return ()
769−doTerm :: PandocMonad m => Translations.Term -> LP m Inlines
770−doTerm term = str <$> translateTerm term
772ifstrequal :: (PandocMonad m, Monoid a) => LP m a
500ifstrequal :: (PandocMonad m, Monoid a) => LP m a
773ifstrequal = do
501ifstrequal = do
774 str1 <- tok
502 str1 <- tok
@@ -789,13 +517,6 @@ coloredInline stylename = do
789ttfamily :: PandocMonad m => LP m Inlines
517ttfamily :: PandocMonad m => LP m Inlines
790ttfamily = code . stringify . toList <$> tok
518ttfamily = code . stringify . toList <$> tok
792−rawInlineOr :: PandocMonad m => Text -> LP m Inlines -> LP m Inlines
793−rawInlineOr name' fallback = do
794− parseRaw <- extensionEnabled Ext_raw_tex <$> getOption readerExtensions
796− then rawInline "latex" <$> getRawCommand name' ("\\" <> name')
799processHBox :: Inlines -> Inlines
520processHBox :: Inlines -> Inlines
800processHBox = walk convert
521processHBox = walk convert
@@ -846,25 +567,6 @@ treatAsInline = Set.fromList
846 , "pagebreak"
567 , "pagebreak"
849−dolabel :: PandocMonad m => LP m Inlines
852− let refstr = untokenize v
853− updateState $ \st ->
854− st{ sLastLabel = Just refstr }
855− return $ spanWith (refstr,[],[("label", refstr)])
856− $ inBrackets $ str $ untokenize v
858−doref :: PandocMonad m => Text -> LP m Inlines
861− let refstr = untokenize v
862− return $ linkWith ("",[],[ ("reference-type", cls)
863− , ("reference", refstr)])
866− (inBrackets $ str refstr)
868lookupListDefault :: (Ord k) => v -> [k] -> M.Map k v -> v
570lookupListDefault :: (Ord k) => v -> [k] -> M.Map k v -> v
869lookupListDefault d = (fromMaybe d .) . lookupList
571lookupListDefault d = (fromMaybe d .) . lookupList
870 where lookupList l m = msum $ map (`M.lookup` m) l
572 where lookupList l m = msum $ map (`M.lookup` m) l
@@ -986,39 +688,6 @@ include name = do
986 mapM_ (insertIncluded defaultExt) fs
688 mapM_ (insertIncluded defaultExt) fs
987 return mempty
689 return mempty
989−readFileFromTexinputs :: PandocMonad m => FilePath -> LP m (Maybe Text)
990−readFileFromTexinputs fp = do
991− fileContentsMap <- sFileContents <$> getState
992− case M.lookup (T.pack fp) fileContentsMap of
993− Just t -> return (Just t)
995− dirs <- map T.unpack . splitTextBy (==':') . fromMaybe "."
996− <$> lookupEnv "TEXINPUTS"
997− readFileFromDirs dirs fp
999−insertIncluded :: PandocMonad m
1003−insertIncluded defaultExtension f' = do
1004− let f = case takeExtension f' of
1007− _ -> addExtension f' defaultExtension
1009− containers <- getIncludeFiles <$> getState
1010− when (T.pack f `elem` containers) $
1011− throwError $ PandocParseError $ T.pack $ "Include file loop at " ++ show pos
1012− updateState $ addIncludeFile $ T.pack f
1013− mbcontents <- readFileFromTexinputs f
1014− contents <- case mbcontents of
1017− report $ CouldNotLoadIncludeFile (T.pack f) pos
1019− getInput >>= setInput . (tokenize f contents ++)
1020− updateState dropLatestIncludeFile
1022authors :: PandocMonad m => LP m ()
691authors :: PandocMonad m => LP m ()
1023authors = try $ do
692authors = try $ do