@@ -68,11 +68,13 @@ import qualified Text.Pandoc.Builder as B
68import Text.Pandoc.Class (PandocMonad (..))
68import Text.Pandoc.Class (PandocMonad (..))
69import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
69import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
70import Text.Pandoc.Definition
70import Text.Pandoc.Definition
71+import Text.Pandoc.Readers.LaTeX (rawLaTeXInline)
72+import Text.Pandoc.Readers.LaTeX.Types (Macro)
71import Text.Pandoc.Error
73import Text.Pandoc.Error
72import Text.Pandoc.Logging
74import Text.Pandoc.Logging
73import Text.Pandoc.Options (
75import Text.Pandoc.Options (
74 Extension (Ext_epub_html_exts, Ext_empty_paragraphs, Ext_native_divs,
76 Extension (Ext_epub_html_exts, Ext_empty_paragraphs, Ext_native_divs,
75− Ext_native_spans, Ext_raw_html, Ext_line_blocks),
77+ Ext_native_spans, Ext_raw_html, Ext_line_blocks, Ext_raw_tex),
76 ReaderOptions (readerExtensions, readerStripComments),
78 ReaderOptions (readerExtensions, readerStripComments),
77 extensionEnabled)
79 extensionEnabled)
78import Text.Pandoc.Parsing hiding ((<|>))
80import Text.Pandoc.Parsing hiding ((<|>))
@@ -102,7 +104,8 @@ readHtml opts inp = do
102 (m:_) -> messageString m
104 (m:_) -> messageString m
103 result <- flip runReaderT def $
105 result <- flip runReaderT def $
104 runParserT parseDoc
106 runParserT parseDoc
105− (HTMLState def{ stateOptions = opts } [] Nothing Set.empty M.empty [])
107+ (HTMLState def{ stateOptions = opts }
108+ [] Nothing Set.empty M.empty [] M.empty)
106 "source" tags
109 "source" tags
107 case result of
110 case result of
108 Right doc -> return doc
111 Right doc -> return doc
@@ -124,7 +127,8 @@ data HTMLState =
124 baseHref :: Maybe URI,
127 baseHref :: Maybe URI,
125 identifiers :: Set.Set String,
128 identifiers :: Set.Set String,
126 headerMap :: M.Map Inlines String,
129 headerMap :: M.Map Inlines String,
127− logMessages :: [LogMessage]
130+ logMessages :: [LogMessage],
131+ macros :: M.Map Text Macro
130data HTMLLocal = HTMLLocal { quoteContext :: QuoteContext
134data HTMLLocal = HTMLLocal { quoteContext :: QuoteContext
@@ -907,9 +911,25 @@ pTagContents =
908 <|> pSpace
912 <|> pSpace
909 <|> smartPunctuation pTagContents
913 <|> smartPunctuation pTagContents
910 <|> pSymbol
915 <|> pSymbol
918+pRawTeX :: PandocMonad m => InlinesParser m Inlines
920+ lookAhead $ try $ do
922+ choice $ map (try . string) ["begin", "eqref", "ref"]
923+ guardEnabled Ext_raw_tex
926+ res <- lift $ runParserT (withRaw rawLaTeXInline) st "chunk" (T.unpack inp)
929+ Right (contents, raw) -> do
930+ _ <- count (length raw) anyChar
931+ return $ B.rawInline "tex" contents
913pStr :: PandocMonad m => InlinesParser m Inlines
933pStr :: PandocMonad m => InlinesParser m Inlines
915 result <- many1 $ satisfy $ \c ->
935 result <- many1 $ satisfy $ \c ->
@@ -923,6 +943,7 @@ isSpecial '\'' = True
923isSpecial '.' = True
943isSpecial '.' = True
924isSpecial '-' = True
944isSpecial '-' = True
925isSpecial '$' = True
945isSpecial '$' = True
946+isSpecial '\\' = True
926isSpecial '\8216' = True
947isSpecial '\8216' = True
927isSpecial '\8217' = True
948isSpecial '\8217' = True
928isSpecial '\8220' = True
949isSpecial '\8220' = True
@@ -1249,6 +1270,10 @@ isSpace _ = False
1250-- Instances
1271-- Instances
1273+instance HasMacros HTMLState where
1274+ extractMacros = macros
1275+ updateMacros f st = st{ macros = f $ macros st }
1252instance HasIdentifierList HTMLState where
1277instance HasIdentifierList HTMLState where
1253 extractIdentifierList = identifiers
1278 extractIdentifierList = identifiers
1254 updateIdentifierList f s = s{ identifiers = f (identifiers s) }
1279 updateIdentifierList f s = s{ identifiers = f (identifiers s) }