summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/DocBook.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-05-08 23:25:34 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-05-08 23:25:34 -0700
commit4f8c536de0dec4bf72485b43d6d0edd68fefb0bb (patch)
tree517b1850b10071e960dce248f2eedf0870cb1bcc /src/Text/Pandoc/Readers/DocBook.hs
parent8ba8a720ed582cbed04f15b5ad645db62c348bc5 (diff)
DocBook reader: More improvements, more tests pass.
Diffstat (limited to 'src/Text/Pandoc/Readers/DocBook.hs')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index 665d89a6a..ba2b79049 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -1,5 +1,5 @@
module Text.Pandoc.Readers.DocBook ( readDocBook ) where
-import Data.Char (toUpper)
+import Data.Char (toUpper, isDigit)
import Text.Pandoc.Parsing (ParserState(..))
import Text.Pandoc.Definition
import Text.Pandoc.Builder
@@ -10,7 +10,7 @@ import Data.Monoid
import Data.Char (isSpace)
import Control.Monad.State
import Control.Applicative ((<$>))
-import Data.List (intersperse, transpose)
+import Data.List (intersperse)
{-
@@ -619,7 +619,20 @@ parseBlock (Elem e) =
"answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
"abstract" -> blockQuote <$> getBlocks e
"itemizedlist" -> bulletList <$> listitems
- "orderedlist" -> orderedList <$> listitems -- TODO list attributes
+ "orderedlist" -> do
+ let listStyle = case attrValue "numeration" e of
+ "arabic" -> Decimal
+ "loweralpha" -> LowerAlpha
+ "upperalpha" -> UpperAlpha
+ "lowerroman" -> LowerRoman
+ "upperroman" -> UpperRoman
+ _ -> Decimal
+ let start = case attrValue "override" <$>
+ filterElement (named "listitem") e of
+ Just x@(_:_) | all isDigit x -> read x
+ _ -> 1
+ orderedListWith (start,listStyle,DefaultDelim)
+ <$> listitems -- TODO list attributes
"variablelist" -> definitionList <$> deflistitems
"mediaobject" -> para <$> (getImage e)
"caption" -> return mempty
@@ -653,8 +666,8 @@ parseBlock (Elem e) =
parseVarListEntry e' = do
let terms = filterChildren (named "term") e'
let items = filterChildren (named "listitem") e'
- terms' <- mapM ((trimInlines . mconcat <$>) . mapM parseInline . elContent) terms
- items' <- mapM ((mconcat <$>) . mapM parseBlock . elContent) items
+ terms' <- mapM getInlines terms
+ items' <- mapM getBlocks items
return (mconcat $ intersperse (str "; ") terms', items')
getTitle = case filterChild (named "title") e of
Just t -> do
@@ -768,6 +781,7 @@ parseInline (Elem e) =
"foreignphrase" -> emph <$> innerInlines
"emphasis" -> case attrValue "role" e of
"strong" -> strong <$> innerInlines
+ "strikethrough" -> strikeout <$> innerInlines
_ -> emph <$> innerInlines
"footnote" -> (note . mconcat) <$> (mapM parseBlock $ elContent e)
_ -> innerInlines