mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 05:43:39 +08:00
T.P.Shared: export hasLineBreaks.
[API change] Formerly defined in the DocBook writer but more generally useful.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user