From f63fb16921e61e462143646582bc0239161b9204 Mon Sep 17 00:00:00 2001 From: mb21 Date: Sun, 22 Apr 2012 12:55:40 +0200 Subject: Added support for mediaobject, inlinemediaobject and caption --- src/Text/Pandoc/Readers/DocBook.hs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index c69cdee10..9d3e8302f 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -63,7 +63,7 @@ List of all DocBook tags, with [x] indicating implemented: [ ] bridgehead - A free-floating heading [ ] callout - A “called out” description of a marked Area [ ] calloutlist - A list of Callouts -[ ] caption - A caption +[x] caption - A caption [ ] caution - A note of caution [ ] chapter - A chapter, as of a book [ ] chapterinfo - Meta-information for a Chapter @@ -132,7 +132,7 @@ List of all DocBook tags, with [x] indicating implemented: [ ] filename - The name of a file [ ] firstname - The first name of a person [ ] firstterm - The first occurrence of a term -[ ] footnote - A footnote +[x] footnote - A footnote [ ] footnoteref - A cross reference to a footnote (a footnote mark) [ ] foreignphrase - A word or phrase in a language other than the primary language of the document @@ -177,7 +177,7 @@ List of all DocBook tags, with [x] indicating implemented: [ ] indexentry - An entry in an index [ ] indexinfo - Meta-information for an Index [ ] indexterm - A wrapper for terms to be indexed -[ ] info - A wrapper for information about a component or other block. (DocBook v5) +[x] info - A wrapper for information about a component or other block. (DocBook v5) [ ] informalequation - A displayed mathematical equation without a title [ ] informalexample - A displayed example without a title [ ] informalfigure - A untitled figure @@ -186,7 +186,7 @@ List of all DocBook tags, with [x] indicating implemented: [ ] inlineequation - A mathematical equation or expression occurring inline [ ] inlinegraphic - An object containing or pointing to graphical data that will be rendered inline -[ ] inlinemediaobject - An inline media object (video, audio, image, and so on) +[x] inlinemediaobject - An inline media object (video, audio, image, and so on) [ ] interface - An element of a GUI [ ] interfacename - The name of an interface [ ] invpartnumber - An inventory part number @@ -225,7 +225,7 @@ List of all DocBook tags, with [x] indicating implemented: with ordinary text and a small amount of markup [ ] medialabel - A name that identifies the physical medium on which some information resides -[ ] mediaobject - A displayed media object (video, audio, image, etc.) +[x] mediaobject - A displayed media object (video, audio, image, etc.) [ ] mediaobjectco - A media object that contains callouts [ ] member - An element of a simple list [ ] menuchoice - A selection or series of selections from a menu @@ -308,7 +308,7 @@ List of all DocBook tags, with [x] indicating implemented: [ ] qandaentry - A question/answer set within a QandASet [ ] qandaset - A question-and-answer set [ ] question - A question in a QandASet -[ ] quote - An inline quotation +[x] quote - An inline quotation [ ] refclass - The scope or other indication of applicability of a reference entry [ ] refdescriptor - A description of the topic of a reference page @@ -517,6 +517,23 @@ attrValue attr elt = Just z -> z Nothing -> "" +-- function that is used by both mediaobject (in parseBlock) +-- and inlinemediaobject (in parseInline) +getImage :: Element -> DB Inlines +getImage e = do + imageUrl <- case filterChild + (\e' -> qName (elName e') == "imageobject") e of + Nothing -> return mempty + Just z -> case filterChild + (\e' -> qName (elName e') == "imagedata") z of + Nothing -> return mempty + Just i -> return $ attrValue "fileref" i + caption <- case filterChild + (\e' -> qName (elName e') == "caption") e of + Nothing -> return mempty + Just z -> mconcat <$> (mapM parseInline $ elContent z) + return $ image imageUrl "" caption + parseBlock :: Content -> DB Blocks parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE parseBlock (Text (CData _ s _)) = if all isSpace s @@ -543,6 +560,8 @@ parseBlock (Elem e) = "abstract" -> blockQuote <$> getBlocks e "itemizedlist" -> bulletList <$> listitems "orderedlist" -> orderedList <$> listitems -- TODO list attributes + "mediaobject" -> para <$> (getImage e) + "caption" -> return mempty "info" -> getTitle >> getAuthors >> getDate >> return mempty "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty "programlisting" -> return $ codeBlock $ strContent e -- TODO attrs @@ -592,6 +611,7 @@ parseInline (Elem e) = case qName (elName e) of "subscript" -> subscript <$> innerInlines "superscript" -> superscript <$> innerInlines + "inlinemediaobject" -> getImage e "quote" -> do qt <- gets dbQuoteType let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote -- cgit v1.2.3 From 8d2baf35f164afe74809ed6d8d03150e7f4ce494 Mon Sep 17 00:00:00 2001 From: mb21 Date: Sun, 22 Apr 2012 16:53:27 +0200 Subject: fixed listitem --- src/Text/Pandoc/Readers/DocBook.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 9d3e8302f..d0b55fcd8 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -574,7 +574,7 @@ parseBlock (Elem e) = skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs | otherwise = xs skipWhite xs = xs - listitems = mapM getBlocks $ findChildren (unqual "listitem") e + listitems = mapM getBlocks $ filterChildren (\e' -> qName (elName e') == "listitem") e getTitle = case findChild (unqual "title") e of Just t -> do tit <- getInlines t -- cgit v1.2.3 From 0005a43f14068215e2ac582828c89d6f53d3644b Mon Sep 17 00:00:00 2001 From: mb21 Date: Sun, 22 Apr 2012 17:23:49 +0200 Subject: fixed xlink namespace --- src/Text/Pandoc/Readers/DocBook.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index d0b55fcd8..3735e6dba 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -211,7 +211,7 @@ List of all DocBook tags, with [x] indicating implemented: ancestors [ ] lineannotation - A comment on a line in a verbatim listing [x] link - A hypertext link -[ ] listitem - A wrapper for the elements of a list item +[x] listitem - A wrapper for the elements of a list item [x] literal - Inline text that is some literal value [ ] literallayout - A block of text in which line breaks and white space are to be reproduced faithfully @@ -631,7 +631,7 @@ parseInline (Elem e) = "userinput" -> return $ codeWith ("",["userinput"],[]) $ strContent e "varargs" -> return $ str "(…)" "ulink" -> link (attrValue "url" e) "" <$> innerInlines - "link" -> case findAttr (QName "href" Nothing $ Just "xlink") e of + "link" -> case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of Just href -> link href "" <$> innerInlines _ -> link ('#' : attrValue "linkend" e) "" <$> innerInlines -- cgit v1.2.3