aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-12-11 10:51:54 +0100
committerJohn MacFarlane <[email protected]>2025-12-11 10:51:54 +0100
commitd19cc38f116fbdc45ed6c0c97892ad6c18785990 (patch)
treef20d464310380796443a3a37330826bee4641f54 /src
parenta6fae6b78018f2d7998eb7c9432c2d00400f209b (diff)
T.P.Shared: export hasLineBreaks.
[API change] Formerly defined in the DocBook writer but more generally useful.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Shared.hs13
-rw-r--r--src/Text/Pandoc/Writers/DocBook.hs10
2 files changed, 13 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 2c748dc5f..657c95b71 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -56,6 +56,7 @@ module Text.Pandoc.Shared (
inlineListToIdentifier,
textToIdentifier,
isHeaderBlock,
+ hasLineBreaks,
onlySimpleTableCells,
isTightList,
taskListItemFromAscii,
@@ -607,6 +608,18 @@ uniqueIdent exts title' usedIdents =
x -> x
numIdent n = baseIdent <> "-" <> tshow n
+-- | True if inlines include a LineBreak (possibly embedded), with the exception
+-- of line breaks in Notes.
+hasLineBreaks :: [Inline] -> Bool
+hasLineBreaks = getAny . query isLineBreak . walk removeNote
+ where
+ removeNote :: Inline -> Inline
+ removeNote (Note _) = Str ""
+ removeNote x = x
+ isLineBreak :: Inline -> Any
+ isLineBreak LineBreak = Any True
+ isLineBreak _ = Any False
+
-- | True if block is a Header block.
isHeaderBlock :: Block -> Bool
isHeaderBlock Header{} = True
diff --git a/src/Text/Pandoc/Writers/DocBook.hs b/src/Text/Pandoc/Writers/DocBook.hs
index 775a92bef..0e0f7cde8 100644
--- a/src/Text/Pandoc/Writers/DocBook.hs
+++ b/src/Text/Pandoc/Writers/DocBook.hs
@@ -344,16 +344,6 @@ blockToDocBook opts (Figure attr capt@(Caption _ caption) body) = do
inTagsSimple "title" title $$
mconcat mediaobjects
-hasLineBreaks :: [Inline] -> Bool
-hasLineBreaks = getAny . query isLineBreak . walk removeNote
- where
- removeNote :: Inline -> Inline
- removeNote (Note _) = Str ""
- removeNote x = x
- isLineBreak :: Inline -> Any
- isLineBreak LineBreak = Any True
- isLineBreak _ = Any False
-
alignmentToString :: Alignment -> Text
alignmentToString alignment = case alignment of
AlignLeft -> "left"