aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
AgeCommit message (Collapse)AuthorFilesLines
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>
2017-01-27Shared: rename compactify', compactify'DL -> compactify, compactifyDL.John MacFarlane1-8/+8
2017-01-27Removed Shared.compactify.John MacFarlane1-17/+0
Changed signatures on Parsing.tableWith and Parsing.gridTableWith.
2017-01-25Removed writerIgnoreNotes.John MacFarlane1-0/+1
Instead, just temporarily remove notes when generating TOC lists in HTML and Markdown (as we already did in LaTeX). Also export deNote from Text.Pandoc.Shared. API change in Shared and Options.WriterOptions.
2017-01-25Factored out deNote in Shared.John MacFarlane1-4/+4
2017-01-25Text.Pandoc.Shared: Removed fetchItem, fetchItem'.John MacFarlane1-66/+3
Made changes where these are used, so that the version of fetchItem from PandocMonad can be used instead.
2017-01-25Removed hush from Text.Pandoc.Shared.John MacFarlane1-5/+0
Not used anywhere.
2017-01-25Removed `--normalize` option and normalization functions from Shared.John MacFarlane1-150/+0
* Removed normalize, normalizeInlines, normalizeBlocks from Text.Pandoc.Shared. These shouldn't now be necessary, since normalization is handled automatically by the Builder monoid instance. * Remove `--normalize` command-line option. * Don't use normalize in tests. * A few revisions to readers so they work well without normalize.
2017-01-25Shared: put err into MonadIO.John MacFarlane1-2/+2
2017-01-25Shared: changed err and warn output.John MacFarlane1-5/+2
Don't print program name in either case. Print [warning] for warnings.
2016-11-27Shared.fetchItem: Better handling of protocol-relative URL.John MacFarlane1-0/+9
If URL starts with `//` and there is no "base URL" (as there would be if a URL were used on the command line), then default to http:. Closes #2635.
2016-11-22Put 'warn' in MonadIO. Add warnings for math conversions in docx.John MacFarlane1-4/+5
2016-10-18Merge pull request #3165 from hubertp-lshift/feature/odt-imageJohn MacFarlane1-0/+13
[odt] images parser
2016-10-17Use bind function instead of pattern matchingHubert Plociniczak1-4/+1
2016-10-13Allow http-client 0.4.30, which is the version in stackage lts.John MacFarlane1-16/+0
Previously we required 0.5. Remove CPP conditionals for earlier versions.
2016-10-13Revert "Remove http-client CPP conditionals."John MacFarlane1-1/+10
This reverts commit 3f82471355286d33f2d73329c29a51c47bf76ad7. We might want to revert the requirement of http-client 0.5, as this is not yet in Stackage and that is starting to cause problems. I can't recall why it is there.
2016-10-13Shared: add function combining lines using LineBreakAlbert Krewinkel1-0/+11
The `linesToBlock` function takes a list of lines and combines them by appending a hard `LineBreak` to each line and concatenating the result, putting the result it into a `Para`. This is most useful when dealing when converting `LineBlock` elements.
2016-10-12Basic support for images in ODT documentsHubert Plociniczak1-0/+16
Highly influenced by the docx support, refactored some code to avoid DRY.
2016-09-03Remove http-client CPP conditionals.Jesse Rosenthal1-10/+1
Our lower bound on http-client is 0.5, and both of these min_version tests are less than 0.5, so they will always pass.
2016-09-02Remove Compat.MonoidJesse Rosenthal1-1/+1
This was only necessary for GHC versions with base below 4.5 (i.e., ghc < 7.4).
2016-07-20Rename README to MANUAL.txtAlbert Krewinkel1-2/+2
2016-07-14Shared: improve year sanity check in normalizeDateJesse Rosenthal1-6/+6
Previously we parsed a list of dates, took the first one, and then tested its year range. That meant that if the first one failed, we returned nothing, regardless of what the others did. Now we test for sanity before running `msum` over the list of Maybe values. Anything failing the test will be Nothing, so will not be a candidate.
2016-07-14Shared: normalizeDate should reject illegal years.Jesse Rosenthal1-5/+10
We only allow years between 1601 and 9999, inclusive. The ISO 8601 actually says that years are supposed to start with 1583, but MS Word only allows 1601-9999. This should stop corrupted word files if the date is out of that range, or is parsed incorrectly.
2016-07-14Shared: Add further formats for `normalizeDate`Jesse Rosenthal1-1/+2
We want to avoid illegal dates -- in particular years with greater than four digits. We attempt to parse series of digits first as `%Y%m%d`, then `%Y%m`, and finally `%Y`.
2016-07-03Fix warning for parseURl import.John MacFarlane1-2/+3
2016-07-03CPP workaround for deprecation of parseUrl in http-client.John MacFarlane1-6/+14
2016-06-23Shared: Add BlockQuote to blocksToInlinesJesse Rosenthal1-0/+1
2016-06-23Shared: introduce blocksToInlines functionJesse Rosenthal1-0/+37
This is a lossy function for converting `[Block] -> [Inline]`. Its main use, at the moment, is for docx comments, which can contain arbitrary blocks (except for footnotes), but which will be converted to spans. This is, at the moment, pretty useless for everything but the basic `Para` and `Plain` comments. It can be improved, but the docx reader should probably emit a warning if the comment contains more than this.