Commit graph

5117 commits

Author SHA1 Message Date
Albert Krewinkel
514662e544
Org reader: support \n export option
The `\n` export option turns all newlines in the text into hard
linebreaks.

Closes #3950
2017-10-02 23:11:58 +02:00
John MacFarlane
3e77ea4792 Lua: added 'pipe', which encapsulates Text.Pandoc.Process.pipeProcess.
This is hard to do in lua, so it's helpful to provide this.
2017-10-01 15:23:20 -07:00
John MacFarlane
4c3b3bf65a Lua: move sha1 from pandoc.mediabag to pandoc. 2017-10-01 00:33:56 -07:00
John MacFarlane
8768f7e5b0 Lua: use sha1 instead of hashname.
Better to leave control over the extension to the user.
2017-09-30 23:15:43 -07:00
John MacFarlane
9451d83058 Lua: make fetch return mime type first and then content. 2017-09-30 23:00:14 -07:00
John MacFarlane
17583cd99d Lua: simply mediabag module.
Now 'fetch' simply fetches content and mime type.
A new 'hashname' function is provided to get a filename based
on the sha1 hash of the contents and the mime type.
2017-09-30 22:54:12 -07:00
John MacFarlane
73c47a44d8 Lua: make lua.mediabag.fetch return filename and mime type.
This is necessary because you may need to insert the filename
into an image or link element.
2017-09-30 21:58:35 -07:00
John MacFarlane
896c288625 Lua filters: make sure whole CommonState is passed through...
to insertResource (`fetch`).
2017-09-30 17:20:44 -05:00
John MacFarlane
99aba1e788 EPUB writer: simplified some functions. 2017-09-30 17:19:07 -05:00
John MacFarlane
9004da4587 Removed unneeded import. 2017-09-30 17:18:37 -05:00
John MacFarlane
dfe816163c Removed Verbosity and MediaBag params from makePDF.
They can be obtained from CommonState since we're
in PandocIO.
2017-09-30 17:17:39 -05:00
John MacFarlane
9ec458f39f Text.Pandoc.Class - add getVerbosity. 2017-09-30 17:15:55 -05:00
John MacFarlane
f3a80034ff Removed writerSourceURL, add source URL to common state.
Removed `writerSourceURL` from `WriterOptions` (API change).
Added `stSourceURL` to `CommonState`.
It is set automatically by `setInputFiles`.

Text.Pandoc.Class now exports `setInputFiles`, `setOutputFile`.

The type of `getInputFiles` has changed; it now returns `[FilePath]`
instead of `Maybe [FilePath]`.

Functions in Class that formerly took the source URL as a parameter
now have one fewer parameter (`fetchItem`, `downloadOrRead`,
`setMediaResource`, `fillMediaBag`).

Removed `WriterOptions` parameter from `makeSelfContained` in
`SelfContained`.
2017-09-30 16:11:20 -05:00
Albert Krewinkel
358e8c2897
Run Lua filters before extracting media
This enables users to change the media files being extracted via lua
filters.
2017-09-30 09:57:03 +02:00
Albert Krewinkel
2f47e04206
Text.Pandoc.Lua: add mediabag submodule 2017-09-30 09:57:03 +02:00
Andrie de Vries
2f03f389e8 Support R filters #3940 (#3941) 2017-09-28 08:48:42 -07:00
Alexander Krotov
b5d064e8f0 Muse reader: parse anchors 2017-09-28 14:57:24 +03:00
John MacFarlane
2314534d4d RST writer: add header anchors when header has non-standard id.
Closes #3937.
2017-09-27 20:42:04 -07:00
John MacFarlane
9a47c7863b Lua filters: set global FORMAT instead of args.
This changes the type of runLuaFilter.
2017-09-26 20:20:09 -07:00
John MacFarlane
3fe4aad5a1 Lua: set "arg" instead of "PandocParameters".
This is standard for lua scripts, and I see no reason
to depart from the standard here.

Also, "arg" is now pushed onto the stack before the script
is loaded.  Previously it was not, and thus "PandocParameters"
was not available at the top level.
2017-09-26 10:07:15 -07:00
Alexander Krotov
2cdb8fe2e6 Muse reader: test metadata parsing 2017-09-26 19:31:10 +03:00
Alexander Krotov
3fb3af7579 Fix a typo: s/collabarators/collaborators/ 2017-09-26 18:28:40 +03:00
Albert Krewinkel
3a7663281a
Org reader: update emphasis border chars
The org reader was updated to match current org-mode behavior: the set
of characters which are acceptable to occur as the first or last
character in an org emphasis have been changed and now allows all
non-whitespace chars at the inner border of emphasized text (see
`org-emphasis-regexp-components`).

Fixes: #3933
2017-09-25 09:31:29 +02:00
Albert Krewinkel
71f69cd086 Allow lua filters to return lists of elements
Closes: #3918
2017-09-24 12:04:15 -07:00
John MacFarlane
e87db3739e Fixed bug in determining writer for xelatex engine.
This revises the last commit, fixing #3931.
2017-09-20 11:45:26 -07:00
John MacFarlane
582cb4b505 Fix and simply latex engine code in App.
Fixes #3931.
2017-09-19 17:22:32 -07:00
John MacFarlane
b1ee747a24 Added --strip-comments option, readerStripComments in ReaderOptions.
* Options:  Added readerStripComments to ReaderOptions.
* Added `--strip-comments` command-line option.
* Made `htmlTag` from the HTML reader sensitive to this feature.

