Merge pull request #4008 from labdsf/fb2-bullets

FB2 writer: make bullet lists consistent with ordered lists
This commit is contained in:
John MacFarlane
2017-11-01 00:38:02 -04:00
committed by GitHub
2 changed files with 14 additions and 18 deletions
+4 -8
View File
@@ -64,7 +64,6 @@ data FbRenderState = FbRenderState
{ footnotes :: [ (Int, String, [Content]) ] -- ^ #, ID, text
, imagesToFetch :: [ (String, String) ] -- ^ filename, URL or path
, parentListMarker :: String -- ^ list marker of the parent ordered list
, parentBulletLevel :: Int -- ^ nesting level of the unordered list
, writerOptions :: WriterOptions
} deriving (Show)
@@ -73,7 +72,7 @@ type FBM m = StateT FbRenderState m
newFB :: FbRenderState
newFB = FbRenderState { footnotes = [], imagesToFetch = []
, parentListMarker = "", parentBulletLevel = 0
, parentListMarker = ""
, writerOptions = def }
data ImageMode = NormalImage | InlineImage deriving (Eq)
@@ -347,15 +346,12 @@ blockToXml (OrderedList a bss) = do
concat <$> zipWithM mkitem markers bss
blockToXml (BulletList bss) = do
state <- get
let level = parentBulletLevel state
let pmrk = parentListMarker state
let prefix = replicate (length pmrk) ' '
let bullets = ["\x2022", "\x25e6", "*", "\x2043", "\x2023"]
let mrk = prefix ++ bullets !! (level `mod` length bullets)
let mrk = pmrk ++ ""
let mkitem bs = do
modify (\s -> s { parentBulletLevel = level+1 })
modify (\s -> s { parentListMarker = mrk ++ " "})
item <- cMapM blockToXml $ plainToPara $ indentBlocks (mrk ++ " ") bs
modify (\s -> s { parentBulletLevel = level }) -- restore bullet level
modify (\s -> s { parentListMarker = pmrk }) -- old parent marker
return item
cMapM mkitem bss
blockToXml (DefinitionList defs) =
+10 -10
View File
@@ -261,23 +261,23 @@
<p>Nested</p>
</title>
<p>• Tab</p>
<p> Tab</p>
<p>* Tab</p>
<p>• • Tab</p>
<p>• • • Tab</p>
<p>Heres another:</p>
<p>1. First</p>
<p>2. Second:</p>
<p>   • Fee</p>
<p>   • Fie</p>
<p>   • Foe</p>
<p>2. • Fee</p>
<p>2. • Fie</p>
<p>2. • Foe</p>
<p>3. Third</p>
<p>Same thing but with paragraphs:</p>
<p>1. First</p>
<empty-line />
<p>2. Second:</p>
<empty-line />
<p>   • Fee</p>
<p>   • Fie</p>
<p>   • Foe</p>
<p>2. • Fee</p>
<p>2. • Fie</p>
<p>2. • Foe</p>
<p>3. Third</p>
<empty-line />
</section>
@@ -289,9 +289,9 @@
<empty-line />
<p>• this is a list item indented with spaces</p>
<empty-line />
<p> this is an example list item indented with tabs</p>
<p>• • this is an example list item indented with tabs</p>
<empty-line />
<p> this is an example list item indented with spaces</p>
<p>• • this is an example list item indented with spaces</p>
<empty-line />
</section>
<section>