aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Shared.hs
AgeCommit message (Collapse)AuthorFilesLines
2019-12-07Fix --toc-depth regression in 2.8.John MacFarlane1-3/+3
Closes #5967.
2019-11-15RST writer: Improve spacing for tables with no width information.John MacFarlane1-5/+19
If a simple table would be too wide, we use a grid table. The code for generating grid tables has been adjusted to give more intelligent column widths when widths aren't given. (This also affects the markdown writer.) Closes #5899.
2019-11-14Writers.Shared: Clean up code for adding metadata to variables.John MacFarlane1-10/+9
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-52/+45
PR #5884. + Use pandoc-types 1.20 and texmath 0.12. + Text is now used instead of String, with a few exceptions. + In the MediaBag module, some of the types using Strings were switched to use FilePath instead (not Text). + In the Parsing module, new parsers `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`, `many1Till`, `manyUntil`, `mantyUntilChar` have been added: these are like their unsuffixed counterparts but pack some or all of their output. + `glob` in Text.Pandoc.Class still takes String since it seems to be intended as an interface to Glob, which uses strings. It seems to be used only once in the package, in the EPUB writer, so that is not hard to change.
2019-10-29T.P.W.Shared: Changed gridTables so it does better at...John MacFarlane1-16/+20
...keeping the widths of columns. See #4320. Adjust test case for #4320.
2019-10-29Changes to build with new doctemplates/doclayout.John MacFarlane1-9/+11
The new version of doctemplates adds many features to pandoc's templating system, while remaining backwards-compatible. New features include partials and filters. Using template filters, one can lay out data in enumerated lists and tables. Templates are now layout-sensitive: so, for example, if a text with soft line breaks is interpolated near the end of a line, the text will break and wrap naturally. This makes the templating system much more suitable for programatically generating markdown or other plain-text files from metadata.
2019-10-10Make some writers sensitive to 'unlisted' class on headings.John MacFarlane1-3/+4
If this is present on a heading with the 'unnumbered' class, the heading won't appear in the TOC. This class has no effect if 'unnumbered' is not also specified. This affects HTML-based writers (including slide shows and epub), LateX (including beamer), RTF, and PowerPoint. Other writers do not yet support `unlisted`. Closes #1762.
2019-10-09Options.WriterOptions: Change type of writerVariables to Context Text.John MacFarlane1-5/+9
This will allow structured values. [API change]
2019-09-08Replace Element and makeHierarchical with makeSections.John MacFarlane1-9/+18
Text.Pandoc.Shared: + Remove `Element` type [API change] + Remove `makeHierarchicalize` [API change] + Add `makeSections` [API change] + Export `deLink` [API change] Now that we have Divs, we can use them to represent the structure of sections, and we don't need a special Element type. `makeSections` reorganizes a block list, adding Divs with class `section` around sections, and adding numbering if needed. This change also fixes some longstanding issues recognizing section structure when the document contains Divs. Closes #3057, see also #997. All writers have been changed to use `makeSections`. Note that in the process we have reverted the change c1d058aeb1c6a331a2cc22786ffaab17f7118ccd made in response to #5168, which I'm not completely sure was a good idea. Lua modules have also been adjusted accordingly. Existing lua filters that use `hierarchicalize` will need to be rewritten to use `make_sections`.
2019-08-25Use new doctemplates, doclayout.John MacFarlane1-117/+92
+ 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.
2019-07-02Fix redundant constraint warnings. (#5625)Pete Ryland1-3/+3
2019-05-04Improve c4a81fb941adf6c3bf524916c46623685d276f32.John MacFarlane1-1/+1
We do want to recognize "0" as a number, even though it has "0" as a prefix.
2019-05-03metaToJSON: treat digits starting with 0 as a string...John MacFarlane1-0/+3
not a number. Closes #5479.
2019-03-28Shared - improve metaToJSON with numbers.John MacFarlane1-5/+8
We now do a better job marshalling numbers from MetaString OR MetaInlines into JSON Number.
2019-03-28Use strict instead of lazy sum.John MacFarlane1-2/+2
sum is lazy; replace with `foldl' (+) 0` to avoid stack overflow in Text.Pandoc.Pretty with very long strings. Closes #5401.
2019-03-27Writers.Shared.metaValueToJSON: use Number Values for integers.John MacFarlane1-4/+9
Pandoc's MetaValue doesn't have a distinguished number type, so numbers are put in MetaStrings. If the MetaString consists entirely of digits, we convert it to a Number. We should probably consider adding a MetaNumber constructor to MetaValue, for better round-tripping with JSON etc. This change aids round-tripping in ipynb metadata fields, like `toc_depth`.
2019-03-01Remove license boilerplate.John MacFarlane1-18/+0
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel1-2/+2
Quite a few modules were missing copyright notices. This commit adds copyright notices everywhere via haddock module headers. The old license boilerplate comment is redundant with this and has been removed. Update copyright years to 2019. Closes #4592.
2019-01-04T.P.Writers.Shared - add toTableOfContents (API change).John MacFarlane1-1/+23
This is refactored out from the Markdown writer. IT can be used in other writers to create a generic TOC.
2018-10-17Move common groff functions to Text.Pandoc.Writers.GroffJohn MacFarlane1-10/+1
(unexported module). These are used in both the man and ms writers. Moved groffEscape out of Text.Pandoc.Writers.Shared [cancels earlier API change from adding it, which was after last release]. This fixes strong/code combination on man (should be `\f[CB]` not `\f[BC]`), mentioned in #4973. Updated tests. Closes #4975.
2018-10-07Revert export of hasSimpleCells from T.P.Writers.Shared.John MacFarlane1-18/+0
This wasn't necessary.
2018-10-06RST writer: use simple tables when possible.John MacFarlane1-0/+18
Closes #4750. Text.Pandoc.Writers.Shared now exports hasSimpleCells [API change].
2018-10-05CommonMark writer: add plain text fallbacks. (#4531)quasicomputational1-1/+30
Previously, the writer would unconditionally emit HTMLish output for subscripts, superscripts, strikeouts (if the strikeout extension is disabled) and small caps, even with raw_html disabled. Now there are plain-text (and, where possible, fancy Unicode) fallbacks for all of these corresponding (mostly) to the Markdown fallbacks, and the HTMLish output is only used when raw_html is enabled. This commit adds exported functions `toSuperscript` and `toSubscript` to `Text.Pandoc.Writers.Shared`. [API change] Closes #4528.
2018-10-04Add lookupMeta* functions to Text.Pandoc.Writers.Shared (#4907)Mauro Bieg1-15/+47
Remove exported functions `metaValueToInlines`, `metaValueToString`. Add new exported functions `lookupMetaBool`, `lookupMetaBlocks`, `lookupMetaInlines`, `lookupMetaString`. Use these whenever possible for uniformity in writers. API change (major, because of removed function `metaValueToInlines`. `metaValueToString` wasn't in any released version.)
2018-10-03Text.Pandoc.Writers.Shared: added `metaValueToString`.John MacFarlane1-0/+9
[API change]
2018-10-02Removed Text.Pandoc.Groff.John MacFarlane1-0/+11
Moved groffEscape function to Text.Pandoc.Writers.Shared. [API change, since T.P.W.S is exported.]
2018-08-17Docx writer: properly handle display math in spans.John MacFarlane1-2/+4
Closes #4826. This isn't a complete solution, since other nestings of display math may still cause problems, but it should work for what is by far the most common case. Note that this also involves an API change: `isDisplayMath` is now exported from Text.Pandoc.Writers.Shared.
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane1-0/+2
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-03-17hlint fixes.John MacFarlane1-1/+1
2018-03-17Don't wrap lines in grid tables when `--wrap=none` (#4320)Francesco Occhipinti1-12/+30
* Annotate gridTable code with comments and abstract small functions * Don't wrap lines in tables when `--wrap=none`. Instead, expand cells, even if it results in cells that don't respect relative widths or surpass page column width. * This change affects RST, Markdown, and Haddock writers.
2018-03-17RST writer: strip whitespace within inlines, closes #4327 (#4329)Francesco Occhipinti1-0/+1
+ Whitespace is ignored at the beginning and end of emphasis, as per <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup>. + Export `stripLeadingTrailingSpace` from `Text.Pandoc.Writers.Shared`.
2018-01-12Move `metaValueToInlines` to T.P.W.SharedJesse Rosenthal1-0/+9
This will allow the Powerpoint writer to use it as well.
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2017-12-02Docx writer: allow empty paragraphs.John MacFarlane1-2/+8
See #2252. This also changes fixDisplayMath from Text.Pandoc.Writers.Shared so that it no longer produces empty Para as an artifact. (That was the original reason the writer omitted them.)
2017-10-29hlint suggestions.John MacFarlane1-5/+5
2017-08-13Added some Functor constraints needed for ghc 7.8.John MacFarlane1-2/+2
2017-08-12Escape MetaString values (as added with --metadata flag).John MacFarlane1-6/+8
Previously they would be transmitted to the template without any escaping. Note that `--M title='*foo*'` yields a different result from --- title: *foo* --- In the latter case, we have emphasis; in the former case, just a string with literal asterisks (which will be escaped in formats, like Markdown, that require it). Closes #3792.
2017-08-08Writers.Shared.unsmartify: undo literal double curly quotes.John MacFarlane1-0/+3
Previously we left these.
2017-07-13Use foldrWithKey instead of deprecated foldWithKey.John MacFarlane1-1/+1
2017-06-25Moved BCP47 specific functions from Writers.Shared to new module.John MacFarlane1-84/+3
Text.Pandoc.BCP47 (unexported, internal module). `getLang`, `Lang(..)`, `parseBCP47`.
2017-06-25Writers.Shared: improve type of Lang and bcp47 parser.John MacFarlane1-29/+67
Use a real parsec parser for BCP47, include variants.
2017-06-25Writers.Shared: refactored getLang, splitLang...John MacFarlane1-11/+24
into `Lang(..)`, `getLang`, `parceBCP47`.
2017-06-25Text.Pandoc.Writers.Shared: export splitLang.John MacFarlane1-0/+19
2017-06-25Text.Pandoc.Writers.Shared: added getLang.John MacFarlane1-2/+13
2017-06-10Writers.Shared: metaToJSON, generalized type so it can take a Text.John MacFarlane1-9/+9
Previously a String was needed as argument; now any ToJSON instance will do. API change.
2017-05-13Update dates in copyright noticesAlbert Krewinkel1-2/+2
This follows the suggestions given by the FSF for GPL licensed software. <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>
2017-03-23Pipe tables: impose minimum cell size.John MacFarlane1-5/+7
This might help with #3526. At any rate, it fixes another bug (see test/command/3526.md).
2017-03-23Grid tables: remove unnecessary extra space in cells.John MacFarlane1-1/+1
2017-03-23Writers.Shared.gridTable: defensive coding around 'maximum'.John MacFarlane1-1/+2
2017-03-21RST writer: improve grid table output, fix bug with empty rows.John MacFarlane1-17/+29
Uses the new gridTable in Writers.Shared, which is here improved to better handle 0-width cells. Closes #3516.