diff options
-rw-r--r-- | src/Main.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 25 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Docbook.hs | 20 |
3 files changed, 26 insertions, 20 deletions
diff --git a/src/Main.hs b/src/Main.hs index d25e38911..adddae0fc 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -482,6 +482,7 @@ main = do writerTableOfContents = toc && (not strict), writerS5 = (writerName=="s5"), + writerIgnoreNotes = False, writerIncremental = incremental, writerNumberSections = numberSections, writerIncludeBefore = includeBefore, diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index d0b134534..69d2dd7ee 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -61,6 +61,8 @@ module Text.Pandoc.Shared ( -- * Pandoc block and inline list processing normalizeSpaces, compactify, + Element (..), + hierarchicalize, -- * Writer options WriterOptions (..), defaultWriterOptions, @@ -368,6 +370,26 @@ containsPara ((OrderedList items):rest) = (any containsPara items) || (containsPara rest) containsPara (x:rest) = containsPara rest +-- | Data structure for defining hierarchical Pandoc documents +data Element = Blk Block + | Sec [Inline] [Element] deriving (Eq, Read, Show) + +-- | Returns true on Header block with level at least 'level' +headerAtLeast :: Int -> Block -> Bool +headerAtLeast level (Header x _) = x <= level +headerAtLeast level _ = False + +-- | Convert list of Pandoc blocks into list of Elements (hierarchical) +hierarchicalize :: [Block] -> [Element] +hierarchicalize [] = [] +hierarchicalize (block:rest) = + case block of + (Header level title) -> let (thisSection, rest') = break (headerAtLeast + level) rest in + (Sec title (hierarchicalize thisSection)): + (hierarchicalize rest') + x -> (Blk x):(hierarchicalize rest) + -- | Options for writers data WriterOptions = WriterOptions { writerStandalone :: Bool -- ^ Include header and footer @@ -377,6 +399,7 @@ data WriterOptions = WriterOptions , writerIncludeAfter :: String -- ^ String to include after the body , writerTableOfContents :: Bool -- ^ Include table of contents , writerS5 :: Bool -- ^ We're writing S5 + , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc) , writerIncremental :: Bool -- ^ Incremental S5 lists , writerNumberSections :: Bool -- ^ Number sections in LaTeX , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax @@ -393,6 +416,7 @@ defaultWriterOptions = writerTabStop = 4, writerTableOfContents = False, writerS5 = False, + writerIgnoreNotes = False, writerIncremental = False, writerNumberSections = False, writerIncludeBefore = "", @@ -434,3 +458,4 @@ refsMatch (x:restx) (y:resty) = (x == y) && refsMatch restx resty refsMatch [] x = null x refsMatch x [] = null x + diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs index 2fa1e8b40..93f091460 100644 --- a/src/Text/Pandoc/Writers/Docbook.hs +++ b/src/Text/Pandoc/Writers/Docbook.hs @@ -74,26 +74,6 @@ inTagsIndented tagType = inTags True tagType [] -- Docbook writer -- --- | Data structure for defining hierarchical Pandoc documents -data Element = Blk Block - | Sec [Inline] [Element] deriving (Eq, Read, Show) - --- | Returns true on Header block with level at least 'level' -headerAtLeast :: Int -> Block -> Bool -headerAtLeast level (Header x _) = x <= level -headerAtLeast level _ = False - --- | Convert list of Pandoc blocks into list of Elements (hierarchical) -hierarchicalize :: [Block] -> [Element] -hierarchicalize [] = [] -hierarchicalize (block:rest) = - case block of - (Header level title) -> let (thisSection, rest') = break (headerAtLeast - level) rest in - (Sec title (hierarchicalize thisSection)): - (hierarchicalize rest') - x -> (Blk x):(hierarchicalize rest) - -- | Convert list of authors to a docbook <author> section authorToDocbook :: [Char] -> Doc authorToDocbook name = inTagsIndented "author" $ |