aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class.hs
AgeCommit message (Collapse)AuthorFilesLines
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.
2017-02-07Moved readFileFromDirs to Text.Pandoc.Class.John MacFarlane1-0/+10
This can be used in several different modules, not just LaTeX reader.
2017-01-27Expose FileTree in ClassJohn MacFarlane1-0/+1
2017-01-25Fixed small mistake in instance for logOutput.John MacFarlane1-1/+1
2017-01-25More logging-related changes.John MacFarlane1-23/+22
Class: * Removed getWarnings, withWarningsToStderr * Added report * Added logOutput to PandocMonad * Make logOutput streaming in PandocIO monad * Properly reverse getLog output Readers: * Replaced use of trace with report DEBUG. TWiki Reader: Put everything inside PandocMonad m. API changes.
2017-01-25Class: Changes around logging.John MacFarlane1-27/+45
* Export getLog, setVerbosity * Add report to PandocMonad methods. * Redefine warning and getWarnings in terms of getLog and report. * Remove stWarnings from CommonState, add stLog and stVerbosity.
2017-01-25Class: Warn instead or erroring if we can't fetch mediaJesse Rosenthal1-5/+18
If deferred media can't be fetched, we catch the error and warn instead. We add an internal function for fetching which returns a Maybe value, and then run catMaybes to only keep the Just's.
2017-01-25Class: Refactor fetchItem.Jesse Rosenthal1-38/+44
Move the downloading/reading-in logic out of fetchItem, so we can use it to fill the MediaBag. Now when other modules use `fetchItem` it will fill the MediaBag as expected.
2017-01-25Class: Add insertDeferredMedia function.Jesse Rosenthal1-0/+7
2017-01-25Integrate DeferredMediaBag into CommonStateJesse Rosenthal1-10/+17
The DeferredMediaBag is now the object that is held in state. It should not be visible to users, who will still deal with MediaBag through exported getters and setters. We now have a function `fetchDeferredMedia` which returns () but downloads/reads in all of the deferred media. Note that getMediaBag first fetches all deferred media.
2017-01-25Introduce DeferredMediaBag.Jesse Rosenthal1-0/+24
This is a lazy MediaBag, that will only be evaluated (downloaded/read in) upon demand. Note that we use fetchItem in getDefferedMedia at the moment to read in/download. This means that we don't need to distinguish between URIs and FilePaths. But there is an inefficiency here: `fetchItem` will pull an item out of the mediaBag if it's already there, and then we'll reinsert it. We could separate out `fetchItem` into the function that checks the MediaBag and the underlying downloader/read-inner.
2017-01-25Class: have pure instance of openURL throw an error, for now.John MacFarlane1-1/+1
Later we may want to include a map of URLs and mime type, bytestring pairs in pure state to serve as a fake internet.
2017-01-25Add openURL and readFileStrict to PandocMonad.John MacFarlane1-38/+98
Removed fetchItem and fetchItem'. Provide fetchItem in PandocMonad (it uses openURL and readFileStrict). TODO: - PandocPure instance for openURL. - Fix places where fetchItem is used so that we trap the exception instead of checking for a Left value. (At least in the places where we want a warning rather than a failure.)
2017-01-25Class: Removed getDefaultReferenceDocx/ODT from PandocMonad.John MacFarlane1-22/+2
We don't need these, since the default docx and odt can be retrieved using `readDataFile datadir "reference.docx"` (or odt).
2017-01-25Removed commented-out vestigaes of fail in Class.John MacFarlane1-8/+0
2017-01-25Class: removed 'fail' from PandocMonad.John MacFarlane1-12/+12
Do we need this? I don't see why. There's a name clash which would better be avoided.
2017-01-25Removed unneeded pragmas.John MacFarlane1-2/+1
2017-01-25Instances of PandocMonad for common transformers.John MacFarlane1-2/+79
2017-01-25Class: no more MonadState CommonState.John MacFarlane1-14/+23
- Added getCommonState, putCommonState, getsCommonState, modifyCommonState to PandocMonad interface. - Removed MonadState CommonState instances.
2017-01-25Whitespace.John MacFarlane1-3/+3
2017-01-25Add PandocMonad m instance for ParserT based on PandocMonad.John MacFarlane1-6/+4
This will avoid the need for lift.
2017-01-25Have warningWithPos take a SourcePos rather than Maybe SourcePos.John MacFarlane1-12/+22
After all, we have warning if you don't want the source pos info.
2017-01-25Class: Functions for dealing with PureStateJesse Rosenthal1-23/+42
There are two states in PandocPure, but it is only easy to deal with CommonState. In the past, to do state monad operations on PureState (the state specific to PandocPure) you had to add (lift . lift) to the monadic operation and then rewrap in the newtype. This adds four functions ({get,gets,put,modify}PureState) corresponding to normal state monad operations. This allows the user to modify PureState in PandocPure without worrying about where it sits in the monad stack or rewrapping the newtype.
2017-01-25Class: rename env* prefixed fields to st*.Jesse Rosenthal1-28/+28
This was left over from when they were part of an environment.
2017-01-25Error: change type of handleError.John MacFarlane1-1/+1
It now lives in IO and gives a proper message + exit instead of calling 'error'. We shouldn't be making it easier for people to raise error on pure code. And this is better for the main application in IO.
2017-01-25Class: rename addWarning[WithPos] to warning[WithPos].John MacFarlane1-12/+10
There's already a function addWarning in Parsing! Maybe we can dispense with that now, but I still like 'warning' better as a name.
2017-01-25Class: Renamed 'warn' to 'addWarning' and consolidated RTF writer.John MacFarlane1-7/+5
* Renaming Text.Pandoc.Class.warn to addWarning avoids conflict with Text.Pandoc.Shared.warn. * Removed writeRTFWithEmbeddedImages from Text.Pandoc.Writers.RTF. This is no longer needed; we automatically handle embedded images using the PandocM functions. [API change]
2017-01-25New withWarningsToStderr exported from Text.Pandoc.Class.John MacFarlane1-1/+11
And use this in pandoc.hs so that messages actually get printed.
2017-01-25Class: cleanup and clarification.Jesse Rosenthal1-22/+6
2017-01-25Remove reader from PandocPure.Jesse Rosenthal1-50/+43
Make it all state. This will make it easier to set things.