Commit graph

3913 commits

Author SHA1 Message Date
John MacFarlane
4f6e6247f9 Made smart extension default for pandoc markdown.
Updated tests.
2017-01-25 17:07:42 +01:00
John MacFarlane
a58369a7e6 Options: changed default reader/writerExtensions to emptyExtensions.
Previously they were pandocExtensions.
This didn't make sense for many formats.
2017-01-25 17:07:42 +01:00
John MacFarlane
412ed3f132 Make the smart extension affect the Markdown writer.
Thus, to "unsmartify" something that has been parsed as
smart by pandoc, you can use `-t markdown+smart`, and
straight quotes will be produced instead of curly quotes,
etc.

Example:

    % pandoc -f latex -t markdown+smart
    ``hi''---ok
    ^D
    "hi"---ok
2017-01-25 17:07:42 +01:00
John MacFarlane
5bf9125770 Removed readerOldDashes and --old-dashes option, added old_dashes extension.
API change.  CLI option change.
2017-01-25 17:07:42 +01:00
John MacFarlane
6f8b967d98 Removed readerSmart and the --smart option; added Ext_smart extension.
Now you will need to do

    -f markdown+smart

instead of

    -f markdown --smart

This change opens the way for writers, in addition to readers,
to be sensitive to +smart, but this change hasn't yet been made.

API change. Command-line option change.

Updated manual.
2017-01-25 17:07:42 +01:00
John MacFarlane
3876b91448 Make Extensions a custom type instead of a Set Extension.
The type is implemented in terms of an underlying bitset
which should be more efficient.

API change: from Text.Pandoc.Extensions export Extensions,
emptyExtensions, extensionsFromList, enableExtension, disableExtension,
extensionEnabled.
2017-01-25 17:07:42 +01:00
John MacFarlane
1427252160 Split extensions code from Options into separate Text.Pandoc.Extensions.
API change.
However, Extensions exports Options, so this shouldn't have
much impact.
2017-01-25 17:07:42 +01:00
John MacFarlane
93e4cd9f8c Fixed something small that broke in rebase. 2017-01-25 17:07:42 +01:00
Jesse Rosenthal
5b3bfa28f4 Class: Warn instead or erroring if we can't fetch media
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-25 17:07:42 +01:00
Jesse Rosenthal
613588a0dc Class: Refactor fetchItem.
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-25 17:07:42 +01:00
Jesse Rosenthal
4b953720c8 Class: Add insertDeferredMedia function. 2017-01-25 17:07:42 +01:00
Jesse Rosenthal
55dbc00d55 Integrate DeferredMediaBag into CommonState
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-25 17:07:42 +01:00
Jesse Rosenthal
5814096d79 Introduce DeferredMediaBag.
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-25 17:07:42 +01:00
John MacFarlane
994d431172 Class: have pure instance of openURL throw an error, for now.
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-25 17:07:42 +01:00
John MacFarlane
6aff97e4e1 Text.Pandoc.Shared: Removed fetchItem, fetchItem'.
Made changes where these are used, so that the version
of fetchItem from PandocMonad can be used instead.
2017-01-25 17:07:42 +01:00
John MacFarlane
4cb124d147 Add openURL and readFileStrict to PandocMonad.
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-25 17:07:41 +01:00
John MacFarlane
00240ca7ed Removed hush from Text.Pandoc.Shared.
Not used anywhere.
2017-01-25 17:07:41 +01:00
John MacFarlane
8165014df6 Removed --normalize option and normalization functions from Shared.
* Removed normalize, normalizeInlines, normalizeBlocks
  from Text.Pandoc.Shared.  These shouldn't now be necessary,
  since normalization is handled automatically by the Builder
  monoid instance.

* Remove `--normalize` command-line option.

* Don't use normalize in tests.

* A few revisions to readers so they work well without normalize.
2017-01-25 17:07:41 +01:00
John MacFarlane
08110c3714 Class: Removed getDefaultReferenceDocx/ODT from PandocMonad.
We don't need these, since the default docx and odt can be
retrieved using `readDataFile datadir "reference.docx"` (or odt).
2017-01-25 17:07:41 +01:00
John MacFarlane
143d1a2113 Removed commented-out vestigaes of fail in Class. 2017-01-25 17:07:41 +01:00
John MacFarlane
b5d1567022 Class: removed 'fail' from PandocMonad.
Do we need this?  I don't see why.

