git.iko.soy/typeable/pandoc
on master help sign in
Move setDefaultLanguage to T.P.Readers.LaTeX.Lang.
commit564c39beef36bf008fa5d2c840560ef064152e7d authorJohn MacFarlane <jgm@berkeley.edu> dateSun 28 Feb 2021, 09:49 (6 years ago) parent5e571d9
2 files changed+22−16
src/Text/Pandoc/Readers/LaTeX.hs+2−14 src/Text/Pandoc/Readers/LaTeX/Lang.hs+20−2
src/Text/Pandoc/Readers/LaTeX.hs+2−14
@@ -44,7 +44,7 @@ import Text.Pandoc.Builder
4444import Text.Pandoc.Class.PandocPure (PandocPure)
4545import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
4646 readFileFromDirs, report, setResourcePath,
47− setTranslations, translateTerm)
47+ translateTerm)
4848import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError))
4949import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
5050import Text.Pandoc.ImageSize (numUnit, showFl)
@@ -59,7 +59,7 @@ import Text.Pandoc.Readers.LaTeX.Accent (accentCommands)
5959import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
6060import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
6161import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
62− babelLangToBCP47)
62+ babelLangToBCP47, setDefaultLanguage)
6363import Text.Pandoc.Readers.LaTeX.SIunitx
6464import Text.Pandoc.Shared
6565import qualified Text.Pandoc.Translations as Translations
@@ -1856,15 +1856,3 @@ block = do
18561856blocks :: PandocMonad m => LP m Blocks
18571857blocks = mconcat <$> many block
18581858
1859−setDefaultLanguage :: PandocMonad m => LP m Blocks
1860−setDefaultLanguage = do
1861− o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')
1862− <$> rawopt
1863− polylang <- untokenize <$> braced
1864− case M.lookup polylang polyglossiaLangToBCP47 of
1865− Nothing -> return mempty -- TODO mzero? warning?
1866− Just langFunc -> do
1867− let l = langFunc o
1868− setTranslations l
1869− updateState $ setMeta "lang" $ str (renderLang l)
1870− return mempty
src/Text/Pandoc/Readers/LaTeX/Lang.hs+20−2
@@ -12,13 +12,31 @@ Functions for parsing polyglossia and babel language specifiers to
1212BCP47 'Lang'.
1313-}
1414module Text.Pandoc.Readers.LaTeX.Lang
15− ( polyglossiaLangToBCP47
15+ ( setDefaultLanguage
16+ , polyglossiaLangToBCP47
1617 , babelLangToBCP47
1718 )
1819where
1920import qualified Data.Map as M
2021import qualified Data.Text as T
21−import Text.Pandoc.BCP47 (Lang(..))
22+import Text.Pandoc.BCP47 (Lang(..), renderLang)
23+import Text.Pandoc.Class (PandocMonad(..), setTranslations)
24+import Text.Pandoc.Readers.LaTeX.Parsing
25+import Text.Pandoc.Parsing (updateState, option)
26+import Text.Pandoc.Builder (Blocks, setMeta, str)
27+
28+setDefaultLanguage :: PandocMonad m => LP m Blocks
29+setDefaultLanguage = do
30+ o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')
31+ <$> rawopt
32+ polylang <- untokenize <$> braced
33+ case M.lookup polylang polyglossiaLangToBCP47 of
34+ Nothing -> return mempty -- TODO mzero? warning?
35+ Just langFunc -> do
36+ let l = langFunc o
37+ setTranslations l
38+ updateState $ setMeta "lang" $ str (renderLang l)
39+ return mempty
2240
2341polyglossiaLangToBCP47 :: M.Map T.Text (T.Text -> Lang)
2442polyglossiaLangToBCP47 = M.fromList