git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #495 from mb21/master
2141e82John MacFarlane
src/Text/Pandoc/Readers/DocBook.hs+29−9
@@ -63,7 +63,7 @@ List of all DocBook tags, with [x] indicating implemented:
63[ ] bridgehead - A free-floating heading
63[ ] bridgehead - A free-floating heading
64[ ] callout - A “called out” description of a marked Area
64[ ] callout - A “called out” description of a marked Area
65[ ] calloutlist - A list of Callouts
65[ ] calloutlist - A list of Callouts
66−[ ] caption - A caption
66+[x] caption - A caption
67[ ] caution - A note of caution
67[ ] caution - A note of caution
68[ ] chapter - A chapter, as of a book
68[ ] chapter - A chapter, as of a book
69[ ] chapterinfo - Meta-information for a Chapter
69[ ] chapterinfo - Meta-information for a Chapter
@@ -132,7 +132,7 @@ List of all DocBook tags, with [x] indicating implemented:
132[ ] filename - The name of a file
132[ ] filename - The name of a file
133[ ] firstname - The first name of a person
133[ ] firstname - The first name of a person
134[ ] firstterm - The first occurrence of a term
134[ ] firstterm - The first occurrence of a term
135−[ ] footnote - A footnote
135+[x] footnote - A footnote
136[ ] footnoteref - A cross reference to a footnote (a footnote mark)
136[ ] footnoteref - A cross reference to a footnote (a footnote mark)
137[ ] foreignphrase - A word or phrase in a language other than the primary
137[ ] foreignphrase - A word or phrase in a language other than the primary
138 language of the document
138 language of the document
@@ -177,7 +177,7 @@ List of all DocBook tags, with [x] indicating implemented:
177[ ] indexentry - An entry in an index
177[ ] indexentry - An entry in an index
178[ ] indexinfo - Meta-information for an Index
178[ ] indexinfo - Meta-information for an Index
179[ ] indexterm - A wrapper for terms to be indexed
179[ ] indexterm - A wrapper for terms to be indexed
180−[ ] info - A wrapper for information about a component or other block. (DocBook v5)
180+[x] info - A wrapper for information about a component or other block. (DocBook v5)
181[ ] informalequation - A displayed mathematical equation without a title
181[ ] informalequation - A displayed mathematical equation without a title
182[ ] informalexample - A displayed example without a title
182[ ] informalexample - A displayed example without a title
183[ ] informalfigure - A untitled figure
183[ ] informalfigure - A untitled figure
@@ -186,7 +186,7 @@ List of all DocBook tags, with [x] indicating implemented:
186[ ] inlineequation - A mathematical equation or expression occurring inline
186[ ] inlineequation - A mathematical equation or expression occurring inline
187[ ] inlinegraphic - An object containing or pointing to graphical data
187[ ] inlinegraphic - An object containing or pointing to graphical data
188 that will be rendered inline
188 that will be rendered inline
189−[ ] inlinemediaobject - An inline media object (video, audio, image, and so on)
189+[x] inlinemediaobject - An inline media object (video, audio, image, and so on)
190[ ] interface - An element of a GUI
190[ ] interface - An element of a GUI
191[ ] interfacename - The name of an interface
191[ ] interfacename - The name of an interface
192[ ] invpartnumber - An inventory part number
192[ ] invpartnumber - An inventory part number
@@ -211,7 +211,7 @@ List of all DocBook tags, with [x] indicating implemented:
211 ancestors
211 ancestors
212[ ] lineannotation - A comment on a line in a verbatim listing
212[ ] lineannotation - A comment on a line in a verbatim listing
213[x] link - A hypertext link
213[x] link - A hypertext link
214−[ ] listitem - A wrapper for the elements of a list item
214+[x] listitem - A wrapper for the elements of a list item
215[x] literal - Inline text that is some literal value
215[x] literal - Inline text that is some literal value
216[ ] literallayout - A block of text in which line breaks and white space are
216[ ] literallayout - A block of text in which line breaks and white space are
217 to be reproduced faithfully
217 to be reproduced faithfully
@@ -225,7 +225,7 @@ List of all DocBook tags, with [x] indicating implemented:
225 with ordinary text and a small amount of markup
225 with ordinary text and a small amount of markup
226[ ] medialabel - A name that identifies the physical medium on which some
226[ ] medialabel - A name that identifies the physical medium on which some
227 information resides
227 information resides
228−[ ] mediaobject - A displayed media object (video, audio, image, etc.)
228+[x] mediaobject - A displayed media object (video, audio, image, etc.)
229[ ] mediaobjectco - A media object that contains callouts
229[ ] mediaobjectco - A media object that contains callouts
230[ ] member - An element of a simple list
230[ ] member - An element of a simple list
231[ ] menuchoice - A selection or series of selections from a menu
231[ ] menuchoice - A selection or series of selections from a menu
@@ -308,7 +308,7 @@ List of all DocBook tags, with [x] indicating implemented:
308[ ] qandaentry - A question/answer set within a QandASet
308[ ] qandaentry - A question/answer set within a QandASet
309[ ] qandaset - A question-and-answer set
309[ ] qandaset - A question-and-answer set
310[ ] question - A question in a QandASet
310[ ] question - A question in a QandASet
311−[ ] quote - An inline quotation
311+[x] quote - An inline quotation
312[ ] refclass - The scope or other indication of applicability of a
312[ ] refclass - The scope or other indication of applicability of a
313 reference entry
313 reference entry
314[ ] refdescriptor - A description of the topic of a reference page
314[ ] refdescriptor - A description of the topic of a reference page
@@ -517,6 +517,23 @@ attrValue attr elt =
517 Just z -> z
517 Just z -> z
518 Nothing -> ""
518 Nothing -> ""
519
519
520+-- function that is used by both mediaobject (in parseBlock)
521+-- and inlinemediaobject (in parseInline)
522+getImage :: Element -> DB Inlines
523+getImage e = do
524+ imageUrl <- case filterChild
525+ (\e' -> qName (elName e') == "imageobject") e of
526+ Nothing -> return mempty
527+ Just z -> case filterChild
528+ (\e' -> qName (elName e') == "imagedata") z of
529+ Nothing -> return mempty
530+ Just i -> return $ attrValue "fileref" i
531+ caption <- case filterChild
532+ (\e' -> qName (elName e') == "caption") e of
533+ Nothing -> return mempty
534+ Just z -> mconcat <$> (mapM parseInline $ elContent z)
535+ return $ image imageUrl "" caption
536+
520parseBlock :: Content -> DB Blocks
537parseBlock :: Content -> DB Blocks
521parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
538parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
522parseBlock (Text (CData _ s _)) = if all isSpace s
539parseBlock (Text (CData _ s _)) = if all isSpace s
@@ -543,6 +560,8 @@ parseBlock (Elem e) =
543 "abstract" -> blockQuote <$> getBlocks e
560 "abstract" -> blockQuote <$> getBlocks e
544 "itemizedlist" -> bulletList <$> listitems
561 "itemizedlist" -> bulletList <$> listitems
545 "orderedlist" -> orderedList <$> listitems -- TODO list attributes
562 "orderedlist" -> orderedList <$> listitems -- TODO list attributes
563+ "mediaobject" -> para <$> (getImage e)
564+ "caption" -> return mempty
546 "info" -> getTitle >> getAuthors >> getDate >> return mempty
565 "info" -> getTitle >> getAuthors >> getDate >> return mempty
547 "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty
566 "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty
548 "programlisting" -> return $ codeBlock $ strContent e -- TODO attrs
567 "programlisting" -> return $ codeBlock $ strContent e -- TODO attrs
@@ -555,7 +574,7 @@ parseBlock (Elem e) =
555 skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs
574 skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs
556 | otherwise = xs
575 | otherwise = xs
557 skipWhite xs = xs
576 skipWhite xs = xs
558− listitems = mapM getBlocks $ findChildren (unqual "listitem") e
577+ listitems = mapM getBlocks $ filterChildren (\e' -> qName (elName e') == "listitem") e
559 getTitle = case findChild (unqual "title") e of
578 getTitle = case findChild (unqual "title") e of
560 Just t -> do
579 Just t -> do
561 tit <- getInlines t
580 tit <- getInlines t
@@ -592,6 +611,7 @@ parseInline (Elem e) =
592 case qName (elName e) of
611 case qName (elName e) of
593 "subscript" -> subscript <$> innerInlines
612 "subscript" -> subscript <$> innerInlines
594 "superscript" -> superscript <$> innerInlines
613 "superscript" -> superscript <$> innerInlines
614+ "inlinemediaobject" -> getImage e
595 "quote" -> do
615 "quote" -> do
596 qt <- gets dbQuoteType
616 qt <- gets dbQuoteType
597 let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote
617 let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote
@@ -611,7 +631,7 @@ parseInline (Elem e) =
611 "userinput" -> return $ codeWith ("",["userinput"],[]) $ strContent e
631 "userinput" -> return $ codeWith ("",["userinput"],[]) $ strContent e
612 "varargs" -> return $ str "(…)"
632 "varargs" -> return $ str "(…)"
613 "ulink" -> link (attrValue "url" e) "" <$> innerInlines
633 "ulink" -> link (attrValue "url" e) "" <$> innerInlines
614− "link" -> case findAttr (QName "href" Nothing $ Just "xlink") e of
634+ "link" -> case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of
615 Just href -> link href "" <$> innerInlines
635 Just href -> link href "" <$> innerInlines
616 _ -> link ('#' : attrValue "linkend" e) ""
636 _ -> link ('#' : attrValue "linkend" e) ""
617 <$> innerInlines
637 <$> innerInlines