Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
Later we may want to include a map of URLs and mime type, bytestring
pairs in pure state to serve as a fake internet.
|
|
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.)
|
|
We don't need these, since the default docx and odt can be
retrieved using `readDataFile datadir "reference.docx"` (or odt).
|
|
|
|
Do we need this? I don't see why.
There's a name clash which would better be avoided.
|
|
|
|
|
|
- Added getCommonState, putCommonState, getsCommonState, modifyCommonState
to PandocMonad interface.
- Removed MonadState CommonState instances.
|
|
|
|
This will avoid the need for lift.
|
|
After all, we have warning if you don't want the source pos info.
|
|
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.
|
|
This was left over from when they were part of an environment.
|
|
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.
|
|
There's already a function addWarning in Parsing!
Maybe we can dispense with that now, but I still like
'warning' better as a name.
|
|
* 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]
|
|
And use this in pandoc.hs so that messages actually get printed.
|
|
|
|
Make it all state. This will make it easier to set things.
|
|
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.
|
|
|
|
|
|
|
|
We'll want these in a number of places, but right now it will be
necessary for the macros in T2T.
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
This was left over from when the pure function was called runTest.
|
|
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
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.
|
|
This can be instantiated by both an IO monad or a pure State monad.
|