git.iko.soy/typeable/pandoc
on master help sign in
DocBook reader: ensure that first and last names are separated.
07d299dJohn MacFarlane
src/Text/Pandoc/Readers/DocBook.hs+14−6
@@ -600,16 +600,24 @@ addMetadataFromElement e = do
600 Nothing -> return ()
600 Nothing -> return ()
601 Just z -> addMetaField "author" z
601 Just z -> addMetaField "author" z
602 addMetaField "subtitle" e
602 addMetaField "subtitle" e
603− addMetaField "author" e
603+ addAuthor e
604 addMetaField "date" e
604 addMetaField "date" e
605 addMetaField "release" e
605 addMetaField "release" e
606 addMetaField "releaseinfo" e
606 addMetaField "releaseinfo" e
607 return mempty
607 return mempty
608+ where
609+ addAuthor elt =
610+ case filterChildren (named "author") elt of
611+ [] -> return ()
612+ [z] -> fromAuthor z >>= addMeta "author"
613+ zs -> mapM fromAuthor zs >>= addMeta "author"
614+ fromAuthor elt =
615+ mconcat . intersperse space <$> mapM getInlines (elChildren elt)
608− where addMetaField fieldname elt =
616+ addMetaField fieldname elt =
609− case filterChildren (named fieldname) elt of
617+ case filterChildren (named fieldname) elt of
610− [] -> return ()
618+ [] -> return ()
611− [z] -> getInlines z >>= addMeta fieldname
619+ [z] -> getInlines z >>= addMeta fieldname
612− zs -> mapM getInlines zs >>= addMeta fieldname
620+ zs -> mapM getInlines zs >>= addMeta fieldname
613
621
614addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> DB m ()
622addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> DB m ()
615addMeta field val = modify (setMeta field val)
623addMeta field val = modify (setMeta field val)
test/command/6541.mdnew file+27
@@ -0,0 +1,27 @@
1+```
2+% pandoc -f docbook -t markdown -s
3+<?xml version="1.0"?>
4+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
5+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6+<book>
7+
8+<bookinfo>
9+<title>Title</title>
10+<author>
11+<firstname>Firstname</firstname><surname>Lastname</surname>
12+</author>
13+<releaseinfo>1.17</releaseinfo>
14+</bookinfo>
15+
16+<para>Text.</para>
17+
18+</book>
19+^D
20+---
21+author: Firstname Lastname
22+releaseinfo: 1.17
23+title: Title
24+---
25+
26+Text.
27+```