Commit graph

358 commits

Author SHA1 Message Date
John MacFarlane
555f9b746d Moved MediaBag from Shared to Options.
This will allow us to put a MediaBag in WriterOptions.
2014-07-30 13:00:54 -07:00
John MacFarlane
d3cf53a956 Moved withTempDir from PDF to Shared, export from Shared.
API change.
2014-07-30 12:29:04 -07:00
Jesse Rosenthal
f78d2f6219 Shared: Make MediaBag available through Shared. 2014-07-30 12:47:26 -04:00
John MacFarlane
18f4490482 Fixed runtime error with compactify'DL on certain lists.
Closes #1452.  Added test.
2014-07-25 10:53:04 -07:00
John MacFarlane
5debb492ef Revert "Shared.hierarchicalize: Don't number subsections of unnumbered sections."
This reverts commit 2a46042661.
2014-07-21 20:47:18 -07:00
John MacFarlane
2a46042661 Shared.hierarchicalize: Don't number subsections of unnumbered sections.
They were previously numbered, starting from the previous numbered
section, which was wrong.
2014-07-21 12:35:11 -07:00
John MacFarlane
b80577b395 Shared.fetchItem: unescape URI encoding before reading local file.
Close #1427.
2014-07-15 12:17:45 -07:00
John MacFarlane
ea1bb4ed27 Better comment on removeFormatting. 2014-07-13 15:10:27 -07:00
John MacFarlane
5dba2e2192 Shared: Generalized type of removeFormatting. 2014-07-13 14:56:20 -07:00
John MacFarlane
172a184274 Shared: Added removeFormatting.
API change (addition of exported function).
2014-07-13 10:13:22 -07:00
John MacFarlane
4676bfdf82 Removed space at ends of lines in source. 2014-07-12 22:57:22 -07:00
John MacFarlane
8c7abf173a normalize: consolidate adjacent RawBlocks when possible. 2014-07-07 15:53:59 -06:00
John MacFarlane
3fbbafd391 Rewrote normalize for efficiency. (Closes #1385.)
* Added normalizeInlines, normalizeBlocks.
* Type signature is now more narrow, `Pandoc -> Pandoc` instead of
  `Data a :: a -> a`.  Some users may need to change their uses of
  `normalize` to the newly exported `normalizeInlines` or
  `normalizeBlocks`.
2014-06-29 23:05:08 -07:00
mpickering
7807564d44 Moved extractSpaces to Shared.hs
Generalised and move the extractSpaces function from `HTML.hs` to
`Shared.hs` so that the docx reader can also use it.
2014-06-16 20:45:54 +01:00
John MacFarlane
2a627f85fe Shared: Added ordNub.
API change (adds export).
2014-06-03 11:00:54 -07:00
John MacFarlane
ee8c8da8cc Removed dependency on conduit.
* http-conduit flag is now https.
* Instead of http-conduit, we depend on http-client and http-client-tls.
2014-05-18 22:07:00 -07:00
John MacFarlane
2348f07b11 Shared addMetaField: if old and new values both lists, concatenate. 2014-05-12 13:05:42 -07:00
Albert Krewinkel
8fdbef841d Update copyright notices for 2014, add missing notices 2014-05-09 00:46:08 +02:00
John MacFarlane
6a2361c457 Merge pull request #1256 from tarleb/org-reader-improvements
Org reader improvements
2014-04-19 20:35:41 -07:00
Albert Krewinkel
efebade38b Move compactify'DL from Markdown reader into Shared
The function `compactify'DL`, used to change the final definition item of a
definition list into a `Plain` iff all other items are `Plain`s as well, is
useful in many parsers and hence moved into Text.Pandoc.Shared.
2014-04-19 15:03:33 +02:00
John MacFarlane
7f036c0b57 Shared: Fixed bug in toRomanNumeral.
9 and numbers ending in 9 would end with "IXIV."
Thanks to Jesse Rosenthal.  Closes #1249.
2014-04-15 19:53:58 -07:00
John MacFarlane
c0309a60bc Shared.openURL: Set proxy with value of http_proxy env variable.
Note:  proxies with non-root paths are not supported,
because of limitations in http-conduit.

Closes #1211.
2014-04-05 10:58:32 -07:00
John MacFarlane
aada7b495b fetchItem: Handle image URLs beginning with '//'. 2014-01-08 12:04:08 -08:00
Henry de Valence
0c5e7cf8cb HLint: use elem and notElem
Replaces long conditional chains with calls to `elem` and `notElem`.
2013-12-19 20:19:24 -05:00
Henry de Valence
1ed2c467c9 HLint: Use all
Replace `and . map` with `all`.
2013-12-19 17:06:27 -05:00
John MacFarlane
142f81889b Added withSocketsDo around http conduit code in openURL.
This should address #1080, but further testing on Windows is needed
before we can close the bug.
2013-12-09 22:35:57 -08:00
Shaun Attfield
82813b5585 normalizeDate: Allow dates with year only (%Y) 2013-12-01 10:19:08 +02:00
John MacFarlane
83b9a66bf4 Shared: Fixed bug in openURL with data: URIs.
Previously the base-64 encoded bytestring was returned.
We now decode it so it's a proper image!

This should fix parsing of data: URLs.
2013-11-19 13:15:24 -08:00
John MacFarlane
386e933432 Use isURI instead of isAbsoluteURI.
It allows fragments identifiers.
2013-10-16 09:48:11 -07:00
John MacFarlane
dd5cb82348 Generalized type of stringify. 2013-08-28 08:43:51 -07:00
John MacFarlane
89a7703260 Shared: Changed stringify so it ignores notes.
Also documented this in README.
2013-08-16 13:22:27 -07:00
John MacFarlane
399c75da44 Revert "Shared: stringify now skips over footnotes."
This reverts commit 19591df739.

This change didn't work; query has already written the contents
of the note by the time it gets to Note.
2013-08-16 13:08:39 -07:00
John MacFarlane
19591df739 Shared: stringify now skips over footnotes.
That is usually the right thing to do for section labels, etc.
2013-08-16 13:05:06 -07:00
John MacFarlane
172f020bc5 Shared: Better error message when default data file not found.
Listing the full path can confuse people who are using
`--self-contained`:  they might have intended the file to be
found locally.  So now we just list the data file name.
2013-08-15 17:21:56 -07:00
John MacFarlane
e279175ea5 Options: Changed writerSourceDir to writerSourceURL (now a Maybe).
Previously we used to store the directory of the first input file,
even if it was local, and used this as a base directory for
finding images in ODT, EPUB, Docx, and PDF.

This has been confusing to many users.  It seems better to look for
images relative to the current working directory, even if the first
file argument is in another directory.

writerSourceURL is set to 'Just url' when the first command-line
argument is an absolute URL.  (So, relative links will be resolved
in relation to the first page.)  Otherwise, 'Nothing'.

The ODT, EPUB, Docx, and PDF writers have been modified accordingly.

Note that this change may break some existing workflows.  If you
have been assuming that relative links will be interpreted relative
to the directory of the first file argument, you'll need to
make that the current directory before running pandoc.

Closes #942.
2013-08-11 15:58:09 -07:00
John MacFarlane
02a125d0aa Use walk, walkM in place of bottomUp, bottomUpM when possible.
They are significantly faster.
2013-08-10 18:45:00 -07:00
John MacFarlane
9152fa1a95 Use query instead of queryWith. 2013-08-10 18:13:38 -07:00
John MacFarlane
7024664dda Fixed compilation with http-conduit flag False. 2013-07-30 08:38:13 -07:00
John MacFarlane
7c980f39bf Improved fetching of external resources.
* In Shared, openURL and fetchItem now return an Either, for
  better error handling. (API change.)
* Better error message when fetching a URL fails with
  `--self-contained`.
* EPUB writer: If resource not found, skip it, as in Docx writer.
* Closes #916.
2013-07-18 20:58:14 -07:00
John MacFarlane
ed714b1b52 cabal: Added http-conduit flag, which allows fetching https resources.
It also brings in a large number of dependencies (http-conduit and its
dependencies), which is why for now it is an optional flag.

Closes #820.
2013-07-04 23:13:37 -07:00
John MacFarlane
956425709d Created Text.Pandoc.Writers.Shared, improved metaToJSON.
* Text.Pandoc.Writers.Shared contains shared functions used
  only in writers.
* metaToJSON now takes a WriterOptions parameter, and will
  return an empty object if standalone is not specified.
2013-07-01 20:47:26 -07:00
John MacFarlane
55c8003e22 Shared: Export getField. 2013-07-01 16:28:22 -07:00
John MacFarlane
a1f010de78 Metadata changes: Variables now completely shadow metadata.
Previously if you set a value both in metadata and with a variable,
they'd be combined into a list.  Now the variable replaces the
value in document metadata.  If many variables with the same
name are set, a list is created.

Shared:  metaToJSON now has an argument for a variable list.
2013-06-29 22:14:01 -07:00
John MacFarlane
9ab60a4d15 Shared: Added defField.
`defField` is like `setField`, but does nothing if the
field already has a value.
2013-06-27 21:13:18 -07:00
John MacFarlane
16d6005ed9 Fixed merge bugs in Shared. 2013-06-25 18:15:22 -07:00
John MacFarlane
f34232c934 Removed 'Functor' constraint. 2013-06-25 17:41:15 -07:00
John MacFarlane
f869f7e08d Use new flexible metadata type.
* Depend on pandoc 1.12.
* Added yaml dependency.
* `Text.Pandoc.XML`: Removed `stripTags`.  (API change.)
* `Text.Pandoc.Shared`:  Added `metaToJSON`.
  This will be used in writers to create a JSON object for use
  in the templates from the pandoc metadata.
* Revised readers and writers to use the new Meta type.
* `Text.Pandoc.Options`: Added `Ext_yaml_title_block`.
* Markdown reader:  Added support for YAML metadata block.
  Note that it must come at the beginning of the document.
* `Text.Pandoc.Parsing.ParserState`:  Replace `stateTitle`,
  `stateAuthors`, `stateDate` with `stateMeta`.
* RST reader:  Improved metadata.
  Treat initial field list as metadata when standalone specified.
  Previously ALL fields "title", "author", "date" in field lists
  were treated as metadata, even if not at the beginning.
  Use `subtitle` metadata field for subtitle.
* `Text.Pandoc.Templates`:  Export `renderTemplate'` that takes a string
  instead of a compiled template..
* OPML template:  Use 'for' loop for authors.
* Org template: '#+TITLE:' is inserted before the title.
  Previously the writer did this.
2013-06-24 20:29:41 -07:00
John MacFarlane
0a6e9f048a Shared.openURL: Properly handle data: URIs. 2013-05-28 12:48:17 -07:00
John MacFarlane
f63129040b Less verbose output from --self-contained.
Now one gets "Fetching [URL]..." for each URL fetched, but not
the full header.
2013-05-04 21:53:06 -07:00
John MacFarlane
effc6a9ed4 Shared.openURL: Print diagnostic output to stderr, not stdout. 2013-05-01 10:55:06 -07:00