There's a name clash which would better be avoided.
2017-01-25 17:07:41 +01:00
John MacFarlane
a66c1bf88e Generic instance for PandocError. 2017-01-25 17:07:41 +01:00
John MacFarlane
a964b14475 Text.Pandoc: limit exports from Text.Pandoc.Class. 2017-01-25 17:07:41 +01:00
John MacFarlane
2e7b0c7eda Added ReaderOptions parameter to readNative.
This makes it similar to the other readers -- even
though ReaderOptions is essentially ignored, the uniformity
is nice.
2017-01-25 17:07:41 +01:00
John MacFarlane
dcccf65f33 MediaBag: put extractMediaBag into MonadIO. 2017-01-25 17:07:41 +01:00
John MacFarlane
cf7d7f533a SelfContained: put makeSelfContained in MonadIO. 2017-01-25 17:07:41 +01:00
John MacFarlane
753c14cb63 PDF: put makePDF in MonadIO. 2017-01-25 17:07:41 +01:00
John MacFarlane
2b24c6ff3a Shared: put err into MonadIO. 2017-01-25 17:07:41 +01:00
John MacFarlane
f1ef0e3645 Finished previous commit; removed export of toJsonFilter. 2017-01-25 17:07:41 +01:00
John MacFarlane
f91a6b541f Removed deprecated toJsonFilter.
Use toJSONFilter from Text.Pandoc.JSON.
2017-01-25 17:07:41 +01:00
John MacFarlane
ce1664cf2b Simplified reference-docx/reference-odt to reference-doc.
* Text.Pandoc.Options.WriterOptions: removed writerReferenceDocx
  and writerReferenceODT, replaced them with writerReferenceDoc.
  This can hold either an ODT or a Docx. In this way, writerReferenceDoc
  is like writerTemplate, which can hold templates of different
  formats. [API change]

* Removed `--reference-docx` and `--reference-odt` options.

* Added `--reference-doc` option.
2017-01-25 17:07:41 +01:00
John MacFarlane
9570f59066 Process.pipeProcess: stream stderr rather than capturing.
Signature of pipeProcess has changed: the return value is
now IO (ExitCode, ByteString) -- with only stdout. Stderr
is just inherited from the parent.

This means that stderr from filters will now be streamed
as the filters are run.

Closes #2729.
2017-01-25 17:07:41 +01:00
John MacFarlane
da2055d709 RST reader: rebase-related fixes to warnings. 2017-01-25 17:07:41 +01:00
John MacFarlane
f328cfe6a7 Removed unneeded pragmas. 2017-01-25 17:07:41 +01:00
John MacFarlane
bc61c6a632 Remove now-unnecessary lifts in Markdown writer.
Other writers still TBD.
2017-01-25 17:07:41 +01:00
John MacFarlane
4111fdbaf0 Instances of PandocMonad for common transformers. 2017-01-25 17:07:41 +01:00
John MacFarlane
54932ade67 Class: no more MonadState CommonState.
- Added getCommonState, putCommonState, getsCommonState, modifyCommonState
  to PandocMonad interface.

- Removed MonadState CommonState instances.
2017-01-25 17:07:41 +01:00
John MacFarlane
40ac0cf133 Whitespace. 2017-01-25 17:07:41 +01:00
John MacFarlane
7d21238d62 RST reader: removed now unnecessary lifts. 2017-01-25 17:07:41 +01:00
John MacFarlane
931528dba6 Markdown reader: Removed readMarkdownWithWarnings [API change]. 2017-01-25 17:07:41 +01:00
John MacFarlane
8753a91252 Add PandocMonad m instance for ParserT based on PandocMonad.
This will avoid the need for lift.
2017-01-25 17:07:41 +01:00
John MacFarlane
e1d2da4c22 Have warningWithPos take a SourcePos rather than Maybe SourcePos.
After all, we have warning if you don't want the source pos info.
2017-01-25 17:07:41 +01:00
John MacFarlane
f1cec1dd02 LaTeX reader: add warning when parsing unescaped characters
that normally need escaping in LaTeX.
2017-01-25 17:07:40 +01:00
John MacFarlane
92cc80b58b RST reader: implement start-after, end-before fields for include. 2017-01-25 17:07:40 +01:00
John MacFarlane
03ede3e312 RST reader: handle code, literal, number-lines, class, name for include. 2017-01-25 17:07:40 +01:00
John MacFarlane
d595702b17 RST reader include: handle negative values for start-, end-line. 2017-01-25 17:07:40 +01:00
John MacFarlane
223dff4d29 RST reader: support start-line and end-line in include.
Just skip other options for now.
2017-01-25 17:07:40 +01:00
John MacFarlane
ad3ff342dd RST reader: Simple .. include:: support.
TODO: handle the options (see comment in code).
See #223.
2017-01-25 17:07:40 +01:00
Jesse Rosenthal
57cff4b8ae Class: Functions for dealing with PureState
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-25 17:07:40 +01:00
Jesse Rosenthal
15708f0b0f Class: rename env* prefixed fields to st*.
This was left over from when they were part of an environment.
2017-01-25 17:07:40 +01:00