aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class.hs
AgeCommit message (Collapse)AuthorFilesLines
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.
2017-01-25Make Txt2Tags test pass.Jesse Rosenthal1-0/+1
We don't have a good way to set things that aren't in the common state. That will be the next order of business.
2017-01-25Have a common state for all PandocMonad instances.Jesse Rosenthal1-81/+63
2017-01-25Unify Errors.Jesse Rosenthal1-25/+16
2017-01-25Finish converting readers over.Jesse Rosenthal1-0/+12
2017-01-25Add input and output filepaths to PandocMonad.Jesse Rosenthal1-12/+48
We'll want these in a number of places, but right now it will be necessary for the macros in T2T.
2017-01-25Add Zoned time to class.Jesse Rosenthal1-1/+15
2017-01-25Class: Add getModificationTimeJesse Rosenthal1-9/+37
This is to enable macros in T2T, but can be used for other stuff in the future, I imagine. This requires building up the info in our fake file trees. Note the version in IO is safe.
2017-01-25Working on readers.Jesse Rosenthal1-0/+10
2017-01-25Class: add setMediaBag function.Jesse Rosenthal1-0/+6
2017-01-25Add ParseError to PandocExecutionError.Jesse Rosenthal1-1/+3
This will be unified with Text.Pandoc.Error eventually. But I'm building it out here so as not to interfere with other modules that might be using the error module currently.
2017-01-25List derived instances vertically one-per-line for readability.Jesse Rosenthal1-2/+14
2017-01-25Change Test{State,Env} to Pure{State,Env}Jesse Rosenthal1-10/+10
This was left over from when the pure function was called runTest.
2017-01-25Class: Add MediaBag to MonadState.Jesse Rosenthal1-6/+18
2017-01-25Class: Add stateful IO warnings, and function to get warndings.Jesse Rosenthal1-3/+9
Right now, the io warnings both print to stderr and write to the state. That can be easily modified. We also add a getWarnings function which pulls warnings out of the state for instances of PandocMonad.
2017-01-25Deleted whitespace at end of source lines.John MacFarlane1-1/+1
2017-01-25Implement Errors in PandocMonadJesse Rosenthal1-7/+11
Errors can be thrown purely with `throwError`. At the moment there are only three kinds of errors: 1. PandocFileReadError FilePath (for problems reading a file from the filesystem) 2. PandocShouldNeverHappenError String (for stuff that should never happen but we need to pattern-match anyway) 3. PandocSomeError String (a grab bag of everything else) Of course, we need to subdivide the third item in this list.
2017-01-25Add runPure function.Jesse Rosenthal1-3/+29
This requires a default environment. The state variables are pretty straightforward. The env variables are a little trickier. I'm just making most of them empty for now. Note that some of them (like defaultReferenceDocx/ODT) will be coming out soon anyway.
2017-01-25Make PandocExecutionError an exceptionJesse Rosenthal1-6/+3
Until we fix fetchItem and fetchItem' to make use of MonadError, we have to thow an exception. We'll throw PandocFileReadError. Note that this is temporary.
2017-01-25Make opaque typeclasses PandocPure and PandocIOJesse Rosenthal1-33/+75
2017-01-25Class: Specify Functor and ApplicativeJesse Rosenthal1-1/+1
We're still compiling for 7.8 which is pre-AMP, so let's just be explicit about it so we can use applicative notation.
2017-01-25Introduce PandocMonad typeclass.Jesse Rosenthal1-0/+202
This can be instantiated by both an IO monad or a pure State monad.