This affects Markdown and Textile input.

Closes #2552.
2017-09-17 13:01:27 -07:00
John MacFarlane
86730f49be Markdown reader: added inlines, inlines1.
Eventually we'll add `processEmphasis` and `processBracketed`
to this.

This will allow us to conform to CommonMark rules and
fix #3903 and #1735.
2017-09-16 11:10:19 -07:00
John MacFarlane
684f055248 Set PANDOC_READER_OPTIONS in environment where filters are run.
This contains a JSON representation of ReaderOptions.
2017-09-15 17:26:14 -07:00
John MacFarlane
b1aa67f0c9 Remove To/FromJSON instance for WriterOptions.
This required the (now removed) instances for Syntax.
It was too long, anyway, to be of use.
2017-09-15 09:36:23 -07:00
John MacFarlane
64472a468c FromJSON/ToJSON instances for Reader, WriterOptions.
Depends on skylighting 0.3.5.
2017-09-14 22:38:23 -07:00
John MacFarlane
4177ee8626 Textile reader: allow 'pre' code in list item.
Closes #3916.
2017-09-12 08:58:47 -07:00
John MacFarlane
b71c7d97d1 Add default pdf engine for beamer. 2017-09-12 08:28:04 -07:00
John MacFarlane
6509501e90 Use defaultLatexEngine instead of head latexEngines.
Partial functions make me nervous.
2017-09-12 08:25:41 -07:00
Mauro Bieg
c7e3c1ec17 Support for PDF generation via weasyprint and prince (#3909)
* Rename --latex-engine to --pdf-engine
* In `Text.Pandoc.Options.WriterOptions`, rename `writerLaTeXEngine` to `writerPdfEngine` and `writerLaTeXArgs` to `writerPdfArgs`.
 * Add support for `weasyprint` and `prince`, in addition to `wkhtmltopdf`, for PDF generation via HTML (closes #3906).
* `Text.Pandoc.PDF.html2pdf`: use stdin instead of intermediate HTML file
2017-09-11 20:18:42 -07:00
John MacFarlane
ddecd72783 Merge pull request #3911 from labdsf/muse-reader-braces
Muse reader: parse {{{ }}} example syntax
2017-09-11 14:01:05 -07:00
Alexander Krotov
8e4ee66563 Muse reader: allow inline markup to be followed by punctuation
Previously code was not allowed to be followed by comma,
and emphasis was allowed to be followed by letter.
2017-09-11 18:34:32 +03:00
Alexander Krotov
508c3a64d8 Muse reader: parse {{{ }}} example syntax 2017-09-11 18:17:28 +03:00
Alexander Krotov
27cccfac84 Muse reader: parse verbatim tag 2017-09-11 12:13:09 +03:00
Alexander Krotov
afedb41b17 Muse reader: trim newlines from <example>s 2017-09-10 12:42:24 +03:00
Alexander Krotov
2230371304 Muse reader: debug inline code markup 2017-09-09 16:39:06 +03:00
Andrew Dunning
621e43e0ec Write euro symbol directly in LaTeX
The textcomp package allows pdfLaTeX to parse `€` directly, making the \euro command unneeded. Closes #3801.
2017-09-08 22:26:32 +01:00
John MacFarlane
3421f3eac7 Removed old beamer template.
We now use the default.latex template for both latex and beamer.
It contains conditionals for the beamer-specific things.

`pandoc -D beamer` will return this template.
2017-09-08 10:48:02 -07:00
John MacFarlane
5fc4980216 Markdown writer: Escape pipe characters when pipe_tables enabled.
Closes #3887.
2017-09-07 22:10:13 -07:00
John MacFarlane
a90f131937 LaTeX writer: use proper code for list enumerators.
This should fix problems with lists that don't use arabic
numerals.

Closes #3891.
2017-09-07 22:05:22 -07:00
Alexander
743413a5b5 Muse reader: Allow finishing header with EOF (#3897) 2017-09-06 08:48:06 -07:00
John MacFarlane
0b05222a9c LaTeX reader: Better support for ogonek accents. 2017-09-05 13:54:44 -07:00
John MacFarlane
bc5624dac2 Markdown writer: make Span with null attribute transparent.
That is, we don't use brackets or `<span>` tags to mark
spans when there are no attributes; we simply output the
contents.
2017-09-05 13:46:44 -07:00
John MacFarlane
d62c4a9247 LaTeX reader: Improve handling of accents.
Handle ogonek, and fall back correctly with forms like `\"{}`.
2017-09-05 10:58:34 -07:00
John MacFarlane
146a10780e LaTeX reader: support \k ogonek accent. 2017-09-05 09:55:42 -07:00
Alexander
350c282f20 Muse reader: require at least one space char after * in header (#3895) 2017-09-05 09:41:27 -07:00
John MacFarlane
9fdc089cd8 Plain writer: don't use &nbsp; to separate list and indented code.
There's no need for it in this context, since this isn't
to be interpreted using Markdown rules.
2017-09-04 21:56:06 -07:00
Alexander
c09b586147 Muse reader: parse <div> tag (#3888) 2017-09-04 21:22:40 -07:00
John MacFarlane
1d0805ce41 HTML reader: Fix pattern match. 2017-09-04 18:11:26 -07:00
Albert Krewinkel
6a6c3858b4
Org writer: stop using raw HTML to wrap divs
Div's are difficult to translate into org syntax, as there are multiple
div-like structures (drawers, special blocks, greater blocks) which all
have their advantages and disadvantages.  Previously pandoc would
use raw HTML to preserve the full div information; this was rarely
useful and resulted in visual clutter.  Div-rendering was changed to
discard the div's classes and key-value pairs if there is no natural way
to translate the div into an org structure.

Closes: #3771
2017-09-01 00:08:12 +02:00
John MacFarlane
50ec64ffbc HTML reader: improved handling of figure.
Previously we had a parse failure if the figure contained
anything besides an image and caption.
2017-08-30 17:05:12 -07:00
Alexander
14f813c3f2 Muse reader: parse verse markup (#3882) 2017-08-29 12:40:34 -07:00
Alexander
2d936ff4e0 hlint Muse reader (#3884) 2017-08-29 09:15:06 -07:00
John MacFarlane
22a4adf4ec Add a type sig to satisfy ghc 7.10.3. 2017-08-29 09:04:59 -07:00
John MacFarlane
2e26046e13 HTML writer: ensure we don't get two style attributes for width & height. 2017-08-28 23:33:21 -07:00
Alexander
05bb8ef4aa RST reader: handle blank lines correctly in line blocks (#3881)
Previously pandoc would sometimes combine two line blocks separated by blanks, and ignore trailing blank lines within the line block.

Test is checked to be consisted with http://rst.ninjs.org/
2017-08-28 07:48:46 -07:00
John MacFarlane
8fcf66453c RST reader: Fixed ..include:: directive.
Closes #3880.
2017-08-27 17:09:55 -07:00
John MacFarlane
6437695574 Markdown writer: don't crash on Str "". 2017-08-26 21:30:00 -07:00
John MacFarlane
1b3431a165 LaTeX reader: improved support for \hyperlink, \hypertarget.
Closes #2549.
2017-08-25 22:04:57 -07:00
Alexander
e6f767b581 Muse reader: parse <verse> tag (#3872) 2017-08-25 07:09:28 -07:00
bucklereed
c80e26f888 LaTeX reader: RN and Rn, from biblatex (#3854) 2017-08-24 09:45:58 -07:00
Albert Krewinkel
f8dce4a9e3
Text.Pandoc.Lua: fix fallback functions with GHC 7.8 2017-08-23 09:43:49 +02:00
Alexander
5d74932578 Muse reader: avoid crashes on multiparagraph inline tags (#3866)
Test checks that behavior is consistent with Amusewiki
2017-08-22 23:12:34 -07:00
Alexander
c7d4fd8cf1 Muse reader: do not allow closing tags with EOF (#3863)
This behavior is compatible to Amusewiki
2017-08-22 16:34:18 -07:00
Albert Krewinkel
41baaff327
Text.Pandoc.Lua: support Inline and Block catch-alls
Try function `Inline`/`Block` if no other filter function of the
respective type matches an element.

Closes: #3859
2017-08-22 23:30:48 +02:00
Albert Krewinkel
56fb854ad8
Text.Pandoc.Lua: respect metatable when getting filters
This change makes it possible to define a catch-all function using lua's
metatable lookup functionality.

    function catch_all(el)
      …
    end

    return {
      setmetatable({}, {__index = function(_) return catch_all end})
    }

A further effect of this change is that the map with filter functions
now only contains functions corresponding to AST element constructors.
2017-08-22 22:56:51 +02:00
Alexander
0a839cbdc9 Muse reader: add definition list support (#3860) 2017-08-21 21:08:44 -07:00
John MacFarlane
9cc128b579 LaTeX reader: Set identifiers on Spans used for \label. 2017-08-20 16:52:03 -07:00
John MacFarlane
f2fdd275fd LaTeX reader: allow ] inside group in option brackets.
Closes #3857.
2017-08-20 13:42:43 -07:00
John MacFarlane
e334d7dc38 Protect OVERLAPS pragma with CPP. 2017-08-20 11:13:42 -07:00
John MacFarlane
ba3088f0b3 Use OverlappingInstances instead of OVERLAPS for ghc 7.8.4. 2017-08-20 10:43:31 -07:00
John MacFarlane
40d1246629 Removed redundant import. 2017-08-20 09:37:18 -07:00
John MacFarlane
8b8c94552f Simplify instances in Class by parameterizing on MonadTrans. 2017-08-19 16:39:22 -07:00
John MacFarlane
a31241a08b Markdown reader: use CommonMark rules for list item nesting.
Closes #3511.

Previously pandoc used the four-space rule: continuation paragraphs,
sublists, and other block level content had to be indented 4
spaces.  Now the indentation required is determined by the
first line of the list item:  to be included in the list item,
blocks must be indented to the level of the first non-space
content after the list marker. Exception: if are 5 or more spaces
after the list marker, then the content is interpreted as an
indented code block, and continuation paragraphs must be indented
two spaces beyond the end of the list marker.  See the CommonMark
spec for more details and examples.

Documents that adhere to the four-space rule should, in most cases,
be parsed the same way by the new rules.  Here are some examples
of texts that will be parsed differently:

    - a
      - b

will be parsed as a list item with a sublist; under the four-space
rule, it would be a list with two items.

    - a

          code

Here we have an indented code block under the list item, even though it
is only indented six spaces from the margin, because it is four spaces
past the point where a continuation paragraph could begin.  With the
four-space rule, this would be a regular paragraph rather than a code
block.

    - a

            code

Here the code block will start with two spaces, whereas under
the four-space rule, it would start with `code`.  With the four-space
rule, indented code under a list item always must be indented eight
spaces from the margin, while the new rules require only that it
be indented four spaces from the beginning of the first non-space
text after the list marker (here, `a`).

This change was motivated by a slew of bug reports from people
who expected lists to work differently (#3125, #2367, #2575, #2210,
 #1990, #1137, #744, #172, #137, #128) and by the growing prevalance
of CommonMark (now used by GitHub, for example).

Users who want to use the old rules can select the `four_space_rule`
extension.

* Added `four_space_rule` extension.
* Added `Ext_four_space_rule` to `Extensions`.
* `Parsing` now exports `gobbleAtMostSpaces`, and the type
  of `gobbleSpaces` has been changed so that a `ReaderOptions`
  parameter is not needed.
2017-08-19 15:45:01 -07:00
John MacFarlane
5ab1162def Markdown reader: fixed parsing of fenced code after list...
...when there is no intervening blank line.

Closes #3733.
2017-08-18 21:46:55 -07:00
John MacFarlane
7cac58f126 Markdown reader: parse -@roe as suppress-author citation.
Previously only `[-@roe]` (with brackets) was recognized as
suppress-author, and `-@roe` was treated the same as `@roe`.

Closes jgm/pandoc-citeproc#237.
2017-08-18 11:40:57 -07:00
John MacFarlane
bfbdfa646a LaTeX reader: implement \newtoggle, \iftoggle, \toggletrue|false
from etoolbox.

Closes #3853.
2017-08-18 10:13:41 -07:00
John MacFarlane
d1444b4ecd RST reader/writer: support unknown interpreted text roles...
...by parsing them as Span with "role" attributes.
This way they can be manipulated in the AST.

Closes #3407.
2017-08-17 16:01:44 -07:00
John MacFarlane
b1f6fb4af5 HTML reader: support column alignments.
These can be set either with a `width` attribute or
with `text-width` in a `style` attribute.

Closes #1881.
2017-08-17 12:08:32 -07:00
John MacFarlane
b9b35059f6 LaTeX reader: support \lq, \rq. 2017-08-17 12:08:32 -07:00
ickc
2a0e2e6fd6 slidy uses https instead of http (#3848)
grep -rl 'http://www.w3.org/Talks/Tools/Slidy2' . | xargs sed -i 's/http:\/\/www\.w3\.org\/Talks\/Tools\/Slidy2/https:\/\/www\.w3\.org\/Talks\/Tools\/Slidy2/g'
2017-08-17 10:11:49 -07:00
John MacFarlane
c175317d03 LaTeX reader: support \textquoteleft|right, \textquotedblleft|right.
Closes #3849.
2017-08-17 10:09:35 -07:00
John MacFarlane
ae61d5f57d LaTeX reader: rudimentary support for \hyperlink. 2017-08-16 10:56:16 -07:00
John MacFarlane
db715ca847 LaTeX reader: use Link instead of Span for \ref.
This makes more sense semantically and avoids unnecessary
Span [Link] nestings when references are resolved.
2017-08-16 10:56:12 -07:00
John MacFarlane
c6ec189a96 Revision to binary format output to stdout:
We now allow default output to stdout when it can be
determined that the output is being piped.  (On Windows,
as mentioned before, this can't be determined.)

Using '-o -' forces output to stdout regardless.
2017-08-16 10:39:34 -07:00
schrieveslaach
cf4b40162d LaTeX reader: add Support for glossaries and acronym package (#3589)
Acronyms are not resolved by the reader, but acronym and glossary information is put into attributes on Spans so that they can be processed in filters.
2017-08-16 10:24:46 -07:00
John MacFarlane
708bb8afe4 Fix import in PDF. 2017-08-16 10:13:16 -07:00
John MacFarlane
61cf3affa9 Change behavior with binary format output to stdout.
Previously, for binary formats, output to stdout was disabled
unless we could detect that the output was being piped (and not
sent to the terminal).  Unfortunately, such detection is not
possible on Windows, leaving windows users no way to pipe binary
output.  So we have changed the behavior in the following way:

* If the -o option is not used, binary output is never sent
  to stdout by default; instead, an error is raised.
* IF '-o -' is used, binary output is sent to stdout, regardless
  of whether it is being piped. This works on Windows too.
2017-08-16 09:45:12 -07:00
Albert Krewinkel
9b31835530 Update to hslua-0.8.0
hslua no longer provides lua stack instances for Int and Double, the
necessary instances are added to the Custom writer and the lua filtering
system.
2017-08-16 15:47:05 +02:00
John MacFarlane
f8b6a224ae Remove initial check for pdf creating program.
Instead, just try running it and raise the exception if it
isn't found at that point.

This improves things for users of Cygwin on Windows, where
the executable won't be found by `findExecutable` unless
`.exe` is added.

The same exception is raised as before, but at a later
point.

Closes #3819.
2017-08-15 21:17:20 -07:00
John MacFarlane
97fe6c35b5 Docx writer: fixed a regression (infinite loop on certain lists).
Bug was introduced by commit a868b238f2.
2017-08-15 14:05:10 -07:00
John MacFarlane
892a4edeb1 Implement multicolumn support for slide formats.
The structure expected is:

    <div class="columns">
      <div class="column" width="40%">
        contents...
      </div>
      <div class="column" width="60%">
        contents...
      </div>
    </div>

Support has been added for beamer and all HTML slide formats.

Closes #1710.

Note:  later we could add a more elegant way to create
this structure in Markdown than to use raw HTML div elements.
This would come for free with a "native div syntax" (#168).
Or we could devise something specific to slides
2017-08-14 23:17:44 -07:00
John MacFarlane
6aef1bd228 Better handle complex \def macros as raw latex. 2017-08-13 12:45:04 -07:00
John MacFarlane
425b731050 LaTeX reader: Allow @ as a letter in control sequences.
@ is commonly used in macros using `\makeatletter`.
Ideally we'd make the tokenizer sensitive to `\makeatletter`
and `\makeatother`, but until then this seems a good change.
2017-08-13 12:24:06 -07:00
John MacFarlane
bf9ec6dfd8 LaTeX reader: fix \let\a=0 case, with single character token. 2017-08-13 12:16:51 -07:00
John MacFarlane
f9656ece4e Resolve references to section numbers in LaTeX reader. 2017-08-13 11:48:44 -07:00
John MacFarlane
253a7c6201 LaTeX reader: track header numbers and correlate with labels. 2017-08-13 11:30:17 -07:00
schrieveslaach
2845ab5976 Put content of \ref, \label commands into span… (#3639)
* Put content of `\ref` and `\label` commands into Span elements so they can be used in filters.
* Add support for `\eqref`
2017-08-13 10:58:45 -07:00
John MacFarlane
8f65590ce9 CommonMark writer: prefer pipe tables to HTML tables...
...even if it means losing relative column width information.
See #3734.
2017-08-13 10:43:43 -07:00
John MacFarlane
506866ef73 Markdown writer: Use pipe tables if raw_html disabled...
and `pipe_tables` enabled, even if the table has relative
width information.

Closes #3734.
2017-08-13 10:37:24 -07:00
John MacFarlane
39066eba1d Added some Functor constraints needed for ghc 7.8. 2017-08-13 10:00:46 -07:00
Albert Krewinkel
3d87e2080a
Delete Text.Pandoc.Lua.SharedInstances
Stack instances for common data types are now provides by hslua. The
instance for Either was useful only for a very specific case; the
function that was using the `ToLuaStack Either` instance was rewritten
to work without it.

Closes: #3805
2017-08-13 17:48:43 +02:00
Albert Krewinkel
6e6cee454e Text.Pandoc.Lua: cleanup element walking code
WalkM is general enough to work in any monad, not just IO. Also get rid
of the LuaException type, sufficient to use the one defined in hslua.
2017-08-13 17:24:17 +02:00
Albert Krewinkel
b9c7adf02e
Text.Pandoc.Lua: Optimize performance by using raw table access
Raw table accessing functions never call back into haskell, which allows
the compiler to use more aggressive optimizations. This improves lua
filter performance considerably (⪆5% speedup).
2017-08-13 14:25:36 +02:00
Albert Krewinkel
2dc3dbd68b Use hslua >= 0.7, update Lua code 2017-08-13 14:23:54 +02:00
John MacFarlane
418bda8128 Docx writer: pass through comments.
We assume that comments are defined as parsed by the
docx reader:

    I want <span class="comment-start" id="0" author="Jesse Rosenthal"
    date="2016-05-09T16:13:00Z">I left a comment.</span>some text to
    have a comment <span class="comment-end" id="0"></span>on it.

We assume also that the id attributes are unique and properly
matched between comment-start and comment-end.

Closes #2994.
2017-08-12 22:59:53 -07:00
John MacFarlane
be9957bddc Escape MetaString values (as added with --metadata flag).
Previously they would be transmitted to the template without
any escaping.

Note that `--M title='*foo*'` yields a different result from

    ---
    title: *foo*
    ---

In the latter case, we have emphasis; in the former case, just
a string with literal asterisks (which will be escaped
in formats, like Markdown, that require it).

Closes #3792.
2017-08-12 20:27:42 -07:00
John MacFarlane
0ab8670a0e LaTeX reader: Fixed space after \figurename etc. 2017-08-12 13:40:28 -07:00
John MacFarlane
3897df868a LaTeX reader: support \chaptername, \partname, \abstractname, etc.
See #3559.
Obsoletes #3560.
2017-08-12 13:28:18 -07:00
John MacFarlane
f7346bbfc1 Added Listing to Term.
So far only added to English.
2017-08-12 13:19:50 -07:00
John MacFarlane
78e61cedd0 Added Encl, Glossary to Term 2017-08-12 13:14:27 -07:00
John MacFarlane
f035f0ffe3 LaTeX reader: have \setmainlanguage set lang in metadata. 2017-08-12 12:34:36 -07:00
John MacFarlane
444f8e9569 Improved error report on loading translation file. 2017-08-12 12:25:33 -07:00
John MacFarlane
622c3f2fa6 Change to yaml for translation files. 2017-08-12 12:17:38 -07:00
John MacFarlane
b6e0add76a Set user data dir at beginning, so readDataFile has access to it. 2017-08-12 12:15:40 -07:00
John MacFarlane
95f7dc6573 Fixed import. 2017-08-11 23:57:35 -07:00
John MacFarlane
1002178752 More redundant imports. 2017-08-11 23:24:55 -07:00
John MacFarlane
b3bb9a4384 Avoid some warnings when compiled wo/ embed_data_files flag. 2017-08-11 23:11:37 -07:00
John MacFarlane
6c5952e746 Add getFileName to PandocMonad.
We need this for getDefaultDataFile.
2017-08-11 23:09:51 -07:00
John MacFarlane
2c85c678f2 Removed redundant import. 2017-08-11 22:26:23 -07:00
John MacFarlane
74212eb1b0 Added support for translations (localization) (see #3559).
* readDataFile, readDefaultDataFile, getReferenceDocx,
  getReferenceODT have been removed from Shared and
  moved into Class.  They are now defined in terms of
  PandocMonad primitives, rather than being primitve
  methods of the class.

* toLang has been moved from BCP47 to Class.

* NoTranslation and CouldNotLoudTranslations have
  been added to LogMessage.

* New module, Text.Pandoc.Translations, exporting
  Term, Translations, readTranslations.

* New functions in Class: translateTerm, setTranslations.
  Note that nothing is loaded from data files until
  translateTerm is used; setTranslation just sets the
  language to be used.

* Added two translation data files in data/translations.

* LaTeX reader: Support `\setmainlanguage` or `\setdefaultlanguage`
  (polyglossia) and `\figurename`.
2017-08-11 22:22:31 -07:00
John MacFarlane
0283616a4a Remove writerUserDataDir from WriterOptions.
It is now carried in CommonState in PandocMonad instances.
(And thus it can be used by readers too.)
2017-08-10 23:46:59 -07:00
John MacFarlane
737d09e325 Removed datadir param from readDataFile and getDefaultTemplate.
In Text.Pandoc.Class and Text.Pandoc.Template, resp.
We now get the datadir from CommonState.
2017-08-10 23:37:44 -07:00
John MacFarlane
13abd97ac0 Class: add setUserDataDir and getUserDataDir.
* Add stUserDataDir to CommonState.
* Rename stUserDataDir/stCabalDataDir in PureState to
  stUserDataFiles/stCabalDataFiles.
2017-08-10 23:16:10 -07:00
John MacFarlane
6aaf8f4770 Expose getDefaultDataFile in both Shared and Class. 2017-08-10 23:04:14 -07:00
John MacFarlane
dee4cbc854 RST reader: implement csv-table directive.
Most attributes are supported, including `:file:` and `:url:`.
A (probably insufficient) test case has been added.

Closes #3533.
2017-08-10 15:01:14 -07:00
John MacFarlane
a5790dd308 RST reader: Basic support for csv-table directive.
* Added Text.Pandoc.CSV, simple CSV parser.
* Options still not supported, and we need tests.

See #3533.
2017-08-10 11:12:41 -07:00
John MacFarlane
e9eaf84215 Slidy writer: use h1 for all slides...
even if they were originally level 2 headers.
Otherwise the built-in table of contents in Slidy breaks.

Closes #3566.
2017-08-10 07:48:28 -07:00
John MacFarlane
f4bff5d359 RST reader: reorganize block parsers for ~20% faster parsing. 2017-08-09 21:16:17 -07:00
John MacFarlane
8c1ae7ddaf RST writer: don't wrap term in definition list.
Wrapping is not allowed.
2017-08-09 20:59:25 -07:00
John MacFarlane
1dcecffef4 Removed spurious comments. 2017-08-09 20:53:42 -07:00
John MacFarlane
2581f97620 EPUB writer: don't strip formatting in TOC.
Closes #1611.
2017-08-09 18:02:38 -07:00
John MacFarlane
6b72c5e35b Support svg in PDF output, converting with rsvg2pdf.
Closes #1793.
2017-08-09 12:13:49 -07:00
John MacFarlane
ac18ff90b2 Org reader: use org-language attribute rather than data-org-language. 2017-08-09 09:45:17 -07:00
John MacFarlane
96933c6043 Org reader: use tag-name attribute instead of data-tag-name. 2017-08-09 09:26:57 -07:00
John MacFarlane
09b7df472d LaTeX reader: Use label instead of data-label for label in caption.
See d441e656db, #3639.
2017-08-09 09:15:50 -07:00
bucklereed
db55f7c1b2 HTML reader: parse <main> like <div role=main>. (#3791)
* HTML reader: parse <main> like <div role=main>.

* <main> closes <p> and behaves like a block element generally
2017-08-09 09:10:12 -07:00
Alexander
cfa597fc2a Muse reader: simplify tableCell implementation (#3846) 2017-08-09 09:09:05 -07:00
John MacFarlane
606a8e2af4 RST reader: support :widths: attribute for table directive. 2017-08-08 20:48:30 -07:00
John MacFarlane
34d3f25e87 Parsing: added gobbleSpaces.
This is a utility function to use in list parsing.
2017-08-08 20:07:06 -07:00
John MacFarlane
b1c2ada4e4 Removed redundant import. 2017-08-08 16:46:12 -07:00
Alexander
b50de96502 Muse writer: insert two blanklines between lists of the same type (#3844) 2017-08-08 14:05:49 -07:00
John MacFarlane
a1cd7c3bfd Templates: Have gfm use commonmark template. 2017-08-08 14:05:04 -07:00
John MacFarlane
1ad9679dc9 CommonMark writer: avoid excess blank lines at end of output. 2017-08-08 14:00:13 -07:00
John MacFarlane
3752298d91 Thread options through CommonMark reader.
This is more efficient than doing AST traversals for
emojis and hard breaks.

Also make behavior sensitive to `raw_html` extension.
2017-08-08 13:55:19 -07:00
John MacFarlane
54658b923a Support hard_line_breaks in CommonMark reader. 2017-08-08 13:30:53 -07:00
John MacFarlane
b6f7c4930b CommonMark writer: support hard_line_breaks, smart.
Add tests.
2017-08-08 13:18:27 -07:00
John MacFarlane
ccd4f13a4a Writers.Shared.unsmartify: undo literal double curly quotes.
Previously we left these.
2017-08-08 13:16:45 -07:00
John MacFarlane
714d8a6377 CommonMark reader: support emoji extension. 2017-08-08 12:05:20 -07:00
John MacFarlane
73caf92871 CommonMark reader: support gfm_auto_identifiers.
Added `Ext_gfm_auto_identifiers`: new constructor for `Extension`
in `Text.Pandoc.Extensions` [API change].

Use this in githubExtensions.

Closes #2821.
2017-08-08 11:43:35 -07:00
John MacFarlane
312349bbcc CommonMark writer: Support pipe tables.
We bypass the commonmark writer from cmark and construct our
own pipe tables, with better results.  (Note also that cmark-gfm
currently doesn't support rendering table nodes; see
kivikakk/cmark-gfm-hs#3.)
2017-08-08 11:01:05 -07:00
John MacFarlane
56a680c305 CommonMark writer: support table, strikethrough extensions...
when enabled (as with gfm).  Note: because of limitations in
cmark-gfm, which will hopefully soon be corrected, this currently
gives an error on Tables.

Also properly support `--wrap=none`.
2017-08-08 09:14:13 -07:00
Alexander
c95cc813cc Fix `blanklines' documentation (#3843) 2017-08-08 08:44:18 -07:00
John MacFarlane
d752f85582 CommonMark reader: make exts depend on extensions. 2017-08-07 23:20:29 -07:00
John MacFarlane
91c989d622 Remove GFM modules; use CMarkGFM for both gfm and commonmark.
We no longer have a separate readGFM and writeGFM;
instead, we'll use readCommonMark and writeCommonMark
with githubExtensions.

It remains to implement these extensions conditionally.

Closes #3841.
2017-08-07 23:11:14 -07:00
John MacFarlane
6a9db1fde3 Issue deprecation warning for markdown_github.
Advise to use `gfm` instead.
2017-08-07 22:34:38 -07:00
John MacFarlane
834e9498f9 Logging: Added Deprecated constructor to LogMessage. 2017-08-07 22:34:23 -07:00
John MacFarlane
3bf11cae27 Man writer: removed some unneeded imports. 2017-08-07 22:04:08 -07:00
John MacFarlane
ea6be2e4e7 Added Deprecated warning to LogMessage. 2017-08-07 21:25:07 -07:00
John MacFarlane
5064241b24 Man writer: avoid error for def lists with no definitions.
Closes #3832.
2017-08-07 21:18:50 -07:00
John MacFarlane
2c0e989f9d Markdown reader: fixed spurious parsing as citation as reference def.
We now disallow reference keys starting with `@` if the
`citations` extension is enabled.  Closes #3840.
2017-08-07 21:00:57 -07:00
John MacFarlane
fd23b6dbce Revert "Logging: Made SkippedContent an INFO level message..."
This reverts commit 8995281691.
2017-08-07 17:07:20 -07:00
John MacFarlane
2c81c4c218 Added gfm (GitHub-flavored CommonMark) as an input and output format.
This uses bindings to GitHub's fork of cmark, so it should parse
gfm exactly as GitHub does (excepting certain postprocessing
steps, involving notifications, emojis, etc.).

* Added Text.Pandoc.Readers.GFM (exporting readGFM)
* Added Text.Pandoc.Writers.GFM (exporting writeGFM)
* Added `gfm` as input and output forma

Note that tables are currently always rendered as HTML
in the writer; this can be improved when CMarkGFM supports
tables in output.
2017-08-07 16:59:31 -07:00
John MacFarlane
8995281691 Logging: Made SkippedContent an INFO level message...
rather than WARNING.
2017-08-07 16:53:59 -07:00
John MacFarlane
190f36d2fd Small tweak to previous commit. 2017-08-07 16:11:13 -07:00
John MacFarlane
c806ef1b15 LaTeX reader: Support simple \def macros.
Note that we still don't support macros with fancy parameter
delimiters, like

    \def\foo#1..#2{...}
2017-08-07 16:06:19 -07:00
John MacFarlane
9e6b9cdc5f LaTeX reader: Support \let.
Also, fix regular macros so they're expanded at the
point of use, and NOT also the point of definition.
`\let` macros, by contrast, are expanded at the
point of definition.  Added an `ExpansionPoint`
field to `Macro` to track this difference.
2017-08-07 13:38:15 -07:00
John MacFarlane
3504915e63 LaTeX writer: Don't use figure inside table cell.
Closes #3836.
2017-08-06 22:31:15 -07:00
Alexander
1b5bfced55 Muse reader: debug indented paragraph support (#3839)
Take only first line indentation into account
and do not start new paragraph on indentation change.
2017-08-06 21:43:59 -07:00
Jesse Rosenthal
a36a56b8ac Docx reader: Avoid 0-level headers.
We used to parse paragraphs styled with "HeadingN" as "nth-level
header." But if a document has a custom style named "Heading0", this
will produce a 0-level header, which shouldn't exist. We only parse
this style if N>0. Otherwise we treat it as a normal style name, and
follow its dependencies, if any.

Closes #3830.
2017-08-06 19:35:03 -07:00
Alexander
8164a005c0 Muse reader: debug list and list item separation rules (#3837) 2017-08-06 13:19:59 -07:00
bucklereed
685788cd4b LaTeX reader: plainbreak, fancybreak et al from the memoir class (#3833) 2017-08-05 10:03:31 -07:00
Alexander Krotov
7a3a8790de Muse reader: do not allow headers in blockquotes (#3831) 2017-08-03 15:41:45 -07:00
Alexander Krotov
38b6adaac0 Muse reader: do not parse blocks inside comments (#3828) 2017-08-03 09:11:00 -07:00
John MacFarlane
ced834076d DokuWiki reader: better handling for code block in list item.
Closes #3824.
2017-08-02 10:33:08 -07:00
John MacFarlane
b8afec05e0 Markdown writer: better escaping of < and >.
If `all_symbols_escapable` is set, we backslash escape these.
Otherwise we use entities as before.
2017-07-30 13:45:22 -07:00
John MacFarlane
8cbc28415e Class: more haddocks. 2017-07-30 07:43:55 -07:00
John MacFarlane
7f9e950d8d Class: Removed unnecessary withMedia, improved haddocks. 2017-07-30 07:43:55 -07:00
Wandmalfarbe
200b5fb60c Sorted the list of supported HTML5 attributes and removed duplicates. (#3817) 2017-07-26 18:50:10 +02:00
John MacFarlane
e0ab09611a HTML writer: render raw inline environments when --mathjax used.
We previously did this only with raw blocks, on the assumption
that math environments would always be raw blocks. This has changed
since we now parse them as inline environments.

Closes #3816.
2017-07-26 12:50:36 +02:00
John MacFarlane
d441e656db HTML writer: insert data- in front of unsupported attributes.
Thus, a span with attribute 'foo' gets written to HTML5
with 'data-foo', so it is valid HTML5.

HTML4 is not affected.

This will allow us to use custom attributes in pandoc without
producing invalid HTML.
2017-07-25 13:13:24 +02:00
John MacFarlane
2b039acb4e Merge branch 'textcolor-support' of https://github.com/schrieveslaach/pandoc into schrieveslaach-textcolor-support 2017-07-25 11:42:10 +02:00
John MacFarlane
329b61ff5c LaTeX reader: support etoolbox's ifstrequal. 2017-07-24 11:20:59 +02:00
John MacFarlane
e7876d4320 LaTeX reader: removed code for non-exported 'macro'. 2017-07-24 00:25:35 +02:00
John MacFarlane
159d31e80f LaTeX reader: Removed 'macro'.
It is no longer necessary, since the rawLaTeXBlock parser
will parse macro definitions.

This also avoids the need for a separate latexMacro parser
in the Markdown reader.
2017-07-24 00:02:55 +02:00
John MacFarlane
be14e2b501 LaTeX reader: some improvements in macro parsing.
Fixed applyMacros so that it operates on the whole
string, not just the first token!

Don't remove macro definitions from the output,
even if Ext_latex_macros is set, so that macros will
be applied.  Since they're only applied to math in
Markdown, removing the macros can have bad effects.
Even for math macros, keeping them should be harmless.
2017-07-24 00:02:55 +02:00
John MacFarlane
d453b3319a Refactored some common code in LaTeX reader. 2017-07-24 00:02:54 +02:00
Mauro Bieg
7d9b782f73 HTML Reader: parse figure and figcaption (#3813) 2017-07-22 19:22:56 +02:00
John MacFarlane
f9309bc46e LaTeX reader: improved heuristic for raw block/inline.
An unknown command at the beginning of the line that could
be either block or inline is treated as block if we have
a sequence of block commands followed by a newline or a
`\startXXX` command (which might start a raw ConTeXt environment).
2017-07-21 23:27:54 +02:00
rlpowell
2ae75e23dd Added TikiWiki reader (#3800)
Added TikiWiki reader, including tests and documentation.

It's probably not *complete*, but it works pretty well, handles all
the basics (and some not-so-basics).
2017-07-21 10:09:54 +02:00
Alexander Krotov
335a1c7f48 Muse reader: fix reading of lists inside tags (#3802) 2017-07-21 10:04:13 +02:00
John MacFarlane
7191fe1f29 LaTeX reader: handle optional args in raw \titleformat.
Closes #3804.
2017-07-21 09:28:36 +02:00
John MacFarlane
992943d98e Templates: change signature of getDefaultTemplate.
Now it runs in any instance of PandocMonad, and returns
a String rather than an Either value.
2017-07-19 21:46:28 +02:00
John MacFarlane
2ce6b492e1 Class: started adding haddocks. 2017-07-19 21:31:46 +02:00
John MacFarlane
56f63af3f6 LaTeX reader: fixed regression with starred environment names.
Closes #3803.
2017-07-19 17:30:22 +02:00