aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-08-08 11:24:26 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2014-08-08 10:25:40 -0700
commit40602c3df69c23c9bc5c42b2de423965cdc2a103 (patch)
tree1eb7b5b0e769edfa82b59881a687215593d9c908 /src/Text
parent10b662c1208ede66344e86bc07584c7efeb9ab2c (diff)
downloadpandoc-40602c3df69c23c9bc5c42b2de423965cdc2a103.tar.gz
HTML EPUB exts: switch element can now be in either the inline or block position
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 42ef11065..3d988cd80 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -126,8 +126,8 @@ block = do
tr <- getOption readerTrace
pos <- getPosition
res <- choice
- [ eSwitch
- , eSection
+ [ eSection
+ , eSwitch B.para block
, mempty <$ eFootnote
, mempty <$ eTOC
, pPara
@@ -147,26 +147,26 @@ block = do
(take 60 $ show $ B.toList res)) (return ())
return res
-namespaces :: [(String, TagParser Blocks)]
-namespaces = [(mathMLNamespace, B.para <$> pMath True)]
+namespaces :: [(String, TagParser Inlines)]
+namespaces = [(mathMLNamespace, pMath True)]
mathMLNamespace :: String
mathMLNamespace = "http://www.w3.org/1998/Math/MathML"
-eSwitch :: TagParser Blocks
-eSwitch = try $ do
+eSwitch :: Monoid a => (Inlines -> a) -> TagParser a -> TagParser a
+eSwitch constructor parser = try $ do
guardEnabled Ext_epub_html_exts
pSatisfy (~== TagOpen "switch" [])
cases <- getFirst . mconcat <$>
manyTill (First <$> (eCase <* skipMany pBlank) )
(lookAhead $ try $ pSatisfy (~== TagOpen "default" []))
skipMany pBlank
- fallback <- pInTags "default" ( skipMany pBlank *> block <* skipMany pBlank )
+ fallback <- pInTags "default" (skipMany pBlank *> parser <* skipMany pBlank)
skipMany pBlank
pSatisfy (~== TagClose "switch")
- return (fromMaybe fallback cases)
+ return $ maybe fallback constructor cases
-eCase :: TagParser (Maybe Blocks)
+eCase :: TagParser (Maybe Inlines)
eCase = do
skipMany pBlank
TagOpen _ attr <- lookAhead $ pSatisfy $ (~== TagOpen "case" [])
@@ -443,6 +443,7 @@ pCodeBlock = try $ do
inline :: TagParser Inlines
inline = choice
[ eNoteref
+ , eSwitch id inline
, pTagText
, pQ
, pEmph