TEI writer: remove heuristic to detect book template
TEI doesn't have `<book>` elements but only generic `<divN>` division elements. Checking the template for a trailing `</book>` is nonsensical.
This commit is contained in:
parent
23fb52ef7d
commit
aca695ab0b
1 changed files with 5 additions and 9 deletions
|
@ -35,7 +35,7 @@ import Text.Pandoc.Shared
|
||||||
import Text.Pandoc.Writers.Shared
|
import Text.Pandoc.Writers.Shared
|
||||||
import Text.Pandoc.Options
|
import Text.Pandoc.Options
|
||||||
import Text.Pandoc.Templates (renderTemplate')
|
import Text.Pandoc.Templates (renderTemplate')
|
||||||
import Data.List ( stripPrefix, isPrefixOf, isSuffixOf )
|
import Data.List ( stripPrefix, isPrefixOf )
|
||||||
import Data.Char ( toLower )
|
import Data.Char ( toLower )
|
||||||
import Text.Pandoc.Highlighting ( languages, languagesByExtension )
|
import Text.Pandoc.Highlighting ( languages, languagesByExtension )
|
||||||
import Text.Pandoc.Pretty
|
import Text.Pandoc.Pretty
|
||||||
|
@ -60,19 +60,15 @@ writeTEI opts (Pandoc meta blocks) =
|
||||||
then Just $ writerColumns opts
|
then Just $ writerColumns opts
|
||||||
else Nothing
|
else Nothing
|
||||||
render' = render colwidth
|
render' = render colwidth
|
||||||
opts' = if "/book>" `isSuffixOf`
|
startLvl = if writerChapters opts then 0 else 1
|
||||||
(trimr $ writerTemplate opts)
|
|
||||||
then opts{ writerChapters = True }
|
|
||||||
else opts
|
|
||||||
startLvl = if writerChapters opts' then 0 else 1
|
|
||||||
auths' = map (authorToTEI opts) $ docAuthors meta
|
auths' = map (authorToTEI opts) $ docAuthors meta
|
||||||
meta' = B.setMeta "author" auths' meta
|
meta' = B.setMeta "author" auths' meta
|
||||||
Just metadata = metaToJSON opts
|
Just metadata = metaToJSON opts
|
||||||
(Just . render colwidth . (vcat .
|
(Just . render colwidth . (vcat .
|
||||||
(map (elementToTEI opts' startLvl)) . hierarchicalize))
|
(map (elementToTEI opts startLvl)) . hierarchicalize))
|
||||||
(Just . render colwidth . inlinesToTEI opts')
|
(Just . render colwidth . inlinesToTEI opts)
|
||||||
meta'
|
meta'
|
||||||
main = render' $ vcat (map (elementToTEI opts' startLvl) elements)
|
main = render' $ vcat (map (elementToTEI opts startLvl) elements)
|
||||||
context = defField "body" main
|
context = defField "body" main
|
||||||
$ defField "mathml" (case writerHTMLMathMethod opts of
|
$ defField "mathml" (case writerHTMLMathMethod opts of
|
||||||
MathML _ -> True
|
MathML _ -> True
|
||||||
|
|
Loading…
Reference in a new issue