summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Shared.hs
AgeCommit message (Collapse)Author
2024-03-18Export `isOrderedListMarker` from T.P.Writers.Shared.John MacFarlane
[API change] This was formerly in T.P.Writers.Markdown.Inline, but we need to use it in the Typst writer too.
2023-10-05Man writer: Fix some spacing issues around links.John MacFarlane
See #9120. We need to use `\c` before a `.UR` or `.MT`, to avoid an extra space, and also after. To ensure that a space at the beginning of the following line doesn't get swallowed up, we escape it with `\`.
2023-10-05T.P.Shared.splitSentences: don't split after initials.John MacFarlane
This improves the man and ms writer output, preventing sentence breaks after initials.
2023-01-21T.P.Writers.Shared: export setupTranslations [API change].John MacFarlane
Use this in HTML and OpenDocument writers.
2023-01-18Add param to tocToList for numberSections.John MacFarlane
Otherwise sections are always numbered in the TOC, even if `--number-sections` is not used.
2023-01-15Chunks: export `tocToList`Albert Krewinkel
2023-01-10Update copyright years, it's 2023!Albert Krewinkel
2022-11-11Use 'literal tag' instead of 'text (T.unpack tag)' in tagWithAttrsWout Gevaert
2022-11-11[API change] Add functions htmlAddStyle, htmlAlignmentToString and htmlAttrs ↵Wout Gevaert
to Writers/Shared.hs The functions htmlAddStyle and htmlAlignmentToString are moved from Writers/HTML.hs, where they were called 'addStyle' and 'alignmentToString' respectively. The function htmlAttrs is split off from tagWithAttrs in Writers/Shared.hs. It creates a representation of an Attr object, as one would see in a tagWithAttrs (but without the tag)
2022-11-06Move SecInfo, toTOCTree to T.P.Chunks.John MacFarlane
Also add `secPath` to `SecInfo`.
2022-11-06Fix warnings.John MacFarlane
2022-11-06T.P.Writers.Shared: refactor toTableOfContents.John MacFarlane
We now export `toTOCTree` and `SecInfo`, which provide a more neutral way of generating TOC information from Blocks, and we use these in `toTableOfContents`. This is desirable because some output formats may require a TOC structure that isn't just a rendered pandoc list.
2022-10-27T.P.Writers.Shared `toTableOfContents`: handle nested Divs better.John MacFarlane
Closes #8402.
2022-10-15Minor code cleanups.John MacFarlane
2022-04-18Fix compiler warnings from last commit.John MacFarlane
2022-04-18Don't replace links with empty spans in TOC.John MacFarlane
This was a performance enhancement which probably isn't too significant. Closes #8020. Note that, with this change, T.P.Shared.deLink isn't used anywhere in the code base; perhaps we should deprecate it (or remove it, but this would be an API change).
2022-03-18Writers.GridTable: improve module documentation.Albert Krewinkel
2022-02-23T.P.Writers.Shared: export ensureValidXmlIdentifiers.John MacFarlane
This function changes identifiers that don't start with letters, and internal links to these identifiers, making them compatible with XML standards. The change is simple: we add `id_` to the front. There is potential for duplication if there are already `id_...` identifiers defined, but this seems rare enough not to worry too much about.
2022-02-11Put id attributes on TOC entries #7907 (#7913)damon-sava-stanley
Naming scheme of id is "toc-" + id of linked to header/section. In Shared, will effect HTML, Markdown, Powerpoint, and RTF.
2022-01-08Avoid blank lines after tight sublists in org, haddock.John MacFarlane
T.P.Writers.Shared `endsWithPlain` now returns True if the list ends with a list which ends with a Plain. See #7810.
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2021-11-11Writers.Shared: Improve toLegacyTable.Christian Despres
Closes #7683. (PR #7684)
2021-10-11T.P.Writers.Shared: remove 'breakable'...John MacFarlane
which was introduced in the cherry-pick'd commit that added splitSentences, but isn't needed here. (It is for the nospace branch.)
2021-10-11T.P.Writers.Shared: Export splitSentences as a Doc Text transform.John MacFarlane
[API change] Use this in man/ms.
2021-05-12Plain writer: handle superscript unicode minus.John MacFarlane
Closes #7276. Note: currently we still get unwanted white space around the minus; this needs to be addressed with a change in texmath.
2021-04-17Remove Text.Pandoc.BCP47 module.John MacFarlane
[API change] Use Lang from UnicodeCollation.Lang instead. This is a richer implementation of BCP 47.
2021-04-17Move getLang from BCP47 -> T.P.Writers.Shared.John MacFarlane
[API change]
2021-03-19Protect partial uses of maximum with NonEmpty.John MacFarlane
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel
2020-12-15Properly handle boolean values in writing YAML metadata.John MacFarlane
(Markdown writer.) This requires doctemplates >= 0.9. Closes #6388.
2020-07-29Writers/Shared: add missing function docsAlbert Krewinkel
Ensure that all functions in the module have a haddock comment.
2020-04-15Modify toLegacyTable to cut up cells, add testsdespresc
Now a cell with dimension (h, w) will be cut up into h*w cells of dimension (1,1), all in the same grid position, with the upper-left holding the original cell contents and the rest being empty.
2020-04-15Adapt to the newest Table type, fix some previous adaptation issuesdespresc
- Writers.Native is now adapted to the new Table type. - Inline captions should now be conditionally wrapped in a Plain, not a Para block. - The toLegacyTable function now lives in Writers.Shared.
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel
* Use implicit Prelude The previous behavior was introduced as a fix for #4464. It seems that this change alone did not fix the issue, and `stack ghci` and `cabal repl` only work with GHC 8.4.1 or newer, as no custom Prelude is loaded for these versions. Given this, it seems cleaner to revert to the implicit Prelude. * PandocMonad: remove outdated check for base version Only base versions 4.9 and later are supported, the check for `MIN_VERSION_base(4,8,0)` is therefore unnecessary. * Always use custom prelude Previously, the custom prelude was used only with older GHC versions, as a workaround for problems with ghci. The ghci problems are resolved by replacing package `base` with `base-noprelude`, allowing for consistent use of the custom prelude across all GHC versions.
2020-03-13Update copyright year (#6186)Albert Krewinkel
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-07Resolve HLint warningsAlbert Krewinkel
All warnings are either fixed or, if more appropriate, HLint is configured to ignore them. HLint suggestions remain. * Ignore "Use camelCase" warnings in Lua and legacy code * Fix or ignore remaining HLint warnings * Remove redundant brackets * Remove redundant `return`s * Remove redundant as-pattern * Fuse mapM_/map * Use `.` to shorten code * Remove redundant `fmap` * Remove unused LANGUAGE pragmas * Hoist `not` in Text.Pandoc.App * Use fewer imports for `Text.DocTemplates` * Remove redundant `do`s * Remove redundant `$`s * Jira reader: remove unnecessary parentheses
2019-12-07Fix --toc-depth regression in 2.8.John MacFarlane
Closes #5967.
2019-11-15RST writer: Improve spacing for tables with no width information.John MacFarlane
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 MacFarlane
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc
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 MacFarlane
...keeping the widths of columns. See #4320. Adjust test case for #4320.
2019-10-29Changes to build with new doctemplates/doclayout.John MacFarlane
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 MacFarlane
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 MacFarlane
This will allow structured values. [API change]
2019-09-08Replace Element and makeHierarchical with makeSections.John MacFarlane
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 MacFarlane
+ 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 Ryland
2019-05-04Improve c4a81fb941adf6c3bf524916c46623685d276f32.John MacFarlane
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 MacFarlane
not a number. Closes #5479.
2019-03-28Shared - improve metaToJSON with numbers.John MacFarlane
We now do a better job marshalling numbers from MetaString OR MetaInlines into JSON Number.