aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-08-16 21:06:49 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-16 21:06:49 -0700
commit0910e9218728c85feb562745ed5eb44d586e824d (patch)
tree40fa689baab3887f65c2b75d39b0b606bd46ac62
parentfe312b0a7a0e63e307162da47dc9f1ca8f47737f (diff)
downloadpandoc-0910e9218728c85feb562745ed5eb44d586e824d.tar.gz
TEI improvements.
- Ensure that title element is always present, even if empty. - Put author tags in the template, rather than adding them in the writer. Closes #4839.
-rw-r--r--data/templates/default.tei4
-rw-r--r--src/Text/Pandoc/Writers/TEI.hs15
2 files changed, 2 insertions, 17 deletions
diff --git a/data/templates/default.tei b/data/templates/default.tei
index 3778dccd5..824c9f0e7 100644
--- a/data/templates/default.tei
+++ b/data/templates/default.tei
@@ -3,11 +3,9 @@
<teiHeader>
<fileDesc>
<titleStmt>
-$if(title)$
<title>$title$</title>
-$endif$
$for(author)$
- $author$
+ <author>$author$</author>
$endfor$
</titleStmt>
<publicationStmt>
diff --git a/src/Text/Pandoc/Writers/TEI.hs b/src/Text/Pandoc/Writers/TEI.hs
index e461f5715..9169c8515 100644
--- a/src/Text/Pandoc/Writers/TEI.hs
+++ b/src/Text/Pandoc/Writers/TEI.hs
@@ -35,7 +35,6 @@ import Prelude
import Data.Char (toLower)
import Data.List (isPrefixOf, stripPrefix)
import Data.Text (Text)
-import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class (PandocMonad, report)
import Text.Pandoc.Definition
import Text.Pandoc.Highlighting (languages, languagesByExtension)
@@ -48,16 +47,6 @@ import Text.Pandoc.Templates (renderTemplate')
import Text.Pandoc.Writers.Shared
import Text.Pandoc.XML
--- | Convert list of authors to a docbook <author> section
-authorToTEI :: PandocMonad m => WriterOptions -> [Inline] -> m B.Inlines
-authorToTEI opts name' = do
- name <- render Nothing <$> inlinesToTEI opts name'
- let colwidth = if writerWrapText opts == WrapAuto
- then Just $ writerColumns opts
- else Nothing
- return $ B.rawInline "tei" $ render colwidth $
- inTagsSimple "author" (text $ escapeStringForXML name)
-
-- | Convert Pandoc document to string in Docbook format.
writeTEI :: PandocMonad m => WriterOptions -> Pandoc -> m Text
writeTEI opts (Pandoc meta blocks) = do
@@ -72,13 +61,11 @@ writeTEI opts (Pandoc meta blocks) = do
TopLevelChapter -> 0
TopLevelSection -> 1
TopLevelDefault -> 1
- auths' <- mapM (authorToTEI opts) $ docAuthors meta
- let meta' = B.setMeta "author" auths' meta
metadata <- metaToJSON opts
(fmap (render' . vcat) .
mapM (elementToTEI opts startLvl) . hierarchicalize)
(fmap render' . inlinesToTEI opts)
- meta'
+ meta
main <- (render' . vcat) <$> mapM (elementToTEI opts startLvl) elements
let context = defField "body" main
$