diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-01-01 09:22:37 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-01-01 09:22:37 -0800 |
commit | f3ee82373b4ad8e955db12d3c2c2159a2bea53a0 (patch) | |
tree | 47e96d389717b60c5aa465aa359ecab7c0107bdf /src/Text | |
parent | d6ec6cf9cf5731977fa0f476cabef4786edd5665 (diff) | |
download | pandoc-f3ee82373b4ad8e955db12d3c2c2159a2bea53a0.tar.gz |
HTML reader: Parse name/content pairs from meta tags as metadata.
Closes #1106.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 4b44a3a21..506fe7770 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -76,9 +76,18 @@ pBody :: TagParser [Block] pBody = pInTags "body" block pHead :: TagParser [Block] -pHead = pInTags "head" $ pTitle <|> ([] <$ pAnyTag) +pHead = pInTags "head" $ pTitle <|> pMetaTag <|> ([] <$ pAnyTag) where pTitle = pInTags "title" inline >>= setTitle . normalizeSpaces setTitle t = [] <$ (updateState $ B.setMeta "title" (B.fromList t)) + pMetaTag = do + mt <- pSatisfy (~== TagOpen "meta" []) + let name = fromAttrib "name" mt + if null name + then return [] + else do + let content = fromAttrib "content" mt + updateState $ B.setMeta name (B.text content) + return [] block :: TagParser [Block] block = choice |