git.iko.soy/typeable/pandoc
on master help sign in
+ Introduced writerIgnoreNotes option in WriterOptions. This is needed

for processing header blocks for a table of contents, since notes on headers should not appear in the TOC. Set default in Main.hs. + Moved Element, headerAtLeast, and hierarchicalize from Docbook writer to Text.Pandoc.Shared. This is because HTML writer now uses these in constructing a table of contents. git-svn-id: https://pandoc.googlecode.com/svn/trunk@633 788f1e2b-df1e-0410-8736-df70ead52e1b

commitf2b16c2065ae5b87615a07ed8b3879f980c26464 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 7 Jul 2007, 19:04 (19 years ago) parentfdf31cd
3 files changed+26−20
src/Main.hs+1 src/Text/Pandoc/Shared.hs+25 src/Text/Pandoc/Writers/Docbook.hs−20
src/Main.hs+1
@@ -482,6 +482,7 @@ main = do
482482 writerTableOfContents = toc &&
483483 (not strict),
484484 writerS5 = (writerName=="s5"),
485+ writerIgnoreNotes = False,
485486 writerIncremental = incremental,
486487 writerNumberSections = numberSections,
487488 writerIncludeBefore = includeBefore,
src/Text/Pandoc/Shared.hs+25
@@ -61,6 +61,8 @@ module Text.Pandoc.Shared (
6161 -- * Pandoc block and inline list processing
6262 normalizeSpaces,
6363 compactify,
64+ Element (..),
65+ hierarchicalize,
6466 -- * Writer options
6567 WriterOptions (..),
6668 defaultWriterOptions,
@@ -368,6 +370,26 @@ containsPara ((OrderedList items):rest) = (any containsPara items) ||
368370 (containsPara rest)
369371containsPara (x:rest) = containsPara rest
370372
373+-- | Data structure for defining hierarchical Pandoc documents
374+data Element = Blk Block
375+ | Sec [Inline] [Element] deriving (Eq, Read, Show)
376+
377+-- | Returns true on Header block with level at least 'level'
378+headerAtLeast :: Int -> Block -> Bool
379+headerAtLeast level (Header x _) = x <= level
380+headerAtLeast level _ = False
381+
382+-- | Convert list of Pandoc blocks into list of Elements (hierarchical)
383+hierarchicalize :: [Block] -> [Element]
384+hierarchicalize [] = []
385+hierarchicalize (block:rest) =
386+ case block of
387+ (Header level title) -> let (thisSection, rest') = break (headerAtLeast
388+ level) rest in
389+ (Sec title (hierarchicalize thisSection)):
390+ (hierarchicalize rest')
391+ x -> (Blk x):(hierarchicalize rest)
392+
371393-- | Options for writers
372394data WriterOptions = WriterOptions
373395 { writerStandalone :: Bool -- ^ Include header and footer
@@ -377,6 +399,7 @@ data WriterOptions = WriterOptions
377399 , writerIncludeAfter :: String -- ^ String to include after the body
378400 , writerTableOfContents :: Bool -- ^ Include table of contents
379401 , writerS5 :: Bool -- ^ We're writing S5
402+ , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
380403 , writerIncremental :: Bool -- ^ Incremental S5 lists
381404 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
382405 , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
@@ -393,6 +416,7 @@ defaultWriterOptions =
393416 writerTabStop = 4,
394417 writerTableOfContents = False,
395418 writerS5 = False,
419+ writerIgnoreNotes = False,
396420 writerIncremental = False,
397421 writerNumberSections = False,
398422 writerIncludeBefore = "",
@@ -434,3 +458,4 @@ refsMatch (x:restx) (y:resty) = (x == y) && refsMatch restx resty
434458refsMatch [] x = null x
435459refsMatch x [] = null x
436460
461+
src/Text/Pandoc/Writers/Docbook.hs−20
@@ -74,26 +74,6 @@ inTagsIndented tagType = inTags True tagType []
7474-- Docbook writer
7575--
7676
77−-- | Data structure for defining hierarchical Pandoc documents
78−data Element = Blk Block
79− | Sec [Inline] [Element] deriving (Eq, Read, Show)
80−
81−-- | Returns true on Header block with level at least 'level'
82−headerAtLeast :: Int -> Block -> Bool
83−headerAtLeast level (Header x _) = x <= level
84−headerAtLeast level _ = False
85−
86−-- | Convert list of Pandoc blocks into list of Elements (hierarchical)
87−hierarchicalize :: [Block] -> [Element]
88−hierarchicalize [] = []
89−hierarchicalize (block:rest) =
90− case block of
91− (Header level title) -> let (thisSection, rest') = break (headerAtLeast
92− level) rest in
93− (Sec title (hierarchicalize thisSection)):
94− (hierarchicalize rest')
95− x -> (Blk x):(hierarchicalize rest)
96−
9777-- | Convert list of authors to a docbook <author> section
9878authorToDocbook :: [Char] -> Doc
9979authorToDocbook name = inTagsIndented "author" $