aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
AgeCommit message (Collapse)AuthorFilesLines
2019-09-05Shared.hierarchicalize: improve handling of div and section structure.John MacFarlane1-4/+15
Previously Divs were opaque to hierarchicalize, so headings inside divs didn't get into the table of contents, for example (#3057). Now hierarchicalize treats Divs as sections when appropriate. For example, these structures both yield a section and a subsection: ``` html <div> <h1>one</h1> <div> <h2>two</h2> </div> </div> ``` ``` html <div> <h1>one</h1> <div> <h1>two</h1> </div> </div> ``` Note that ``` html <h1>one</h1> <div> <h2>two</h2> </div> <h1>three</h1> ``` gets parsed as the structure one two three which may not always be desirable. Closes #3057.
2019-08-25Use new doctemplates, doclayout.John MacFarlane1-1/+1
+ 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-16Make filterIpynbOutput strip ANSI escapes from code in output...John MacFarlane1-1/+10
for non-ipynb formats, when the default "best" option is used with --ipynb-output. The escape sequences cause problems in many formats, including LaTeX. Closes #5633.
2019-05-27consolidate simple-table detection (#5524)Mauro Bieg1-0/+15
add `onlySimpleTableCells` to `Text.Pandoc.Shared` [API change] This fixes an inconsistency in the HTML reader, which did not treat tables with `<p>` inside cells as simple.
2019-03-06filterIpynbOutput - go back to just including one block per format.John MacFarlane1-4/+3
In the end we need a 1-1 map of mime types to output blocks.
2019-03-06Fixed mistake in filterIpynbOutput (prefer lower, not higher rank!)John MacFarlane1-4/+3
2019-03-06Improve filterIpynbOutput.John MacFarlane1-4/+7
- Ensure that images are prioritized over text. - Allow multiple RawBlocks for same format.
2019-03-06Shared.filterIpynbOutput: 'best' should include everything for ipynb.John MacFarlane1-1/+5
2019-03-02Shared: remove withTempDir.John MacFarlane1-17/+0
2019-03-02Add new exported function defaultUserDataDirsJohn MacFarlane1-1/+17
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-28Shared: add filterIpynbOutput. [API change]John MacFarlane1-1/+28
Add command line option `--ipynb-output=all|none|best`. Closes #5339.
2019-02-25Shared.compactify: Avoid mixed lists.John MacFarlane1-7/+6
This improves on the original fix to #5285 by preventing other mixed lists (lists with a mix of Plain and Para elements) that were allowed given the original fix.
2019-02-08Improve tight/loose list handling.John MacFarlane1-2/+9
Closes #5285. Previously the algorithm allowed list items with a mix of Para and Plain, which is never wanted. compactify in T.P.Shared has been modified so that, if a list's items contain (at the top level) Para elements (aside from perhaps at the very end), ALL Plains are converted to Paras.
2019-02-08Fix misleading code comment.John MacFarlane1-2/+1
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-02-02Shared: withTempDir is no longer used in the codebase.John MacFarlane1-0/+2
Add comment to remove it in next major release.
2019-01-02Implement task lists (#5139)Mauro Bieg1-0/+32
Closes #3051
2018-11-19For bibliography match Div with id 'refs', not class 'references'.John MacFarlane1-2/+2
This was a mismatch between pandoc's docx, epub, latex, and markdown writers and the behavior of pandoc-citeproc, which actually looks for a div with id 'refs' rather than one with class 'references'.
2018-11-11Exactly match GitHub's identifier generating algorithm.John MacFarlane1-2/+7
See #5057.
2018-11-11Text.Pandoc.Shared: add parameter to uniqueIdent, inlineListToIdentifier.John MacFarlane1-22/+37
The parameter is Extensions. This allows these functions to be sensitive to the settings of `Ext_gfm_auto_identifiers` and `Ext_ascii_identifiers`. This allows us to use `uniqueIdent` in the CommonMark reader, replacing some custom code. It also means that `gfm_auto_identifiers` can now be used in all formats. Semantically, `gfm_auto_identifiers` is now a modifier of `auto_identifiers`; for identifiers to be set, `auto_identifiers` must be turned on, and then the type of identifier produced depends on `gfm_auto_identifiers` and `ascii_identifiers` are set. Closes #5057.
2018-11-03Add Text.Pandoc.Shared.ToString typeclass (API change)Alexander Krotov1-0/+12
2018-10-29LaTeX reader: allow space at end of math after `\`.John MacFarlane1-0/+10
Closes #5010. Expose trimMath from T.P.Shared.
2018-10-10Reimplement mapLeft using Bifunctor.firstAlexander Krotov1-2/+2
2018-10-01Shared: new export `splitSentences` [API change].John MacFarlane1-0/+26
This was duplicated in the Man and Ms writers, and really belongs in Shared.
2018-07-30Lua Utils module: add function blocks_to_inlines (#4799)Albert Krewinkel1-2/+11
Exposes a function converting which flattenes a list of blocks into a list of inlines. An example use case would be the conversion of Note elements into other inlines.
2018-07-02Spellcheck commentsAlexander Krotov1-1/+1
2018-05-08Fixed bug in uriPathToPath for Windows.John MacFarlane1-1/+1
2018-05-08Shared: add uriPathToPath.John MacFarlane1-0/+14
This adjusts the path from a file: URI in a way that is sensitive to Windows/Linux differences. Thus, on Windows, `/c:/foo` gets interpreted as `c:/foo`, but on Linux, `/c:/foo` gets interpreted as `/c:/foo`. See #4613.
2018-03-18Removed old-locale flag and Text.Pandoc.Compat.Time.John MacFarlane1-7/+2
This is no longer necessary since we no longer support ghc 7.8.
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-16Monoid/Semiground cleanup relying on custom Prelude.John MacFarlane1-3/+2
2018-01-19hlint code improvements.John MacFarlane1-1/+1
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2017-12-22API change: export blocksToInlines' from Text.Pandoc.Sharedmb211-0/+1
2017-12-02Shared.blocksToInlines: rewrote using builder.John MacFarlane1-24/+27
This gives us automatic normalization, so we don't get for example two consecutive Spaces.
2017-12-02Add --strip-empty-paragraphs option.John MacFarlane1-0/+9
This works for any input format.
2017-11-28make normalizeDate more forgiving (#4101)Mauro Bieg1-1/+1
also parse two-digit days, e.g. "April 20, 2017"
2017-11-01hlintAlexander Krotov1-3/+3
2017-10-29Source code reformatting.John MacFarlane1-1/+1
2017-10-27hlint suggestions.John MacFarlane1-22/+21
2017-10-27Don't rely on syb when we don't need to.John MacFarlane1-1/+1
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-63/+67
2017-10-27Consistent underline for Readers (#2270)hftf1-0/+8
* Added underlineSpan builder function. This can be easily updated if needed. The purpose is for Readers to transform underlines consistently. * Docx Reader: Use underlineSpan and update test * Org Reader: Use underlineSpan and add test * Textile Reader: Use underlineSpan and add test case * Txt2Tags Reader: Use underlineSpan and update test * HTML Reader: Use underlineSpan and add test case
2017-10-15Remove openURL from Shared (API change).John MacFarlane1-51/+1
Now all the guts of openURL have been put into openURL from Class. openURL is now sensitive to stRequestHeaders in CommonState and will add these custom headers when making a request. It no longer looks at the USER_AGENT environment variable, since you can now set the `User-Agent` header directly.
2017-10-08Shared.stringify, removeFormatting: handle Quoted better.John MacFarlane1-2/+9
Previously we were losing the qutation marks in Quoted elements. See #3958.
2017-08-11Added support for translations (localization) (see #3559).John MacFarlane1-118/+1
* readDataFile, readDefaultDataFile, getReferenceDocx, getReferenceODT have been removed from Shared and moved into Class. They are now defined in terms of PandocMonad primitives, rather than being primitve methods of the class. * toLang has been moved from BCP47 to Class. * NoTranslation and CouldNotLoudTranslations have been added to LogMessage. * New module, Text.Pandoc.Translations, exporting Term, Translations, readTranslations. * New functions in Class: translateTerm, setTranslations. Note that nothing is loaded from data files until translateTerm is used; setTranslation just sets the language to be used. * Added two translation data files in data/translations. * LaTeX reader: Support `\setmainlanguage` or `\setdefaultlanguage` (polyglossia) and `\figurename`.
2017-08-10Expose getDefaultDataFile in both Shared and Class.John MacFarlane1-0/+1
2017-06-20Move CR filtering from tabFilter to the readers.John MacFarlane1-4/+8
The readers previously assumed that CRs had been filtered from the input. Now we strip the CRs in the readers themselves, before parsing. (The point of this is just to simplify the parsers.) Shared now exports a new function `crFilter`. [API change] And `tabFilter` no longer filters CRs.
2017-06-17Use Control.Monad.State.Strict throughout.John MacFarlane1-1/+1
This gives 20-30% speedup and reduction of memory usage in most of the writers.