Skip to content

Commit

Permalink
OPML writer: respect --wrap options & --columns in contents of no…
Browse files Browse the repository at this point in the history
…tes.

Closes #9297.
  • Loading branch information
jgm committed Jan 4, 2024
1 parent 59e28b8 commit 5cff32c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
11 changes: 8 additions & 3 deletions src/Text/Pandoc/Writers/OPML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ writeOPML opts (Pandoc meta blocks) = do
else Nothing
meta' = B.setMeta "date" (B.str $ convertDate $ docDate meta) meta
metadata <- metaToContext opts
(fmap literal . writeMarkdown def . Pandoc nullMeta)
(fmap literal . writeMarkdown' opts . Pandoc nullMeta)
(\ils -> literal . T.stripEnd <$>
writeMarkdown def (Pandoc nullMeta [Plain ils]))
writeMarkdown' opts (Pandoc nullMeta [Plain ils]))
meta'
let blocks' = makeSections False (Just 1) blocks
main <- render colwidth . vcat <$>
Expand All @@ -49,6 +49,11 @@ writeOPML opts (Pandoc meta blocks) = do
Nothing -> main
Just tpl -> render colwidth $ renderTemplate tpl context

writeMarkdown' :: PandocMonad m => WriterOptions -> Pandoc -> m Text
writeMarkdown' opts = writeMarkdown def{ writerWrapText = writerWrapText opts
, writerColumns = writerColumns opts
, writerExtensions = pandocExtensions
}

writeHtmlInlines :: PandocMonad m => [Inline] -> m Text
writeHtmlInlines ils =
Expand All @@ -71,7 +76,7 @@ blockToOPML opts (Div (_,"section":_,_) (Header _ _ title : xs)) = do
htmlIls <- writeHtmlInlines title
md <- if null blocks
then return mempty
else writeMarkdown def $ Pandoc nullMeta blocks
else writeMarkdown' opts $ Pandoc nullMeta blocks
let attrs = ("text", htmlIls) :
[("_note", T.stripEnd md) | not (null blocks)]
rest' <- vcat <$> mapM (blockToOPML opts) rest
Expand Down
Loading

0 comments on commit 5cff32c

Please sign in to comment.