aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-12-05 09:32:40 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-12-05 09:32:40 -0800
commit79a10388daedf959c23dfef108a035d436108657 (patch)
treed1759249c77ce606f0d9f14f529e8e991b5dbc63 /src/Text/Pandoc
parent4489283b03fecce31c49f37809932cebb8b72d46 (diff)
downloadpandoc-79a10388daedf959c23dfef108a035d436108657.tar.gz
HTML writer: add task-list class to ul if all elements are task list items.
This will allow styling unordered task lists in a way that omits the bullet.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index dd8b7d6f7..4d8a6b961 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -370,6 +370,13 @@ defList :: PandocMonad m
=> WriterOptions -> [Html] -> StateT WriterState m Html
defList opts items = toList H.dl opts (items ++ [nl opts])
+isTaskListItem :: [Block] -> Bool
+isTaskListItem (Plain (Str "☐":Space:_):_) = True
+isTaskListItem (Plain (Str "☒":Space:_):_) = True
+isTaskListItem (Para (Str "☐":Space:_):_) = True
+isTaskListItem (Para (Str "☒":Space:_):_) = True
+isTaskListItem _ = False
+
listItemToHtml :: PandocMonad m
=> WriterOptions -> [Block] -> StateT WriterState m Html
listItemToHtml opts bls
@@ -819,7 +826,9 @@ blockToHtml opts (Header level attr@(_,classes,_) lst) = do
_ -> H.p ! A.class_ "heading" $ contents'
blockToHtml opts (BulletList lst) = do
contents <- mapM (listItemToHtml opts) lst
- unordList opts contents
+ let isTaskList = not (null lst) && all isTaskListItem lst
+ (if isTaskList then (! A.class_ "task-list") else id) <$>
+ unordList opts contents
blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
contents <- mapM (listItemToHtml opts) lst
html5 <- gets stHtml5