Add <titleabbr>
support to DocBook reader
This commit is contained in:
parent
19eb5c6d6a
commit
40aa74badc
4 changed files with 24 additions and 6 deletions
|
@ -19,7 +19,7 @@ import Data.Foldable (asum)
|
||||||
import Data.Generics
|
import Data.Generics
|
||||||
import Data.List (intersperse,elemIndex)
|
import Data.List (intersperse,elemIndex)
|
||||||
import Data.List.NonEmpty (nonEmpty)
|
import Data.List.NonEmpty (nonEmpty)
|
||||||
import Data.Maybe (catMaybes,fromMaybe,mapMaybe)
|
import Data.Maybe (catMaybes,fromMaybe,mapMaybe,maybeToList)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
|
@ -829,7 +829,7 @@ parseBlock (Elem e) =
|
||||||
"section" -> gets dbSectionLevel >>= sect . (+1)
|
"section" -> gets dbSectionLevel >>= sect . (+1)
|
||||||
"simplesect" ->
|
"simplesect" ->
|
||||||
gets dbSectionLevel >>=
|
gets dbSectionLevel >>=
|
||||||
sectWith (attrValue "id" e,["unnumbered"],[]) . (+1)
|
sectWith(attrValue "id" e) ["unnumbered"] [] . (+1)
|
||||||
"refsect1" -> sect 1
|
"refsect1" -> sect 1
|
||||||
"refsect2" -> sect 2
|
"refsect2" -> sect 2
|
||||||
"refsect3" -> sect 3
|
"refsect3" -> sect 3
|
||||||
|
@ -994,8 +994,8 @@ parseBlock (Elem e) =
|
||||||
(TableHead nullAttr $ toHeaderRow headrows)
|
(TableHead nullAttr $ toHeaderRow headrows)
|
||||||
[TableBody nullAttr 0 [] $ map toRow bodyrows]
|
[TableBody nullAttr 0 [] $ map toRow bodyrows]
|
||||||
(TableFoot nullAttr [])
|
(TableFoot nullAttr [])
|
||||||
sect n = sectWith (attrValue "id" e,[],[]) n
|
sect n = sectWith(attrValue "id" e) [] [] n
|
||||||
sectWith attr n = do
|
sectWith elId classes attrs n = do
|
||||||
isbook <- gets dbBook
|
isbook <- gets dbBook
|
||||||
let n' = if isbook || n == 0 then n + 1 else n
|
let n' = if isbook || n == 0 then n + 1 else n
|
||||||
headerText <- case filterChild (named "title") e `mplus`
|
headerText <- case filterChild (named "title") e `mplus`
|
||||||
|
@ -1006,7 +1006,14 @@ parseBlock (Elem e) =
|
||||||
modify $ \st -> st{ dbSectionLevel = n }
|
modify $ \st -> st{ dbSectionLevel = n }
|
||||||
b <- getBlocks e
|
b <- getBlocks e
|
||||||
modify $ \st -> st{ dbSectionLevel = n - 1 }
|
modify $ \st -> st{ dbSectionLevel = n - 1 }
|
||||||
return $ headerWith attr n' headerText <> b
|
return $ headerWith (elId, classes, maybeToList titleabbrevElAsAttr++attrs) n' headerText <> b
|
||||||
|
titleabbrevElAsAttr = do
|
||||||
|
txt <- case filterChild (named "titleabbrev") e `mplus`
|
||||||
|
(filterChild (named "info") e >>=
|
||||||
|
filterChild (named "titleabbrev")) of
|
||||||
|
Just t -> Just ("titleabbrev", strContentRecursive t)
|
||||||
|
Nothing -> Nothing
|
||||||
|
return txt
|
||||||
lineItems = mapM getInlines $ filterChildren (named "line") e
|
lineItems = mapM getInlines $ filterChildren (named "line") e
|
||||||
-- | Admonitions are parsed into a div. Following other Docbook tools that output HTML,
|
-- | Admonitions are parsed into a div. Following other Docbook tools that output HTML,
|
||||||
-- we parse the optional title as a div with the @title@ class, and give the
|
-- we parse the optional title as a div with the @title@ class, and give the
|
||||||
|
|
|
@ -1615,4 +1615,8 @@ or here: <http://example.com/>
|
||||||
<indexterm><primary>food</primary><secondary>big <foreignphrase>baguette</foreignphrase> <strong>supreme</strong></secondary></indexterm>Nested content in index term elements is flattened.
|
<indexterm><primary>food</primary><secondary>big <foreignphrase>baguette</foreignphrase> <strong>supreme</strong></secondary></indexterm>Nested content in index term elements is flattened.
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
<sect1 id="titleabbrev">
|
||||||
|
<title>Abbreviated title</title>
|
||||||
|
<titleabbrev>Abbr. title</titleabbrev>
|
||||||
|
</sect1>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -3117,4 +3117,11 @@ Pandoc
|
||||||
, Space
|
, Space
|
||||||
, Str "flattened."
|
, Str "flattened."
|
||||||
]
|
]
|
||||||
|
, Header
|
||||||
|
1
|
||||||
|
( "titleabbrev"
|
||||||
|
, []
|
||||||
|
, [ ( "titleabbrev" , "Abbr. title" ) ]
|
||||||
|
)
|
||||||
|
[ Str "Abbreviated" , Space , Str "title" ]
|
||||||
]
|
]
|
||||||
|
|
|
@ -156,7 +156,7 @@ Pandoc
|
||||||
[ Str "Some" , Space , Str "content" , Space , Str "here" ]
|
[ Str "Some" , Space , Str "content" , Space , Str "here" ]
|
||||||
, Header
|
, Header
|
||||||
1
|
1
|
||||||
( "ch04" , [] , [] )
|
( "ch04" , [] , [ ( "titleabbrev" , "Chapter 4" ) ] )
|
||||||
[ Str "The" , Space , Str "Fourth" , Space , Str "Chapter" ]
|
[ Str "The" , Space , Str "Fourth" , Space , Str "Chapter" ]
|
||||||
, Para
|
, Para
|
||||||
[ Str "Some" , Space , Str "content" , Space , Str "here" ]
|
[ Str "Some" , Space , Str "content" , Space , Str "here" ]
|
||||||
|
|
Loading…
Reference in a new issue