mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 17:20:47 +08:00
DocBook reader: ensure that first and last names are separated.
Closes #6541.
This commit is contained in:
@@ -600,16 +600,24 @@ addMetadataFromElement e = do
|
||||
Nothing -> return ()
|
||||
Just z -> addMetaField "author" z
|
||||
addMetaField "subtitle" e
|
||||
addMetaField "author" e
|
||||
addAuthor e
|
||||
addMetaField "date" e
|
||||
addMetaField "release" e
|
||||
addMetaField "releaseinfo" e
|
||||
return mempty
|
||||
where addMetaField fieldname elt =
|
||||
case filterChildren (named fieldname) elt of
|
||||
[] -> return ()
|
||||
[z] -> getInlines z >>= addMeta fieldname
|
||||
zs -> mapM getInlines zs >>= addMeta fieldname
|
||||
where
|
||||
addAuthor elt =
|
||||
case filterChildren (named "author") elt of
|
||||
[] -> return ()
|
||||
[z] -> fromAuthor z >>= addMeta "author"
|
||||
zs -> mapM fromAuthor zs >>= addMeta "author"
|
||||
fromAuthor elt =
|
||||
mconcat . intersperse space <$> mapM getInlines (elChildren elt)
|
||||
addMetaField fieldname elt =
|
||||
case filterChildren (named fieldname) elt of
|
||||
[] -> return ()
|
||||
[z] -> getInlines z >>= addMeta fieldname
|
||||
zs -> mapM getInlines zs >>= addMeta fieldname
|
||||
|
||||
addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> DB m ()
|
||||
addMeta field val = modify (setMeta field val)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
```
|
||||
% pandoc -f docbook -t markdown -s
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
||||
<book>
|
||||
|
||||
<bookinfo>
|
||||
<title>Title</title>
|
||||
<author>
|
||||
<firstname>Firstname</firstname><surname>Lastname</surname>
|
||||
</author>
|
||||
<releaseinfo>1.17</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<para>Text.</para>
|
||||
|
||||
</book>
|
||||
^D
|
||||
---
|
||||
author: Firstname Lastname
|
||||
releaseinfo: 1.17
|
||||
title: Title
|
||||
---
|
||||
|
||||
Text.
|
||||
```
|
||||
Reference in New Issue
Block a user