diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-08-14 22:11:05 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-08-25 14:24:31 -0700 |
commit | 1ee6e0e0878bcd655f31deb0caf6a4766e500cc6 (patch) | |
tree | 5f11cadde103d1cb72e9b1cbf6eeb2b61a570e9b /src/Text/Pandoc/Writers/Ipynb.hs | |
parent | 8959c44e6ae2a2f79ca55c2c173f84bf8d3abfc7 (diff) | |
download | pandoc-1ee6e0e0878bcd655f31deb0caf6a4766e500cc6.tar.gz |
Use new doctemplates, doclayout.
+ Remove Text.Pandoc.Pretty; use doclayout instead. [API change]
+ Text.Pandoc.Writers.Shared: remove metaToJSON, metaToJSON'
[API change].
+ Text.Pandoc.Writers.Shared: modify `addVariablesToContext`,
`defField`, `setField`, `getField`, `resetField` to work with
Context rather than JSON values. [API change]
+ Text.Pandoc.Writers.Shared: export new function `endsWithPlain` [API
change].
+ Use new templates and doclayout in writers.
+ Use Doc-based templates in all writers.
+ Adjust three tests for minor template rendering differences.
+ Added indentation to body in docbook4, docbook5 templates.
The main impact of this change is better reflowing of content
interpolated into templates. Previously, interpolated variables
were rendered independently and intepolated as strings, which could lead
to overly long lines. Now the templates interpolated as Doc values
which may include breaking spaces, and reflowing occurs
after template interpolation rather than before.
Diffstat (limited to 'src/Text/Pandoc/Writers/Ipynb.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Ipynb.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Ipynb.hs b/src/Text/Pandoc/Writers/Ipynb.hs index 4f088f7fc..2d2ee320e 100644 --- a/src/Text/Pandoc/Writers/Ipynb.hs +++ b/src/Text/Pandoc/Writers/Ipynb.hs @@ -33,7 +33,7 @@ import qualified Data.Text as T import Data.Aeson as Aeson import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Shared (safeRead, isURI) -import Text.Pandoc.Writers.Shared (metaToJSON') +import Text.Pandoc.Writers.Shared (metaToContext') import Text.Pandoc.Writers.Markdown (writeMarkdown) import qualified Data.Text.Encoding as TE import qualified Data.ByteString.Lazy as BL @@ -73,9 +73,10 @@ pandocToNotebook opts (Pandoc meta blocks) = do Just z -> (4, z) Nothing -> (4, 5) _ -> (4, 5) -- write as v4.5 - metadata' <- metaToJSON' blockWriter inlineWriter $ - B.deleteMeta "nbformat" $ - B.deleteMeta "nbformat_minor" $ jupyterMeta + metadata' <- toJSON <$> metaToContext' blockWriter inlineWriter + (B.deleteMeta "nbformat" $ + B.deleteMeta "nbformat_minor" $ + jupyterMeta) -- convert from a Value (JSON object) to a M.Map Text Value: let metadata = case fromJSON metadata' of Error _ -> mempty -- TODO warning here? shouldn't happen @@ -109,7 +110,7 @@ extractCells opts (Div (_id,classes,kvs) xs : bs) source <- writeMarkdown opts{ writerTemplate = Nothing } newdoc (Cell{ cellType = Markdown - , cellSource = Source $ breakLines source + , cellSource = Source $ breakLines $ T.stripEnd source , cellMetadata = meta , cellAttachments = if M.null attachments then Nothing |