aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2021-10-03 22:44:37 -0700
committerJohn MacFarlane <[email protected]>2021-10-03 22:44:37 -0700
commit17cb68410197966dc4b6fc9d67e64e58066c1cee (patch)
treea9327102eb0ff1be70807ab5db8c9ab47f900492
parent6531894b13e9ddcd3bf024a23841e7b383b8823e (diff)
Fix task list.
-rw-r--r--src/Text/Pandoc/Shared.hs19
-rw-r--r--test/markdown-citations.native9
2 files changed, 16 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index bb40ae2cc..3cc65cdf9 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -640,9 +640,13 @@ isTightList = all (\item -> firstIsPlain item || null item)
taskListItemFromAscii :: Extensions -> [Block] -> [Block]
taskListItemFromAscii = handleTaskListItem fromMd
where
- fromMd (Str "[ ] " : is) = Str "☐ " : is
- fromMd (Str "[x] " : is) = Str "☒ " : is
- fromMd (Str "[X] " : is) = Str "☒ " : is
+ fromMd (Str t : is)
+ | "[ ] " `T.isPrefixOf` t
+ = B.toList $ B.str "☐ " <> B.str (T.drop 3 t) <> B.fromList is
+ | "[x] " `T.isPrefixOf` t
+ = B.toList $ B.str "☒ " <> B.str (T.drop 3 t) <> B.fromList is
+ | "[X] " `T.isPrefixOf` t
+ = B.toList $ B.str "☒ " <> B.str (T.drop 3 t) <> B.fromList is
fromMd is = is
-- | Convert a list item containing text starting with @U+2610 BALLOT BOX@
@@ -650,10 +654,13 @@ taskListItemFromAscii = handleTaskListItem fromMd
taskListItemToAscii :: Extensions -> [Block] -> [Block]
taskListItemToAscii = handleTaskListItem toMd
where
- toMd (Str "☐ " : is) = rawMd "[ ] " : is
- toMd (Str "☒ " : is) = rawMd "[x] " : is
+ toMd (Str t : is)
+ | "☐ " `T.isPrefixOf` t
+ = B.toList $ rawMd "[ ] " <> B.str (T.drop 2 t) <> B.fromList is
+ | "☒ " `T.isPrefixOf` t
+ = B.toList $ rawMd "[x] " <> B.str (T.drop 2 t) <> B.fromList is
toMd is = is
- rawMd = RawInline (Format "markdown")
+ rawMd = B.rawInline "markdown"
handleTaskListItem :: ([Inline] -> [Inline]) -> Extensions -> [Block] -> [Block]
handleTaskListItem handleInlines exts bls =
diff --git a/test/markdown-citations.native b/test/markdown-citations.native
index a7f7367e4..245412f7c 100644
--- a/test/markdown-citations.native
+++ b/test/markdown-citations.native
@@ -115,8 +115,7 @@
[ Para
[ Cite
[ Citation
- { citationId =
- "\1087\1091\1085\1082\1090\&3"
+ { citationId = "\1087\1091\1085\1082\1090\&3"
, citationPrefix = []
, citationSuffix = [ Str "p.\160\&12" ]
, citationMode = AuthorInText
@@ -128,8 +127,7 @@
, Str " and a citation without locators "
, Cite
[ Citation
- { citationId =
- "\1087\1091\1085\1082\1090\&3"
+ { citationId = "\1087\1091\1085\1082\1090\&3"
, citationPrefix = []
, citationSuffix = []
, citationMode = NormalCitation
@@ -200,8 +198,7 @@
, citationHash = 0
}
, Citation
- { citationId =
- "\1087\1091\1085\1082\1090\&3"
+ { citationId = "\1087\1091\1085\1082\1090\&3"
, citationPrefix = []
, citationSuffix = []
, citationMode = NormalCitation