aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class.hs
AgeCommit message (Collapse)AuthorFilesLines
2017-10-15Remove openURL from Shared (API change).John MacFarlane1-7/+44
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-15Class: add stRequestHeaders to CommonState, and setRequestHeader.John MacFarlane1-0/+13
2017-09-30Text.Pandoc.Class - add getVerbosity.John MacFarlane1-0/+5
2017-09-30Removed writerSourceURL, add source URL to common state.John MacFarlane1-17/+37
Removed `writerSourceURL` from `WriterOptions` (API change). Added `stSourceURL` to `CommonState`. It is set automatically by `setInputFiles`. Text.Pandoc.Class now exports `setInputFiles`, `setOutputFile`. The type of `getInputFiles` has changed; it now returns `[FilePath]` instead of `Maybe [FilePath]`. Functions in Class that formerly took the source URL as a parameter now have one fewer parameter (`fetchItem`, `downloadOrRead`, `setMediaResource`, `fillMediaBag`). Removed `WriterOptions` parameter from `makeSelfContained` in `SelfContained`.
2017-09-30Text.Pandoc.Lua: add mediabag submoduleAlbert Krewinkel1-9/+19
2017-08-20Protect OVERLAPS pragma with CPP.John MacFarlane1-0/+4
2017-08-20Use OverlappingInstances instead of OVERLAPS for ghc 7.8.4.John MacFarlane1-0/+4
2017-08-20Removed redundant import.John MacFarlane1-1/+0
2017-08-19Simplify instances in Class by parameterizing on MonadTrans.John MacFarlane1-67/+21
2017-08-12Improved error report on loading translation file.John MacFarlane1-4/+6
2017-08-12Change to yaml for translation files.John MacFarlane1-6/+7
2017-08-11Fixed import.John MacFarlane1-1/+1
2017-08-11More redundant imports.John MacFarlane1-2/+1
2017-08-11Avoid some warnings when compiled wo/ embed_data_files flag.John MacFarlane1-2/+3
2017-08-11Add getFileName to PandocMonad.John MacFarlane1-2/+16
We need this for getDefaultDataFile.
2017-08-11Added support for translations (localization) (see #3559).John MacFarlane1-46/+212
* 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-10Removed datadir param from readDataFile and getDefaultTemplate.John MacFarlane1-14/+20
In Text.Pandoc.Class and Text.Pandoc.Template, resp. We now get the datadir from CommonState.
2017-08-10Class: add setUserDataDir and getUserDataDir.John MacFarlane1-5/+21
* Add stUserDataDir to CommonState. * Rename stUserDataDir/stCabalDataDir in PureState to stUserDataFiles/stCabalDataFiles.
2017-08-10Expose getDefaultDataFile in both Shared and Class.John MacFarlane1-3/+13
2017-07-30Class: more haddocks.John MacFarlane1-0/+12
2017-07-30Class: Removed unnecessary withMedia, improved haddocks.John MacFarlane1-7/+22
2017-07-19Class: started adding haddocks.John MacFarlane1-10/+39
2017-07-15Don't rely on listDirectory, which is only in newer versions...John MacFarlane1-2/+5
of directory.
2017-07-14Class: make addToFileTree handle directories recursively.John MacFarlane1-6/+15
2017-07-14Class: remove stFontFiles in PureState, 'glob' searches stFiles.John MacFarlane1-4/+2
2017-07-14Class: added addToFileTreeJohn MacFarlane1-0/+8
2017-06-19Tracing: give less misleading line information with parseWithString.John MacFarlane1-2/+7
Previously positions would be reported past the end of the chunk. We now reset the source position within the chunk and report positions "in chunk."
2017-06-19Separated tracing from logging.John MacFarlane1-5/+22
Formerly tracing was just log messages with a DEBUG log level. We now make these things independent. Tracing can be turned on or off in PandocMonad using `setTrace`; it is independent of logging. * Removed `DEBUG` from `Verbosity`. * Removed `ParserTrace` from `LogMessage`. * Added `trace`, `setTrace` to `PandocMonad`.
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-12Changed "extracting..." warning to a regular log message.John MacFarlane1-4/+19
This makes it sensitive to proper verbosity settings. (It is now treated as INFO rather than WARNING, so one doesn't get these messages for creation of tmp images while making a pdf.) API changes: * Removed extractMediaBag from Text.Pandoc.MediaBag. * Added Extracting as constructor for LogMessage.
2017-06-02hlint suggestions.John MacFarlane1-1/+1
2017-06-01Some hlint refactoring.John MacFarlane1-16/+13
2017-06-01Trivial reformatting.John MacFarlane1-3/+7
2017-05-18Don't double extract images from docx.John MacFarlane1-9/+14
This fixes a regression that was introduced when `--extract-media` was generalized to work with any input format. We were getting two versions of each image extracted from a docx, one with a hash, one with the original filename, though only the hash one was used. This patch restores the original behavior (using the original filename). Pointed out in comments on #3674. Thanks to @laperouse.
2017-05-07Rename fillMedia -> fillMediaBag.John MacFarlane1-3/+3
2017-05-07Moved fillMedia, extractMedia from App to Class.John MacFarlane1-3/+53
Also generalized type of fillMedia to any instance of PandocMonad.
2017-05-07Added PandocHttpException, trap exceptions in fetching from URLs.John MacFarlane1-1/+4
Closes #3646.
2017-05-02Added PandocResourceNotFound error.John MacFarlane1-8/+4
Use this instead of PandocIOError when a resource is not found in path. This improves the error message in this case, see #3629.
2017-03-09Changed display format for messages.John MacFarlane1-8/+8
2017-03-04Add hanging indent to log messages.John MacFarlane1-3/+12
This makes them easier to read.
2017-02-24Shared: remove 'warn'.John MacFarlane1-4/+1
PDF writer: Use 'report' instead of 'warn', make it sensitive to verbosity settings.
2017-02-24Class: Add stResourcePath to CommonState, getResourcePath, setResourcePath.John MacFarlane1-8/+32
To be used in implementing `\graphicspath` in LaTeX, and possibly in things like PDF production via context. Use resource path in fetchItem. Issue an info message if we get a resource from somewhere other than ".". Added UsingResourceFrom to log message.
2017-02-23Restore "Fetching..." message with openURL if --verbose.John MacFarlane1-1/+3
2017-02-23Use PandocIOError in Class.John MacFarlane1-36/+23
2017-02-11Class.report: Save all log messages in state.John MacFarlane1-2/+2
Verbosity level only affects which are printed to stdout. (Exception: DEBUG messages are only printed, never saved to state.)
2017-02-11Use new warnings throughout the code base.John MacFarlane1-32/+21
2017-02-10Added Text.Pandoc.Logging (exported module).John MacFarlane1-2/+2
This now contains the Verbosity definition previously in Options, as well as a new LogMessage datatype that will eventually be used instead of raw strings for warnings. This will enable us, among other things, to provide machine-readable warnings if desired. See #3392.
2017-02-09LaTeX reader: Issue warnings when skipping unknown latex commands.John MacFarlane1-1/+1
See #3392.
2017-02-09Reverted deferred media bag code.John MacFarlane1-51/+6
This was not actually being used. Since it adds considerable complexity, it's best not to include it unless we are actually going to use it. The original thought was that we could do all loading in the readers, always deferred and thus costless. This was supposed to eliminate the need to traverse trees loading resources in the docx, epub, odt writers and in PDF and SelfContained. (It would also have the side effect that --extract-media could be used with all input formats. This wasn't an intended side effect, and it could be debated whether it's desirable, since --extract-media was originally designed to extract the media contained in a docx or odt or epub container.) However, we never actually took the step of moving all of this work to the readers, for a couple of reasons. The main reason is that we'd still need to fetch resources in the docx, epub, odt, pdf and self-contained writers, since the Pandoc AST might have been built programatically and hence not generated by a reader. So it's not clear that doing lazy loading in the readers would have any real advantage. I'm still not completely sure about this --- if we change our minds it would be easy to undo this commit. @jkr comments welcome.
2017-02-07Refactored some files formerly in LaTeX reader.John MacFarlane1-4/+4
* Export readFileFromDirs from Class. * Export insertIncludedFile from Parsing. Simplified code in LaTeX/RST readers.