Move setDefaultLanguage to T.P.Readers.LaTeX.Lang.
This commit is contained in:
parent
5e571d9635
commit
564c39beef
2 changed files with 22 additions and 16 deletions
|
@ -44,7 +44,7 @@ import Text.Pandoc.Builder
|
|||
import Text.Pandoc.Class.PandocPure (PandocPure)
|
||||
import Text.Pandoc.Class.PandocMonad (PandocMonad (..), getResourcePath,
|
||||
readFileFromDirs, report, setResourcePath,
|
||||
setTranslations, translateTerm)
|
||||
translateTerm)
|
||||
import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError))
|
||||
import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
|
||||
import Text.Pandoc.ImageSize (numUnit, showFl)
|
||||
|
@ -59,7 +59,7 @@ import Text.Pandoc.Readers.LaTeX.Accent (accentCommands)
|
|||
import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
|
||||
import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
|
||||
import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,
|
||||
babelLangToBCP47)
|
||||
babelLangToBCP47, setDefaultLanguage)
|
||||
import Text.Pandoc.Readers.LaTeX.SIunitx
|
||||
import Text.Pandoc.Shared
|
||||
import qualified Text.Pandoc.Translations as Translations
|
||||
|
@ -1856,15 +1856,3 @@ block = do
|
|||
blocks :: PandocMonad m => LP m Blocks
|
||||
blocks = mconcat <$> many block
|
||||
|
||||
setDefaultLanguage :: PandocMonad m => LP m Blocks
|
||||
setDefaultLanguage = do
|
||||
o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')
|
||||
<$> rawopt
|
||||
polylang <- untokenize <$> braced
|
||||
case M.lookup polylang polyglossiaLangToBCP47 of
|
||||
Nothing -> return mempty -- TODO mzero? warning?
|
||||
Just langFunc -> do
|
||||
let l = langFunc o
|
||||
setTranslations l
|
||||
updateState $ setMeta "lang" $ str (renderLang l)
|
||||
return mempty
|
||||
|
|
|
@ -12,13 +12,31 @@ Functions for parsing polyglossia and babel language specifiers to
|
|||
BCP47 'Lang'.
|
||||
-}
|
||||
module Text.Pandoc.Readers.LaTeX.Lang
|
||||
( polyglossiaLangToBCP47
|
||||
( setDefaultLanguage
|
||||
, polyglossiaLangToBCP47
|
||||
, babelLangToBCP47
|
||||
)
|
||||
where
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Text as T
|
||||
import Text.Pandoc.BCP47 (Lang(..))
|
||||
import Text.Pandoc.BCP47 (Lang(..), renderLang)
|
||||
import Text.Pandoc.Class (PandocMonad(..), setTranslations)
|
||||
import Text.Pandoc.Readers.LaTeX.Parsing
|
||||
import Text.Pandoc.Parsing (updateState, option)
|
||||
import Text.Pandoc.Builder (Blocks, setMeta, str)
|
||||
|
||||
setDefaultLanguage :: PandocMonad m => LP m Blocks
|
||||
setDefaultLanguage = do
|
||||
o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')
|
||||
<$> rawopt
|
||||
polylang <- untokenize <$> braced
|
||||
case M.lookup polylang polyglossiaLangToBCP47 of
|
||||
Nothing -> return mempty -- TODO mzero? warning?
|
||||
Just langFunc -> do
|
||||
let l = langFunc o
|
||||
setTranslations l
|
||||
updateState $ setMeta "lang" $ str (renderLang l)
|
||||
return mempty
|
||||
|
||||
polyglossiaLangToBCP47 :: M.Map T.Text (T.Text -> Lang)
|
||||
polyglossiaLangToBCP47 = M.fromList
|
||||
|
|
Loading…
Add table
Reference in a new issue