Commit graph

7694 commits

Author SHA1 Message Date
Jesse Rosenthal
221f878c0e Class: cleanup and clarification. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
912eee362b Remove OverlappingInstances pragma.
It doesn't help to solve the problem in 7.8.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
3cda737dbd Remove redundant import. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
e35c6c9e4d Try adding OverlappingInstances pragma to parsing.
It's having trouble figuring out HasQuoteContext.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
650fa20788 Readers: pass errors straight up to PandocMonad.
Since we've unified error types, we can just throw the same error at
the toplevel.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
9d69c51527 ODT test: remove unnecessary imports. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
c4c56b8c04 Fix rebasing errors. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
d5051ae101 Remove redundant imports from OPML reader. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
5a81c914e7 Remove reader from PandocPure.
Make it all state. This will make it easier to set things.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
06eb9cfb34 Make Txt2Tags test pass.
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-25 17:07:40 +01:00
Jesse Rosenthal
4fe499d3f2 Have a common state for all PandocMonad instances. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
5ede57122c Update all tests to use new readers and error structure. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
3574b98f81 Unify Errors. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
52859b9863 Finish converting readers over. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
5a02a81b43 Have to do some work to get the mediabag out. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
3f7b3f5fd0 Add Text2Tags to Text.Pandoc 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
6a9a38c92d Add input and output filepaths to PandocMonad.
We'll want these in a number of places, but right now it will be
necessary for the macros in T2T.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
9d9f615593 Add Zoned time to class. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
fe0b71a2f1 Class: Add getModificationTime
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-25 17:07:40 +01:00
Jesse Rosenthal
b53ebcdf8e Working on readers. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
840439ab2a Add IncoherentInstances pragma for HasQuotedContext.
We can remove this if we can figure out a better way to do this.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
d9f5f551dd Class: add setMediaBag function. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
d447552be1 Add ParseError to PandocExecutionError.
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-25 17:07:40 +01:00
Jesse Rosenthal
b34bb8be01 List derived instances vertically one-per-line for readability. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
97be338188 Change Test{State,Env} to Pure{State,Env}
This was left over from when the pure function was called runTest.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
2fc47ceebf Class: Add MediaBag to MonadState. 2017-01-25 17:07:40 +01:00
Jesse Rosenthal
cc7191b3b1 Class: Add stateful IO warnings, and function to get warndings.
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-25 17:07:40 +01:00
John MacFarlane
18e85f8dfb Changed readNative to use PandocMonad. 2017-01-25 17:07:40 +01:00
John MacFarlane
bf8fb78389 Text.Pandoc: Change Reader to Reader m.
For now I just replaced occurences of Reader with Reader IO,
so nothing is really different.

When we move readers into instances of PandocMonad, though,
we can change things here so that the readers will work
with any instance of PandocMonad.
2017-01-25 17:07:40 +01:00
John MacFarlane
8978689c08 Removed some commented-out source. 2017-01-25 17:07:40 +01:00
John MacFarlane
300d94ac24 Deleted whitespace at end of source lines. 2017-01-25 17:07:39 +01:00
John MacFarlane
23baba2243 Fixed icml tables test (no newline at end). 2017-01-25 17:07:39 +01:00
John MacFarlane
0e4f959981 Fixed regression in OPML writer.
OPML writer should note include `_notes` attribute when there's
no content.
2017-01-25 17:07:39 +01:00
John MacFarlane
fb2ae14977 Fixed rtf tables test 2017-01-25 17:07:39 +01:00
John MacFarlane
22ffbad9e8 Texinfo writer: restore former behavior for headers level > 4.
The recent changes made the writer fail with an error if it
encountered a header with level 5.  Better to do as we did
before and just print a paragraph in that case.  Eventually
we should emit a warning here.
2017-01-25 17:07:39 +01:00
John MacFarlane
1673bda95e Update tests to work with runPure. 2017-01-25 17:07:39 +01:00
John MacFarlane
b969863e07 Export Text.Pandoc.Class from Text.Pandoc. 2017-01-25 17:07:39 +01:00
John MacFarlane
33af62acc5 Fixes to compile after rebase. 2017-01-25 17:07:39 +01:00
Jesse Rosenthal
04545c92c8 Clean up Text.Pandoc
We had primed versions of all the Writer types and getWriter
functions, as we transitioned. Now that we're using the new ones
exclusively, we'll get rid of the old ones, and get rid of the primes in
the names.
2017-01-25 17:07:39 +01:00
Jesse Rosenthal
23c5b0d0f1 Implement Errors in 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.
2017-01-25 17:07:39 +01:00
Jesse Rosenthal
04487779b2 Convert all writers to use PandocMonad.
Since PandocMonad is an instance of MonadError, this will allow us, in a
future commit, to change all invocations of `error` to `throwError`,
which will be preferable for the pure versions. At the moment, we're
disabling the lua custom writers (this is temporary).

This requires changing the type of the Writer in Text.Pandoc. Right now,
we run `runIOorExplode` in pandoc.hs, to make the conversion easier. We
can switch it to the safer `runIO` in the future.

Note that this required a change to Text.Pandoc.PDF as well. Since
running an external program is necessarily IO, we can be clearer about
using PandocIO.
2017-01-25 17:07:39 +01:00
Jesse Rosenthal
b19f79f672 Add runPure function.
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-25 17:07:39 +01:00
Jesse Rosenthal
b2721c6b02 Make PandocExecutionError an exception
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-25 17:07:39 +01:00
Jesse Rosenthal
211d0f9574 Tests: have docx writer test use runIOorExplode.
Note that part of the reason for making a pure writer is to have better
tests, so this is a temporary fix.
2017-01-25 17:07:39 +01:00
Jesse Rosenthal
989971fce1 Pandoc.hs: Run runIOorExplode on IO functions.
This is a compatibility layer to reintroduce something like the old
errors into the functions.
2017-01-25 17:07:39 +01:00
Jesse Rosenthal
a94f3dddee Make opaque typeclasses PandocPure and PandocIO 2017-01-25 17:07:39 +01:00
Jesse Rosenthal
45f3c53dd9 Class: Specify Functor and Applicative
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-25 17:07:39 +01:00
Jesse Rosenthal
6595318142 Remove Text.Pandoc.Free 2017-01-25 17:07:39 +01:00
Jesse Rosenthal
957eee24ec Convert writers to use PandocMonad typeclass.
Instead of Free Monad with runIO
2017-01-25 17:07:39 +01:00
Jesse Rosenthal
239880f412 Introduce PandocMonad typeclass.
This can be instantiated by both an IO monad or a pure State monad.
2017-01-25 17:07:39 +01:00