aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
AgeCommit message (Collapse)AuthorFilesLines
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.
2017-06-11Switched Writer types to use Text.John MacFarlane1-2/+2
* XML.toEntities: changed type to Text -> Text. * Shared.tabFilter -- fixed so it strips out CRs as before. * Modified writers to take Text. * Updated tests, benchmarks, trypandoc. [API change] Closes #3731.
2017-06-10Rewrote convertTabs to use Text not String.John MacFarlane1-17/+11
2017-05-30Added eastAsianLineBreakFilter to Shared.John MacFarlane1-0/+12
This used to live in the Markdown reader.
2017-05-23Shared.isURI: allow uppercase versions of known schemes.John MacFarlane1-1/+2
2017-05-23Shared: Provide custom isURI that rejects unknown schemes [isURI]Albert Krewinkel1-1/+68
We also export the set of known `schemes`. The new function replaces the function of the same name from `Network.URI`, as the latter did not check whether a scheme is well-known. E.g. MediaWiki wikis frequently feature pages with names like `User:John`. These links were interpreted as URIs, thus turning internal links into global links. This is prevented by also checking whether the scheme of a URI is frequently used (i.e. is IANA registered or an otherwise well-known scheme). Fixes: #2713 Update set of well-known URIs from IANA list All official IANA schemes (as of 2017-05-22) are included in the set of known schemes. The four non-official schemes doi, isbn, javascript, and pmid are kept.
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-05-07Added PandocHttpException, trap exceptions in fetching from URLs.John MacFarlane1-4/+5
Closes #3646.
2017-05-07Remove https flag.John MacFarlane1-21/+0
Supporting two completely different libraries for fetching from URLs makes it difficult to trap errors, because of different error types expected from the libraries. There's no clear reason not to build with these https-capable libraires.
2017-04-15Error: Added PandocCouldNotFindDataFileError.John MacFarlane1-3/+2
Use this instead of PandocAppError when appropriate. Removed exit code from PandocAppError, use 1 for all.
2017-04-02Text.Pandoc.App: Throw errors rather than exiting.John MacFarlane1-12/+4
These are caught (and lead to exit) in pandoc.hs, but other uses of Text.Pandoc.App may want to recover in another way. Added PandocAppError to PandocError (API change). This is a stopgap: later we should have a separate constructor for each type of error. Also fixed uses of 'exit' in Shared.readDataFile, and removed 'err' from Shared (API change). Finally, removed the dependency on extensible-exceptions. See #3548.
2017-03-12Revert "Shared: export extractIds."John MacFarlane1-20/+0
This reverts commit 0ef1e51211cd35b1ddb54a5fe8bee4247f1e1801.
2017-03-12Shared: export extractIds.John MacFarlane1-0/+20
This will be used to help with #1745.
2017-03-10Removed normalizeSpaces from Text.Pandoc.Shared.John MacFarlane1-20/+0
Rewrote functions in RST reader and writer to avoid the need for it. Closes #1530.
2017-03-10Shared.normalizeSpaces: strip off leading/trailing line breaks...John MacFarlane1-2/+4
...not just spaces.
2017-02-24Shared: remove 'warn'.John MacFarlane1-5/+0
PDF writer: Use 'report' instead of 'warn', make it sensitive to verbosity settings.
2017-02-23Shared.openURL: Changed type from an Either.John MacFarlane1-6/+9
Now it will just raise an exception to be trapped later.
2017-02-14Simplify toRomanNumeral using guards (#3445)Alexander Krotov1-18/+16
2017-02-05Allow user to specify User-Agent (#3421)Thenaesh Elango1-3/+11
This commit enables users to specify the User-Agent header used when pandoc requests a document from a URL. This is done by setting an environment variable. For instance, one can do: USER_AGENT="..." ./pandoc -f html -t markdown http://example.com Signed-off-by: Thenaesh Elango <thenaeshelango@gmail.com>