git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #4008 from labdsf/fb2-bullets

FB2 writer: make bullet lists consistent with ordered lists

commiteef8118af0bb353f38e8b6ae0f2881ca4d7f71d3 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 1 Nov 2017, 00:38 (9 years ago) parent1f393f194d02a6
2 files changed+14−18
src/Text/Pandoc/Writers/FB2.hs+4−8 test/writer.fb2+10−10
src/Text/Pandoc/Writers/FB2.hs+4−8
@@ -64,7 +64,6 @@ data FbRenderState = FbRenderState
6464 { footnotes :: [ (Int, String, [Content]) ] -- ^ #, ID, text
6565 , imagesToFetch :: [ (String, String) ] -- ^ filename, URL or path
6666 , parentListMarker :: String -- ^ list marker of the parent ordered list
67− , parentBulletLevel :: Int -- ^ nesting level of the unordered list
6867 , writerOptions :: WriterOptions
6968 } deriving (Show)
7069
@@ -73,7 +72,7 @@ type FBM m = StateT FbRenderState m
7372
7473newFB :: FbRenderState
7574newFB = FbRenderState { footnotes = [], imagesToFetch = []
76− , parentListMarker = "", parentBulletLevel = 0
75+ , parentListMarker = ""
7776 , writerOptions = def }
7877
7978data ImageMode = NormalImage | InlineImage deriving (Eq)
@@ -347,15 +346,12 @@ blockToXml (OrderedList a bss) = do
347346 concat <$> zipWithM mkitem markers bss
348347blockToXml (BulletList bss) = do
349348 state <- get
350− let level = parentBulletLevel state
351349 let pmrk = parentListMarker state
352− let prefix = replicate (length pmrk) ' '
353− let bullets = ["\x2022", "\x25e6", "*", "\x2043", "\x2023"]
354− let mrk = prefix ++ bullets !! (level `mod` length bullets)
350+ let mrk = pmrk ++ "•"
355351 let mkitem bs = do
356− modify (\s -> s { parentBulletLevel = level+1 })
352+ modify (\s -> s { parentListMarker = mrk ++ " "})
357353 item <- cMapM blockToXml $ plainToPara $ indentBlocks (mrk ++ " ") bs
358− modify (\s -> s { parentBulletLevel = level }) -- restore bullet level
354+ modify (\s -> s { parentListMarker = pmrk }) -- old parent marker
359355 return item
360356 cMapM mkitem bss
361357blockToXml (DefinitionList defs) =
test/writer.fb2+10−10
@@ -261,23 +261,23 @@
261261<p>Nested</p>
262262</title>
263263<p>• Tab</p>
264−<p>◦ Tab</p>
265−<p>* Tab</p>
264+<p>• • Tab</p>
265+<p>• • • Tab</p>
266266<p>Here’s another:</p>
267267<p>1. First</p>
268268<p>2. Second:</p>
269−<p>   • Fee</p>
270−<p>   • Fie</p>
271−<p>   • Foe</p>
269+<p>2. • Fee</p>
270+<p>2. • Fie</p>
271+<p>2. • Foe</p>
272272<p>3. Third</p>
273273<p>Same thing but with paragraphs:</p>
274274<p>1. First</p>
275275<empty-line />
276276<p>2. Second:</p>
277277<empty-line />
278−<p>   • Fee</p>
279−<p>   • Fie</p>
280−<p>   • Foe</p>
278+<p>2. • Fee</p>
279+<p>2. • Fie</p>
280+<p>2. • Foe</p>
281281<p>3. Third</p>
282282<empty-line />
283283</section>
@@ -289,9 +289,9 @@
289289<empty-line />
290290<p>• this is a list item indented with spaces</p>
291291<empty-line />
292−<p>◦ this is an example list item indented with tabs</p>
292+<p>• • this is an example list item indented with tabs</p>
293293<empty-line />
294−<p>◦ this is an example list item indented with spaces</p>
294+<p>• • this is an example list item indented with spaces</p>
295295<empty-line />
296296</section>
297297<section>