Commit graph

3913 commits

Author SHA1 Message Date
Jesse Rosenthal
4eba314c24 Docx writer: code legibility fixups.
More meaningful variable name, and explanatory comment.
2016-10-05 08:06:22 -04:00
Jesse Rosenthal
be27c9c646 Docx writer: Clean up and streamline RTL behavior
Now RTL is turned and off by a general function, `withDirection`
wrapping `inlineToOpenXML` and `blockToOpenXML`. This acts according to
the `envRTL` variable. This means we can just set the environment at the
outset, and change the environment with `local` as need be.

Note that this requires making the `inlineToOpenXML` and
`blockToOpenXML` functions into wrappers around
primed-versions (`{inline,block}ToOpenXML`) where the real work takes
place.
2016-10-04 11:18:11 -04:00
Jesse Rosenthal
1893f8fe48 Docx writer: move a couple more vars to ReaderT
In general, we want things that are either:

 1. unchanging environment variables, or
 2. environment variables that will change for a the scope of
    a function and then pop back

to be in the reader monad. This is safer for (1), since we won't
accidentally change it, and easier for (2), since we can use `local`
instad of setting the old value and then resetting.

We keep the StateT monad for values that we will want to accumulate or
change and then use later.
2016-10-04 08:54:35 -04:00
Jesse Rosenthal
41f4c8741f Clean up commented-out code
A few commented out functions were left in the code during the
conversion from StateT to ReaderT. This removes them.
2016-10-03 21:48:59 -04:00
Jesse Rosenthal
ab31d5ea8d Remove bool on setRTL.
We had to use this because we set the env, which means that setRTL
wouldn't do anything at the top level. We now don't set the env (it will
always be false at the outset), which means the toplevel setRTL will
work if necessary.
2016-10-03 21:39:40 -04:00
Jesse Rosenthal
666c042e80 Filter text/para props correctly.
We only filter on the name, not the prefix.
2016-10-03 21:39:40 -04:00
Jesse Rosenthal
acf352331c Add a boolean flag to the setRTL function.
At the toplevel we don't check to see if RTL is already set.
2016-10-03 21:39:40 -04:00
Jesse Rosenthal
e98be61a38 Test for "dir" metadata. 2016-10-03 21:39:40 -04:00
Jesse Rosenthal
8d148c02a8 Add setRTL and setLTR functions. 2016-10-03 21:39:34 -04:00
Jesse Rosenthal
a2d3854f23 Move more enviroment vars to Reader Monad.
Things that get pushed and then reset are better in ReaderT, because
they can be run with `local`.
2016-10-03 12:12:38 -04:00
Jesse Rosenthal
6a3d1cf210 Add ReaderT env to the docx writer:
This will allow us to add text and paragraph properties depending on if
rtl is already set or not.

(It would probably be cleaner and safer to move the paraprops and
textprops to this part of the stack in the future.)
2016-10-03 07:50:40 -04:00
John MacFarlane
1435906f09 MediaWiki writer: transform filename with underscores in images.
`foo bar.jpg` becomes `foo_bar.jpg`. This was already done
for internal links, but it also needs to happen for images.

Closes #3052.
2016-10-02 22:09:20 +02:00
John MacFarlane
d0bfcbb801 EPUB writer: use stringify instead of plain writer for metadata.
This means that underscores won't be used for emphasis,
or CAPS for bold.  The metadata fields will just have unadorned
text.

Closes #3066.
2016-10-02 22:01:22 +02:00
John MacFarlane
46d8b42da5 AsciiDoc writer: avoid unnecessary use of "unconstrained" emphasis.
In AsciiDoc, you must use a special form of emphasis (double `__`)
for intraword emphasis.  Pandoc was previously using this more
than necessary.

Closes #3068.
2016-10-02 21:51:34 +02:00
John MacFarlane
5ec9b6352c Moved template compiling/rendering code to a separate library.
jgm/doctemplates.

This allows the pandoc templating system to be used independently.
2016-10-02 09:30:26 +02:00
John MacFarlane
e95047ed85 Markdown reader: added bracket syntax for native spans.
See #168.

Text.Pandoc.Options.Extension has a new constructor `Ext_brackted_spans`,
which is enabled by default in pandoc's Markdown.
2016-09-28 12:33:05 +02:00
John MacFarlane
c6d3eca44e Merge pull request #3093 from wilx/master-figure-placement
LaTeX: Do not set [htbp] figure placement options.
2016-09-28 11:17:48 +02:00
Jesse Rosenthal
581fc0130b LaTeX writer: change braced backtick to \textasciigrave{}
Backticks in verbatim environments are converted to
open-single-quotes. This change makes them appear as backticks. This
corresponds to how we treat `'' in verbatim environments (with
\textquotesingle{}).
2016-09-20 09:44:35 -04:00
Jesse Rosenthal
5b5f55a710 LaTeX writer: enclose backtick in {} in verbatim
We don't want ligatures like ` ?` ` (which produces `¿`) inside
`\texttt{}` environments, so we enclose the backtick in braces.

This fixes #3121
2016-09-19 16:23:28 -04:00
Albert Krewinkel
aca695ab0b
TEI writer: remove heuristic to detect book template
TEI doesn't have `<book>` elements but only generic `<divN>` division elements.
Checking the template for a trailing `</book>` is nonsensical.
2016-09-13 18:21:03 +02:00
Oliver Matthews
23fb52ef7d
Add --parts command line option to LaTeX writer.
Add --parts command line argument.
This only effects LaTeX writer, and only for non-beamer output formats.
It changes the output levels so the top level is 'part', the next
'chapter' and then into sections.
2016-09-06 21:43:45 +02:00
John MacFarlane
fd4831dd03 DocBook writer: include an anchor element when a div or span has an id.
This closes #3102.  Note that DocBook does not have a class attribute,
but at least this provides an anchor for internal links.
2016-09-06 10:09:52 +02:00
Jesse Rosenthal
3f82471355 Remove http-client CPP conditionals.
Our lower bound on http-client is 0.5, and both of these min_version
tests are less than 0.5, so they will always pass.
2016-09-03 08:41:00 -04:00
Jesse Rosenthal
7d9f2d3657 Remove blaze-html CPP conditional.
This tests for a min value >= 0.5. But we have a lower bound of 0.5 in
pandoc.cabal, so the test will always pass.

(If we bump the lower bound to 0.5.1, we can remove a conditional in the
HTML writer as well.)
2016-09-03 08:40:13 -04:00
Jesse Rosenthal
df1ca2b1a5 Add EOL note to time compat module.
Because time 1.4 is a boot library for GHC 7.8, we will support the
compatibility module as long as we support 7.8. But we should be clear
about when we will no longer need it.
2016-09-03 08:10:53 -04:00
Jesse Rosenthal
3f8d3d844f Remove TagSoup compat
We already lower-bound tagsoup at 0.13.7, which means we were always
running the compatibility layer (it was conditional on min value
0.13). Better to just use `lookupEntity` from the library directly, and
convert a string to a char if need be.
2016-09-02 12:28:53 -04:00
Jesse Rosenthal
c613dbde01 Remove unnecessary CPP condition in UTF8
Base 4.4 is ghc 7.2, so we don't have to worry about getting a lower version.
2016-09-02 09:18:09 -04:00
Jesse Rosenthal
7ea16ad058 Actually remove T/P/Compat/Except. 2016-09-02 09:18:09 -04:00
Jesse Rosenthal
f72e3b58e8 Remove directory compat
directory 1.1 depends on base 4.5 (ghc 7.4) which we are no longer
supporting. So we don't have to use a compatibility layer for it.
2016-09-02 09:18:09 -04:00
Jesse Rosenthal
7f676b534a Remove Text.Pandoc.Compat.Except 2016-09-02 09:18:09 -04:00
Jesse Rosenthal
26c3705da4 Fix grouping of imports.
Some source files keep imports in tidy groups. Changing
`Text.Pandoc.Compat.Monoid` to `Data.Monoid` could upset that. This
restores tidiness.
2016-09-02 09:18:09 -04:00
Jesse Rosenthal
1cdebe1170 Remove an inline monad compatibility macro. 2016-09-02 09:18:08 -04:00
Jesse Rosenthal
45c7108b4f Remove Compat.Monoid
This was only necessary for GHC versions with base below 4.5
(i.e., ghc < 7.4).
2016-09-02 09:18:08 -04:00
John MacFarlane
b0013bfb13 PDF: Don't crash with nonexistent image.
Instead, emit the alt text, emphasized.  This accords with what
the ODT writer currently does.

The user will still get a warning about a nonexistent image,
but will no longer get a LaTeX crash.

Closes #3100.
2016-09-02 11:44:50 +02:00
John MacFarlane
07c67cf868 Merge pull request #3091 from wilx/master-narrow-no-break-space
Translate NARROW NO-BREAK SPACE into LaTeX.
2016-09-02 11:42:18 +02:00
Albert Krewinkel
21cd76c201
Org reader: respect unnumbered header property
Sections the `unnumbered` property should, as the name implies, be
excluded from the automatic numbering of section provided by some output
formats.  The Pandoc convention for this is to add an "unnumbered" class
to the header.  The reader treats properties as key-value pairs per
default, so a special case is added to translate the above property to a
class instead.

Closes #3095.
2016-08-30 18:10:24 +02:00
Jesse Rosenthal
abc4bca46b Docx reader: make all compilers happy with traversable.
The last attempt to make 7.8 happy made 7.10 unhappy. So we need some
conditional logic to appease all versions.
2016-08-29 23:16:40 -04:00
Jesse Rosenthal
773adc7804 Docx reader: Import traverse for ghc 7.8
The GHC 7.8 build was erroring without it.
2016-08-29 21:34:26 -04:00
Jesse Rosenthal
7ae9621a87 Docx reader: clean up function with traverse 2016-08-29 18:56:24 -04:00
Albert Krewinkel
a3a3e3fdbf
Merge branch 'org-meta-handling' 2016-08-29 14:42:23 +02:00
Albert Krewinkel
88313c0b93
Org reader: respect creator export option
The `creator` option controls whether the creator meta-field should be
included in the final markup.  Setting `#+OPTIONS: creator:nil` will
drop the creator field from the final meta-data output.

Org-mode recognizes the special value `comment` for this field, causing
the creator to be included in a comment.  This is difficult to translate
to Pandoc internals and is hence interpreted the same as other truish
values (i.e. the meta field is kept if it's present).
2016-08-29 14:35:16 +02:00
Albert Krewinkel
0568aa5cad
Org reader: respect email export option
The `email` option controls whether the email meta-field should be
included in the final markup. Setting `#+OPTIONS: email:nil` will drop
the email field from the final meta-data output.
2016-08-29 14:34:39 +02:00
Albert Krewinkel
117d3f4d92
Org reader: respect author export option
The `author` option controls whether the author should be included in
the final markup.  Setting `#+OPTIONS: author:nil` will drop the author
from the final meta-data output.
2016-08-29 14:33:18 +02:00
Albert Krewinkel
28d17ea70f
Org reader: read HTML_head as header-includes
HTML-specific head content can be defined in `#+HTML_head` lines.  They
are parsed as format-specific inlines to ensure that they will only show
up in HTML output.
2016-08-29 14:10:57 +02:00
Albert Krewinkel
d164ead379
Org reader: set classoption meta from LaTeX_class_options 2016-08-29 14:10:57 +02:00
Albert Krewinkel
825ce8ca73
Org reader: set documentclass meta from LaTeX_class 2016-08-29 14:10:57 +02:00
Albert Krewinkel
a257488343
Org reader: read LaTeX_header as header-includes
LaTeX-specific header commands can be defined in `#+LaTeX_header` lines.
They are parsed as format-specific inlines to ensure that they will only
show up in LaTeX output.
2016-08-29 14:10:57 +02:00
Albert Krewinkel
75df104215
Org reader: give precedence to later meta lines
The last meta-line of any given type is the significant line.
Previously the value of the first line was kept, even if more lines of
the same type were encounterd.
2016-08-29 14:10:57 +02:00
Albert Krewinkel
2ca2585b35
Org reader: allow multiple, comma-separated authors
Multiple authors can be specified in the `#+AUTHOR` meta line if they
are given as a comma-separated list.
2016-08-29 14:10:57 +02:00
Albert Krewinkel
153970bef5
Org reader: read markup only for special meta keys
Most meta-keys should be read as normal string values, only a few are
interpreted as marked-up text.
2016-08-29 14:10:56 +02:00
Albert Krewinkel
bed5f700ce
Org reader: extract meta parsing code to module
Parsing of meta-data is well separable from other block parsing tasks.
Moving into new module to get small files and clearly arranged code.
2016-08-29 14:10:51 +02:00
Vaclav Zeman
df33d13587 LaTeX: Do not set [htbp] figure placement options.
Do not set `[htbp]` placement options on each figure to allow overriding
them by them using `\fps@figure` redefintion either in header or in
template.
2016-08-29 10:03:09 +02:00
Jesse Rosenthal
95734b2951 Docx reader: update copyright. 2016-08-28 22:53:19 -04:00
Jesse Rosenthal
9f6fd6139f Docx reader: use all anchor spans for header ids.
Previously we only used the first anchor span to affect header ids. This
allows us to use all the anchor spans in a header, whether they're
nested or not.

Along with 62882f97, this closes #3088.
2016-08-28 18:12:02 -04:00
Jesse Rosenthal
2893b0055a Docx reader: Let headers use exisiting id.
Previously we always generated an id for headers (since they wouldn't
bring one from Docx). Now we let it use an existing one if
possible. This should allow us to recurs through anchor spans.
2016-08-28 18:09:27 -04:00
Jesse Rosenthal
62882f976d Docx reader: Handle anchor spans with content in headers.
Previously, we would only be able to figure out internal links to a
header in a docx if the anchor span was empty. We change that to read
the inlines out of the first anchor span in a header.

This still leaves another problem: what to do if there are multiple
anchor spans in a header. That will be addressed in a future commit.
2016-08-28 18:03:09 -04:00
Vaclav Zeman
1053677f49 Translate NARROW NO-BREAK SPACE into LaTeX.
Translate NARROW NO-BREAK SPACE into LaTeX' `\,`.
2016-08-27 22:17:39 +02:00
John MacFarlane
d29a623896 Man writer: allow section numbers that are not a single digit.
Closes #3089.
2016-08-27 22:00:42 +02:00
Albert Krewinkel
500de5e979
Org writer: translate language identifiers
Pandoc and Org-mode use different programming language identifiers.  An
additional translation between those identifiers is added to avoid
unexpected behavior.  This fixes a problem where language specific
source code would sometimes be output as example code.
2016-08-20 23:42:36 +02:00
Albert Krewinkel
dbf4d77091
Org writer: ensure link targets are paths or URLs
Org-mode treats links as document internal searches unless the link
target looks like a URL or file path, either relative or absolute.  This
change ensures that this is always the case.
2016-08-18 14:32:59 +02:00
Albert Krewinkel
d669425640
Org writer: ensure blank line after figure
An Org-mode figure should be surrounded by blank lines.  The figure
would be recognized regardless, but images in the following line would
unintentionally be treated as figures as well.
2016-08-18 14:32:59 +02:00
Albert Krewinkel
91afa513ad
Org writer: remove blank line after figure caption
Org-mode only treats an image as a figure if it is directly preceded by
a caption.
2016-08-18 14:32:59 +02:00
Jesse Rosenthal
b784ce8866 Docx Writer: change dynamic style key
Use "custom-style" instead of "docx-style." This allows it to be used in
other formats like ODT in the future.
2016-08-15 13:58:56 -04:00
Jesse Rosenthal
2870c9be00 Docx writer: Inject text properties as well. 2016-08-15 13:56:45 -04:00
Jesse Rosenthal
66d393ae7a Docx Writer: Keep track of dynamic text props too. 2016-08-15 12:41:31 -04:00
Jesse Rosenthal
d6b60558e3 Docx writer: Allow dynamic styles on spans.
This enables dynamic styling on spans. It uses the same prefix as we
used on divs ("docx-style" for the moment). It does not yet inject the
style into styles.xml.
2016-08-15 12:35:11 -04:00
Jesse Rosenthal
59bc1e68aa Docx writer: Inject new paragraph properties
This injects new dynamic paragraph properties to be into the style
file. Nothing occurs if the prop already exists in the style file.
2016-08-15 12:19:24 -04:00
Jesse Rosenthal
9999db2e6c StyleMap: export functions on StyleMap instances
We're going to want `getMap` in the Docx Writer.
2016-08-15 12:04:20 -04:00
Jesse Rosenthal
6c6860d076 Docx Writer: Have state keep track of dynamic styles.
We want to be able to inject these into our styles.xml.
2016-08-15 10:27:01 -04:00
Jesse Rosenthal
a362a62abe Docx Writer: Implement user-defined styles.
Divs with a "docx-style" key in the attributes will apply the
corresponding key to the contained blocks.
2016-08-13 21:52:50 -04:00
Jesse Rosenthal
347d716826 Docx parser: Use xml convenience functions
The functions `isElem` and `elemName` (defined in Docx/Util.hs) make the
code a lot cleaner than the original XML.Light functions, but they had
been used inconsistently. This puts them in wherever applicable.
2016-08-13 13:46:21 -04:00
John MacFarlane
1955ee9c72 Merge pull request #3048 from tarleb/latex-mini-fix
LaTeX reader: drop duplicate `*` in bibtexKeyChars
2016-08-11 21:15:27 +02:00
John MacFarlane
13424a2bd7 Merge pull request #3065 from tarleb/org-verse-indent
Org reader: preserve indentation of verse lines
2016-08-09 21:33:24 +02:00
Albert Krewinkel
ba5b426ded Org reader: ensure image sources are proper links
Image sources as those in plain images, image links, or figures, must be
proper URIs or relative file paths to be recognized as images.  This
restriction is now enforced for all image sources.

This also fixes the reader's usage of uncleaned image sources, leading
to `file:` prefixes not being deleted from figure
images (e.g. `[[file:image.jpg]]` leading to a broken image `<img
src="file:image.jpg"/>)

Thanks to @bsag for noticing this bug.
2016-08-09 20:27:08 +02:00
Albert Krewinkel
13280a8112 Org reader: preserve indentation of verse lines
Leading spaces in verse lines are converted to non-breaking spaces, so
indentation is preserved.

This fixes #3064.
2016-08-08 09:40:50 +02:00
John MacFarlane
0fbb676c81 MediaWiki reader: properly interpret XML tags in pre environments.
They are meant to be interpreted as literal text in textile.
Closes #3042.
2016-08-06 23:57:42 +02:00
John MacFarlane
124679fd63 Improved mediawiki reader's treatment of verbatim constructions.
Previously these yielded strings of alternating Code and Space
elements; we now incorporate the spaces into the Code.  Emphasis
etc. is still possible inside these.

Closes #3055.
2016-08-06 23:41:03 +02:00
John MacFarlane
3a49439202 Fix for unquoted attribute values in mediawiki tables.
Previously an unquoted attribute value in a table row
could cause parsing problems.

Fixes #3053 (well, proper rowspans and colspans aren't
created, but that's a bigger limitation with the current
Pandoc document model for tables).
2016-08-06 23:22:03 +02:00
Matthew Pickering
be4783109c Fix out of index error in handleError
In the latex parser when includes are processed, the text of the
included file is directly included into the parse stream. This caused
problems when there was an error in the included file (and the included
file was longer than the original file) as the error would be reported
at this position.

The error handling tries to display the line and position where the
error occured. It works by including a copy of the input and finding the
place in the input when given the position of the error. In the
previously described scenario, the input file would be the original
source file but the error position would be the position of the error in
the included file.

The fix is to not try to show the exact line when it would cause an
out-of-bounds error.
2016-08-06 22:06:37 +01:00
John MacFarlane
a480293b3c LaTeX writer: don't use * for unnumbered paragraph, subparagraph.
The starred variants don't exist.

This helps with part of #3058...it gets rid of the spurious *s.
But we still have numbers on the 4th and 5th level headers.
2016-08-06 22:37:11 +02:00
Albert Krewinkel
f9afc0d378 LaTeX reader: drop duplicate * in bibtexKeyChars 2016-07-29 20:53:43 +02:00
John MacFarlane
199489c12c Merge pull request #3033 from tarleb/github-readme
PoC: GitHub-optimized README
2016-07-22 15:52:38 -07:00
John MacFarlane
27762affe3 Textile reader: disallow empty URL in explicit link.
Closes #3036.
2016-07-22 15:45:03 -07:00
John MacFarlane
5f758970a5 Textile reader: support bc.. extended code blocks.
Also, remove trailing newline in code blocks (consistently
with Markdown reader).
2016-07-22 15:32:50 -07:00
Albert Krewinkel
a396003a31 Rename README to MANUAL.txt 2016-07-20 21:16:45 +02:00
John MacFarlane
34533dd8d1 LaTeX reader: be more forgiving of non-standard characters.
E.g. `^` outside of math.  Some custom environments give
these a meaning, so we should try not to fall over when we
encounter them.
2016-07-20 11:36:50 -07:00
John MacFarlane
1b6c9733ee LaTeX reader: more robust parsing of unknown environments.
We no longer fail on things like `^` inside options for tikz.
Closes #3026.
2016-07-20 11:18:24 -07:00
John MacFarlane
3263ed3c42 RST reader: use Div for admonitions.
Previously blockquotes were used.  Now a Div is used
with class `admonition` and (if relevant) one of the
following:  `attention`, `caution`, `danger`, `error`,
`hint`, `important`, `note`, `tip`, `warning`.

`sidebar` is also put into a Div.

Note: This will change rendering of RST documents!
It should provide much more flexibility.

Closes #3031.
2016-07-20 10:14:24 -07:00
John MacFarlane
e2d59461bb Textile reader: improve definition list parsing.
- Allow multiple terms (which we concatenate with linebreaks).
- Fix exponential parsing bug (closes #3020 for real this time).
2016-07-19 09:03:15 -07:00
John MacFarlane
3490932d21 Textile reader: improved table parsing.
We now handle cell and row attributes, mostly by skipping
them.  However, alignments are now handled properly.
Since in pandoc alignment is per-column, not per-cell, we
try to devine column alignments from cell alignments.

Table captions are also now parsed, and textile indicators
for thead and tfoot no longer cause parse failure.  (However,
a row designated as tfoot will just be a regular row in pandoc.)
2016-07-18 22:40:45 -07:00
John MacFarlane
d7396e73b4 Don't require haddock-library 1.4.
Instead use CPP to work around version differences.
2016-07-15 12:04:00 -07:00
John MacFarlane
17defd5004 Use liftM since otherwise Functor type constraint needen in ghc 7.8. 2016-07-15 12:02:37 -07:00
John MacFarlane
2f54de7cc4 Fixed compiler warnings. 2016-07-14 23:38:44 -07:00
John MacFarlane
c203ace130 Haddock reader - support math.
The Haddock document model added elements for math
in 1.4.
2016-07-14 23:38:20 -07:00
Jesse Rosenthal
f529fc17ef Docx Writer: Use actual creation time as doc prop
Previously, we had used the user-supplied date, if available, for Word's
document creation metadata. This could lead to weird results, as in
cases where the user post-dates a document (so the modification might be
prior to the creation). Here we use the actual computer time to set the
document creation.
2016-07-14 17:02:30 -04:00
Jesse Rosenthal
e8e02f1220 Shared: improve year sanity check in normalizeDate
Previously we parsed a list of dates, took the first one, and then
tested its year range. That meant that if the first one failed, we
returned nothing, regardless of what the others did. Now we test for
sanity before running `msum` over the list of Maybe values. Anything
failing the test will be Nothing, so will not be a candidate.
2016-07-14 17:02:30 -04:00
Jesse Rosenthal
bbfcd50fb1 Shared: normalizeDate should reject illegal years.
We only allow years between 1601 and 9999, inclusive. The ISO 8601
actually says that years are supposed to start with 1583, but MS Word
only allows 1601-9999. This should stop corrupted word files if the date
is out of that range, or is parsed incorrectly.
2016-07-14 17:02:30 -04:00
Jesse Rosenthal
4816facee4 Shared: Add further formats for normalizeDate
We want to avoid illegal dates -- in particular years with greater than
four digits. We attempt to parse series of digits first as `%Y%m%d`, then
`%Y%m`, and finally `%Y`.
2016-07-14 17:02:30 -04:00
John MacFarlane
0b0a0e730f Removed some redundant class constraints. 2016-07-14 08:54:06 -07:00
John MacFarlane
06a3e6a03f Merge pull request #3019 from tarleb/org-verbatim-fix
Org reader: fix parsing of verbatim inlines
2016-07-14 08:43:39 -07:00
John MacFarlane
00b11bcbcf Fixed exponential parsing bug in textile reader.
Closes #3020.
2016-07-14 08:42:38 -07:00
Albert Krewinkel
529146decf Org reader: fix parsing of verbatim inlines
Org rules for allowed characters before or after markup chars were not
checked for verbatim text.  This resultet in wrong parsing outcomes of
if the verbatim text contained e.g. space enclosed markup characters as
part of the text (`=is_substr = True=`).  Forcing the parser to update
the positions of allowed/forbidden markup border characters fixes this.

This fixes #3016.
2016-07-14 13:33:25 +02:00
John MacFarlane
e2659a46db Merge pull request #3014 from tarleb/org-writer-div
Org writer: improve Div handling
2016-07-05 12:46:13 -07:00
Albert Krewinkel
5378b7c5bd
Org writer: improve Div handling
Div blocks handling is changed to make the output look more like
idiomatic org mode:

  - Div-wrapped content is output as-is if the div's attribute is the
    null attribute.
  - Div containers with an id but neither classes nor key-value pairs
    are unwrapped and the id is added as an anchor.
  - Divs with classes associated with greater block elements are
    wrapped in a `#+BEGIN`...`#+END` block.
  - The old behavior for Divs with more complex attributes is kept.
2016-07-05 11:49:45 +02:00
Albert Krewinkel
f417fecf5f
Org reader: replace ugly code with view pattern
Some less-than-smart code required a pragma switching of overlapping
pattern warnings in order to compile seamlessly.  Using view patterns
makes the code easier to read and also doesn't require overlapping
pattern checks to be disabled.
2016-07-04 11:20:05 +02:00
John MacFarlane
e548b8df07 Merge pull request #3010 from tarleb/org-header-tree
Org reader: support archived trees, headline levels export setting
2016-07-03 22:57:22 -07:00
John MacFarlane
4099b2dca4 Odt reader: Removed redundant Monoid constraints. 2016-07-03 22:47:32 -07:00
John MacFarlane
b203a31ba7 Fix warning for parseURl import. 2016-07-03 22:26:08 -07:00
John MacFarlane
261c3af053 CPP workaround for deprecation of parseUrl in http-client. 2016-07-03 21:29:47 -07:00
Albert Krewinkel
5ffa4abf72
Org reader: support headline levels export setting
The depths of headlines can be modified using the `H` option.  Deeper
headlines will be converted to lists.
2016-07-03 23:28:45 +02:00
John MacFarlane
40caf516aa Allow 'standout' as a beamer frame option.
## Slide title {.standout}

Closes #3007.
2016-07-03 11:56:03 -07:00
Albert Krewinkel
c1f6bd2640
Org reader: put export setting parser into module
Export option parsing is distinct enough from general block parsing to
justify putting it into a separate module.
2016-07-02 13:14:09 +02:00
John MacFarlane
e0cc9e4463 LaTeX reader: strip off double quotes around image source if present.
Avoids interpreting these as part of the literal filename.
See #2825.
2016-07-01 15:47:42 -07:00
John MacFarlane
7e712abfa6 LaTeX writer: don't URI-escape image source.
Usually this is a local file, and replacing spaces with `%20`
ruins things.  Closes #2825.
2016-07-01 15:41:33 -07:00
Albert Krewinkel
c4cf6d237f
Org reader: support archived trees export options
Handling of archived trees can be modified using the `arch` option.
Archived trees are either dropped, exported completely, or collapsed to
include just the header when the `arch` option is nil, non-nil, or
`headline`, respectively.
2016-07-01 23:05:33 +02:00
Albert Krewinkel
1ebaf6de11
Org reader: refactor comment tree handling
Comment trees were handled after parsing, as pattern matching on lists
is easier than matching on sequences.  The new method of reading
documents as trees allows for more elegant subtree removal.
2016-07-01 23:05:32 +02:00
Albert Krewinkel
17484ed01a
Org reader: parse as headlines, convert to blocks
Emacs org-mode is based on outline-mode, which treats documents as trees
with headlines are nodes.  The reader is refactored to parse into a
similar tree structure.  This simplifies transformations acting on
document (sub-)trees.
2016-07-01 23:05:32 +02:00
Albert Krewinkel
2f8d6755f4
Org reader: improve tag and properties type safety
Specific newtype definitions are used to replace stringly typing of tags
and properties.  Type safety is increased while readability is improved.
2016-07-01 23:05:32 +02:00
John MacFarlane
b3382cf377 ZimWiki writer: removed commented out code that confused Haddock.
See https://travis-ci.org/jgm/pandoc/jobs/141542247
2016-07-01 10:39:32 -07:00
Alex Ivkin
a73c95f61d Added Zim Wiki writer, template and tests. 2016-06-30 23:59:43 -07:00
Jesse Rosenthal
b103f829f0 Docx writer: set paragraph to FirstPara after display math
We treat display math like block quotes, and apply FirstParagraph style
to paragraphs that follow them. These can be styled as the user
wishes. (But, when the user is using indentation, this allows for
paragraphs to continue after display math without indentation.)
2016-07-01 01:14:16 -04:00
Jesse Rosenthal
2c62f0e122 Writers: treat SoftBreak as space for stripping
In Writers.Shared, we strip leading and trailing spaces for display
math. Since SoftBreak's are treated as spaces, we should strip those
too.
2016-07-01 00:52:52 -04:00
John MacFarlane
3429fa6438 LaTeX reader: fixed \cite so it is a NormalCitation not AuthorInText. 2016-06-29 07:59:00 -07:00
John MacFarlane
a349814665 Merge pull request #3001 from tarleb/org-figure-label
Org reader: support figure labels
2016-06-26 17:51:51 -07:00
Albert Krewinkel
0f3f5ce1a1 Org reader: support figure labels
Figure labels given as `#+LABEL: thelabel` are used as the ID of the
respective image.  This allows e.g. the LaTeX to add proper `\label`
markup.

This fixes half of #2496 and #2999.
2016-06-26 20:42:22 +02:00
John MacFarlane
38c97320ef Textile reader: Fix overly aggressive interpretation as images.
Spaces are not allowed in the image URL in textile.

Closes #2998.
2016-06-25 14:04:47 -07:00
John MacFarlane
d283f9c864 Fixed RST links with no explicit link text.
The link

    `<foo>`_

should have `foo` as both its link text and its URL.

See RST spec at
<http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases>

"The reference text may also be omitted, in which case the URI will be
duplicated for use as the reference text. This is useful for relative
URIs where the address or file name is also the desired reference text:

See `<a_named_relative_link>`_ or `<an_anonymous_relative_link>`__
for details."

Closes Debian #828167 -- reported by Christian Heller.
2016-06-25 10:56:37 -07:00
John MacFarlane
a4294800bf Make --webtex work with the Markdown writer.
Closes #1177.  This is a convenient option for people using
websites whose Markdown flavors don't provide for math.
2016-06-24 14:57:21 -07:00
John MacFarlane
69e59e7f29 Process markdown extensions on command line in L->R order.
Previously they were processed, very unintuitively, in R->L
order, so that `markdown-tex_math_dollars+tex_math_dollars`
had `tex_math_dollars` disabled.

Closes #2995.
2016-06-23 23:04:42 -07:00
John MacFarlane
a820c1bd1c Textile reader: fixed attributes.
Attributes can't be followed by a space.

So,

    _(class)emph_

but

    _(noclass) emph_

Closes #2984.
2016-06-23 10:28:54 -07:00
John MacFarlane
139d418d4b Markdown writer: use raw HTML for simple, pipe tables with linebreaks.
Markdown line breaks involve a newline, and simple and pipe
tables can't contain one.

Closes #2993.
2016-06-23 10:00:33 -07:00
Jesse Rosenthal
032ba8dd0c Docx reader: Add warning for advanced comment formatting.
We can't guarantee we'll convert every comment correctly, though we'll
do the best we can. This warns if the comment includes something other
than Para or Plain.
2016-06-23 10:50:46 -04:00
Jesse Rosenthal
5f0cd89129 docx reader: enable warnings in top-level reader
Previously we had only allowed for warnings in the parser. Now we allow
for them in the `Docx.hs` as well. The warnings are simply concatenated.
2016-06-23 10:50:46 -04:00
Jesse Rosenthal
8bb739f7ff Docx reader: add simple comment functionality.
This adds simple track-changes comment parsing to the docx reader. It is
turned on with `--track-changes=all`. All comments are converted to
inlines, which can list some information. In the future a warning will
be added for comments with formatting that seems like it will be
excessively denatured.

Note that comments can extend across blocks. For that reason there are
two spans: `comment-start` and `comment-end`. `comment-start` will
contain the comment. `comment-end` will always be empty. The two will be
associated by a numeric id.
2016-06-23 10:50:46 -04:00
Jesse Rosenthal
cbc2c15f0f Shared: Add BlockQuote to blocksToInlines 2016-06-23 10:50:46 -04:00
Jesse Rosenthal
2b701f9389 Shared: introduce blocksToInlines function
This is a lossy function for converting `[Block] -> [Inline]`. Its main
use, at the moment, is for docx comments, which can contain arbitrary
blocks (except for footnotes), but which will be converted to spans.

This is, at the moment, pretty useless for everything but the basic
`Para` and `Plain` comments. It can be improved, but the docx reader
should probably emit a warning if the comment contains more than this.
2016-06-23 10:50:46 -04:00
John MacFarlane
319a56aefc Merge pull request #2992 from tarleb/org-partial-functions
Org reader: remove partial functions
2016-06-22 12:51:37 -07:00
John MacFarlane
ba7868765a HTML writer: Better support for raw LaTeX environments.
Previously we just passed all raw TeX through when MathJax
was used for HTML math.  This passed through too much.
With this patch, only raw LaTeX environments that MathJax
can handle get passed through.

This patch also causes raw LaTeX environments to be treated
as math, when possible, with MathML and WebTeX output.

Closes #2758.
2016-06-22 11:47:44 -07:00
Albert Krewinkel
7df656089f Org reader: remove partial functions
Partial functions like `head` lead to avoidable errors and should be
avoided.  They are replaced with total functions.

This fixes #2991.
2016-06-21 23:51:15 +02:00
John MacFarlane
58d60b1c85 Changed email-obfuscation default to no obfuscation.
- `writerEmailObfuscation` in `defaultWriterOptions` is now
  `NoObfuscation`
- the default for the command-line `--email-obfuscation` option is
  now `none`.

Closes #2988.
2016-06-20 10:37:23 -07:00
Albert Krewinkel
29552eff3e Org reader: support arbitrary raw inlines
Org mode allows arbitrary raw inlines ("export snippets" in Emacs
parlance) to be included as `@@format:raw foreign format text@@`.

Support for this features is added to the Org reader.
2016-06-13 23:53:14 +02:00
Albert Krewinkel
cf2502de8f Org writer: support arbitrary raw inlines
Org mode allows arbitrary raw inlines ("export snippets" in Emacs
parlance) to be included as `@@format:raw foreign format text@@`.

Support for this features is added to the Org writer.
2016-06-13 23:13:05 +02:00
Ivo Clarysse
240cdfd1b3 Docbook writer: Declare xlink namespace in Docbook5 output 2016-06-07 06:03:06 -07:00
Albert Krewinkel
8a9f5915ab Org reader: add support for "Berkeley-style" cites
A specification for an official Org-mode citation syntax was drafted by
Richard Lawrence and enhanced with the help of others on the orgmode
mailing list.  Basic support for this citation style is added to the
reader.

This closes #1978.
2016-06-05 11:28:57 +02:00
Albert Krewinkel
06dfe3276d Org reader: add semicolon to list of special chars
Semicolons are used as special characters in citations syntax.  This
ensures the correct parsing of Pandoc-style citations:

    [prefix; @key; suffix]

Previously, parsing would have failed unless there was a space or other
special character as the last <prefix> character.
2016-06-05 11:28:57 +02:00
Albert Krewinkel
f56792927f
Org reader: support special strings export option
Parsing of special strings (like '...' as ellipsis or '--' as en dash)
can be toggled using the `-` option.
2016-06-03 11:41:23 +02:00
Albert Krewinkel
d4de8451b9 Org reader: support emphasized text export option
Parsing of emphasized text can be toggled using the `*` option.  This
influences parsing of text marked as emphasized, strong, strikeout, and
underline.  Parsing of inline math, code, and verbatim text is not
affected by this option.
2016-06-03 11:17:02 +02:00
Albert Krewinkel
952a7dac58 Org reader: support smart quotes export option
Reading of smart quotes can be toggled using the `'` option.
2016-06-03 11:16:35 +02:00
Albert Krewinkel
729fca311f Org reader: drop unused field from parser state
The `OrgParserState` contained both an `orgStateMeta` and
`orgStateMeta'` field, the former for plain meta information and the
latter for F-monad wrapped meta info.  The plain meta info is only used
to make `OrgParserState` an instance of the `HasMeta` class, which in
turn is never used in the reader.  The (F Meta) version is hence renamed
to the "un-primed" version while the other one is dropped.
2016-06-02 15:30:21 +02:00
Albert Krewinkel
512bf2eebf Org reader: undo code duplication
Some code was duplicated (copy-pasted) or placed in an inappropriate
module during the modularization refactoring.  Those functions are moved
into a `Shared` module, as was originally intended but forgotten.
Better documentation of the respective functions is a positive
side-effect.
2016-06-02 15:30:20 +02:00
John MacFarlane
061bc60f70 Merge pull request #2950 from tarleb/org-ref-support
Org reader: support org-ref style citations
2016-05-31 12:44:29 -07:00
John MacFarlane
669ecbd4ab Merge pull request #2954 from tarleb/org-export-blocks
Org export blocks
2016-05-31 11:16:08 -07:00
John MacFarlane
561afac0bc brazilian -> brazil for polyglossia.
Closes #2953.
2016-05-31 11:15:21 -07:00
Albert Krewinkel
c17c62a2c7 Org reader: support new syntax for export blocks
Org-mode version 9 usees a new syntax for export blocks.  Instead of
`#+BEGIN_<FORMAT>`, where `<FORMAT>` is the format of the block's
content, the new format uses `#+BEGIN_export <FORMAT>` instead.  Both
types are supported.
2016-05-29 21:08:50 +02:00
Albert Krewinkel
4f84cf02c7 Org reader: refactor BEGIN…END block parsing
- Reorder functions, grouping related functions together.

- Demote simple functions to local functions if they are used just once.

- Rename and document functions to increase code readability.

- Fix handling of whitespace in blocks, allowing content to be indented
  less then the block header.
2016-05-29 21:08:36 +02:00
Albert Krewinkel
bc82123122 Org reader: rename parseInlines to inlines
Having a function starting with `parse` in a parsing library is overly
redundant.  Let's use a nicer, shorter name more in line with the rest
of the library.
2016-05-29 21:08:31 +02:00
Albert Krewinkel
f226cb88b0 Org reader: support org-ref style citations
The *org-ref* package is an org-mode extension commonly used to manage
citations in org documents.  Basic support for the `cite:citeKey` and
`[[cite:citeKey][prefix text::suffix text]]` syntax is added.
2016-05-27 21:19:28 +02:00
Albert Krewinkel
eea6d6568f Org reader: extract blocks parser to module
Block parsing code is moved to a separate module.

This is part of the Org-mode reader cleanup effort.
2016-05-25 23:21:40 +02:00
Albert Krewinkel
39e8b4276e Org reader: extract inline parser to module
Inline parsing code is moved to a separate module.  Parsers for block
starts are extracted as well, as those are used in the `endline` parser.

This is part of the Org-mode reader cleanup effort.
2016-05-25 22:54:45 +02:00
Albert Krewinkel
a340c7249f Org reader: extract parsing function to module
The Org-mode reader uses many functions defined in the
`Text.Pandoc.Parsing` utility module.  Some of the functions are
overwritten with versions adapted to Org-mode idiosyncrasies.  These
special functions, as well as the normal Pandoc versions, are combined
in a single module to increase the ease of use.

This leads to decoupling of Org-mode and Pandoc and hence to slightly
cleaner code.  The downside is code-bloat due to repeated import/export
statements.
2016-05-25 22:53:55 +02:00
mb21
340f0aaef8 EPUB Reader: normalise Link id as well 2016-05-24 17:42:37 +02:00
Carlos Sosa
5667e0959a Org writer: add drawer capability
For the implementation of the Drawer element in the Org Writer, we make
use of a generic Block container with attributes.  The presence of a
`drawer` class defines that the `Div` constructor is a drawer. The first
class defines the drawer name to use. The key-value list in the
attributes defines the keys to add inside the Drawer. Lastly, the list
of Block elements contains miscellaneous blocks elements to add inside
of the Drawer.

Signed-off-by: Albert Krewinkel <albert@zeitkraut.de>
2016-05-23 10:00:14 +02:00
Albert Krewinkel
a4717c2fc5 Org reader: respect drawer export setting
The `d` export option can be used to control which drawers are exported
and which are discarded.  Basic support for this option is added here.
2016-05-23 09:44:37 +02:00
Albert Krewinkel
f3d27e4c80 Org reader/writer: use CUSTOM_ID in properties
The `ID` property is reserved for internal use by Org-mode and should
not be used.  The `CUSTOM_ID` property is to be used instead, it is
converted to the `ID` property for certain export format.

The reader and writer erroneously used `ID`.  This is corrected by using
`CUSTOM_ID` where appropriate.
2016-05-22 23:01:47 +02:00
John MacFarlane
446cf6a1cf HTML reader: fixed bug in pClose.
This caused exponential parsing behavior in documnets
with unclosed tags in dl, dd, dt.
2016-05-21 23:05:00 -07:00
Albert Krewinkel
cd3282b08d Org writer: add :PROPERTIES: drawer support
This allows header attributes to be added to org documents in the form
of `:PROPERTIES:` drawers.  All available attributes are stored as
key/value pairs.  This reflects the way the org reader handles
`:PROPERTIES:` blocks.

This closes #1962.
2016-05-20 17:01:50 +02:00
Albert Krewinkel
68d388f833 Org reader: add :PROPERTIES: drawer support
Headers can have optional `:PROPERTIES:` drawers associated with them.
These drawers contain key/value pairs like the header's `id`.  The
reader adds all listed pairs to the header's attributes; `id` and
`class` attributes are handled specially to match the way `Attr` are
defined.

This also changes behavior of how drawers of unknown type are handled.
Instead of including all unknown drawers, those are not read/exported,
thereby matching current Emacs behavior.

This closes #1877.
2016-05-20 17:01:26 +02:00
John MacFarlane
0958f2f5d0 Merge pull request #2927 from tarleb/org-attr-html
Org reader support for ATTR_HTML statements
2016-05-19 10:44:11 -07:00
Albert Krewinkel
16e233475a Org reader: add support for ATTR_HTML attributes
Arbitrary key-value pairs can be added to some block types using a
`#+ATTR_HTML` line before the block.  Emacs Org-mode only includes these
when exporting to HTML, but since we cannot make this distinction here,
the attributes are always added.

The functionality is now supported for figures.

This closes #1906.
2016-05-19 09:55:12 +02:00
Albert Krewinkel
26e8d98be2 Org reader: use custom anyLine
Additional state changes need to be made after a newline is parsed,
otherwise markup may not be recognized correctly.

This fixes a bug where markup after certain block-types would not be
recognized. E.g. `/emph/` in the following snippet was not parsed as
emphasized.

    foo
    # comment
    /emph/
2016-05-19 09:35:47 +02:00
Albert Krewinkel
1dda535378 Org reader: refactor block attribute handling
A parser state attribute was used to keep track of block attributes
defined in meta-lines.  Global state is undesirable, so block attributes
are no longer saved as part of the parser state.  Old functions and the
respective part of the parser state are removed.
2016-05-19 09:33:51 +02:00
John MacFarlane
847167804a EPUB reader: unescape URIs in spine.
This should fix #2924.

Testing on the epub that caused the problem originally
would be welcome.
2016-05-17 09:38:52 -07:00
John MacFarlane
7be30a40f1 LaTeX writer: Don't escape underscore in labels.
Previously they were escaped as ux5f.

Closes #2921.
2016-05-17 09:18:52 -07:00
John MacFarlane
344412cba8 Merge pull request #2894 from sid-kap/rst-code-class
Add class option for code block in RST reader
2016-05-12 00:03:14 -07:00
John MacFarlane
609fb33302 Merge pull request #2913 from jlduran/strut-minipage-tables
Retake on strut with \minipage inside tables
2016-05-11 23:57:47 -07:00
John MacFarlane
3800cb3d42 Merge pull request #2912 from tarleb/org-export-settings
Org reader: basic support for export settings
2016-05-11 13:36:02 -07:00
Albert Krewinkel
be5cccf248 Org reader: parse but ignore export options
All known export options are parsed but ignored.
2016-05-11 19:13:43 +02:00
Albert Krewinkel
76143de97e Org reader: add support for sub/superscript export options
Org-mode allows to specify export settings via `#+OPTIONS` lines.
Disabling simple sub- and superscripts is one of these export options,
this options is now supported.
2016-05-11 19:13:43 +02:00
Albert Krewinkel
7a0729ea09 Org reader: move parser state into separate module
The org reader code has become large and confusing.  Extracting smaller
parts into submodules should help to clean things up.
2016-05-11 19:13:42 +02:00
Jose Luis Duran
ec2fc30288 Retake on strut with \minipage inside tables
Reimplement on 4c684561ee

The problem with 4c68456 was a space between the cell contents and the
`\strut` that affected the alignment.
2016-05-11 14:02:09 -03:00
John MacFarlane
f7601297f0 Avoid lazy foldl in LaTeX writer. 2016-05-09 18:25:57 -07:00
John MacFarlane
fd9ec835ec Merge pull request #2907 from tarleb/org-fixes
Org fixes (reader and writer)
2016-05-09 10:17:56 -07:00
Albert Krewinkel
d32878b84b Org writer: print empty table rows
Empty table rows should not be dropped from the output, so row-height is
always set to be at least 1.
2016-05-09 19:06:24 +02:00
Albert Krewinkel
10a809f126 Org reader: fix inline-LaTeX regression
The last fix for whitespace handling of inline LaTeX commands was
incorrect, preventing correct recognition of inline LaTeX commands which
contain spaces.  This fix ensures that only trailing whitespace is cut
off.
2016-05-09 19:06:04 +02:00
roblabla
acd492c7f4 Allow spaces before '!' in MediaWiki table header 2016-05-09 17:54:40 +02:00
John MacFarlane
21d1a3b57c Merge pull request #2898 from tarleb/org-table-refactoring
Org reader: table parsing code refactoring and fixes
2016-05-05 16:22:56 -07:00
Albert Krewinkel
405c3e9c36 Org reader: fix spacing after LaTeX-style symbols
The org-reader was droping space after unescaped LaTeX-style symbol
commands: `\ForAll \Auml` resulted in `∀Ä` but should give `∀ Ä`
instead.  This seems to be because the LaTeX-reader treats the
command-terminating space as part of the command.  Dropping the trailing
space from the symbol-command fixes this issue.
2016-05-04 23:16:23 +02:00
Albert Krewinkel
2d825603c6 Org reader: fix handling of empty table cells, rows
This fixes Org mode parsing of some corner cases regarding empty cells
and rows.  Empty cells weren't parsed correctly, e.g. `|||` should be
two empty cells, but would be parsed as a single cell containing a pipe
character.  Empty rows where parsed as alignment rows and dropped from
the output.

This fixes #2616.
2016-05-04 16:02:03 +02:00
Albert Krewinkel
a51e4e8215 Org reader: refactor rows-to-table conversion
This refactores the codes conversing a list table lines to an org table
ADT.  The old code was simplified and is now slightly less ugly.
2016-05-04 16:01:22 +02:00
Albert Krewinkel
d5e4bc179c Org reader: stop padding short table rows
Emacs Org-mode doesn't add any padding to table rows.  The first
row (header or first body row) is used to determine the column count, no
other magic is performed.

The org reader was padding rows to the length of the longest table row.
This was done due to a misunderstanding of how Org handles tables.  This
feature reflected how Org-mode handles tables when pressing <TAB>.  The
Org exporter however, which is what the reader should implement, doesn't
do any of this.  So this was a mis-feature that made the reader more
complex and reduced comparability.  It was hence removed.
2016-05-04 15:48:07 +02:00
John MacFarlane
ee4e863225 Merge pull request #2890 from bcdevices/docbook5-writer
Docbook5 write support
2016-05-01 22:43:38 -07:00
Sidharth Kapur
490c2b543d Add class option for code block in RST reader
According to http://docutils.sourceforge.net/docs/ref/rst/directives.html#code,
the code directive supports the ":class:" option.
2016-05-01 21:42:58 -05:00
Jesse Rosenthal
99eac312fe Binary fmts throw PandocError on zip-archive fail
Commit 91dc3342 made `readDocx` throw PandocError if there was an
unarchiving error. This extends that fix to `readOdt` and `readEPUB`.
2016-05-01 18:27:20 -04:00
John MacFarlane
1fbe79db05 LaTeX writer: use {} around options containing special chars.
Closes #2892.
2016-05-01 11:20:26 -07:00
Jesse Rosenthal
91dc334249 Docx Reader: Throw PandocError on unzip failure
Previously, readDocx would error out if zip-archive failed. We change
the archive extraction step from `toArchive` to `toArchiveOrFail`, which
returns an Either value.
2016-05-01 12:17:12 -04:00
Ivo Clarysse
fd36e6b64a Docbook5 writer: Properly handle ulink/link 2016-04-29 16:06:55 -07:00
Ivo Clarysse
987ec3a752 Write out Docbook 5 namespace 2016-04-29 15:43:15 -07:00
John MacFarlane
aa4a1d527a HTML writer: ensure mathjax link is added when math appears in footnote.
Previously if a document only had math in a footnote,
the MathJax link would not be added.

Closes #2881.
2016-04-29 14:54:54 -07:00
Ivo Clarysse
271cb4d845 Add docbook5 writer support 2016-04-29 14:00:46 -07:00
John MacFarlane
32f1b0a5f1 Revert "LaTeX writer: Add \strut to fix multiline tables"
This reverts commit 4c684561ee.

See
https://groups.google.com/d/msg/pandoc-discuss/u6J-_aCProU/UufN3IYRAgAJ

This should fix uneven spacing issues in multiline tables.
2016-04-27 17:25:45 -07:00
John MacFarlane
ece215ed7d Merge pull request #2735 from mb21/patch-1
LaTeX Writer: fix polyglossia to babel env mapping
2016-04-26 23:09:02 -07:00
John MacFarlane
cc0527bf31 Merge pull request #2829 from adunning/patch-1
LaTeX writer: Add missing languages.
2016-04-26 23:08:15 -07:00
John MacFarlane
cc82851a6a Merge pull request #2876 from shosti/org-code-indent
Ignore leading space in org code blocks
2016-04-26 23:07:29 -07:00
John MacFarlane
1985164816 LaTeX writer: ignore --incremental unless -t beamer.
Closes #2843.
2016-04-26 21:50:37 -07:00
Emanuel Evans
1bfe39e24c
Ignore leading space in org code blocks
Fixes #2862

Also fix up tab handling for leading whitespace in code blocks.
2016-04-26 10:29:59 -07:00
Jesse Rosenthal
a385ee1d4f Docx Reader: parse moveTo and moveFrom
`moveTo` and `moveFrom` are track-changes tags that are used when a
block of text is moved in the document. We now recognize these tags and
treat them the same as `insert` and `delete`, respectively. So,
`--track-changes=accept` will show the moved version, while
`--track-changes=reject` will show the original version.
2016-04-15 14:09:18 -04:00
John MacFarlane
4b49f923cb Markdown reader: Fix pandoc title blocks with lines ending in 2 spaces.
Closes #2799.

Also added -s to markdown-reader-more test.
2016-04-10 09:13:53 -07:00
John MacFarlane
773bbb8fc7 Markdown + HTML readers: be more forgiving about unescaped &.
We are now more forgiving about parsing invalid HTML with
unescaped `&` as raw HTML.  (Previously any unescaped `&`
would cause pandoc not to recognize the string as raw HTML.)

Closes #2410.
2016-04-10 07:39:36 -07:00
Andrew Dunning
9765ef2ce6 LaTeX writer: Add missing languages.
Updates the list from the hyphenation files at <http://mirror.ctan.org/language/hyph-utf8/tex/generic/hyph-utf8/loadhyph/>.
2016-04-01 16:47:33 +01:00
Andrew Dunning
0c37a7c488 Recognize la-x-classic as Classical Latin.
This allows one to access the hyphenation patterns at <http://mirrors.ctan.org/language/hyph-utf8/tex/generic/hyph-utf8/patterns/tex/hyph-la-x-classic.tex>, using its private language tag.
2016-03-30 14:15:47 +01:00
John MacFarlane
f74498cb47 EPUB writer: set 'navpage' variable on nav page.
This allows templates to treat it differently.
2016-03-26 13:14:50 -07:00
John MacFarlane
9742c48647 Removed two superfluous lines. 2016-03-25 09:05:38 -07:00
John MacFarlane
f47b369f37 LaTeX writer: better positioning for hypertarget in figures.
Closes #2813.
2016-03-24 16:44:33 -07:00
John MacFarlane
bb6897a13e LaTeX writer: Fixed position of label in figures.
Partially addresses #2813.

This isn't perfect, because now the hypertarget is in the
wrong place -- when you link to the figure, the screen
is positioned with the caption at the top, and most of
the figure off screen.

So this needs a bit more tweaking.
2016-03-24 09:41:45 -07:00
John MacFarlane
499985c1a3 Updated copyright dates to include 2016. 2016-03-22 17:20:39 -07:00
John MacFarlane
b1ffdf3b01 Fixed bug in Markdown raw HTML parsing.
This was a regression, with the rewrite of `htmlInBalanced`
(from `Text.Pandoc.Readers.HTML`) in 1.17.

It caused newlines to be omitted in raw HTML blocks.

Closes #2804.
2016-03-22 16:56:10 -07:00
Mauro Bieg
44f95484a4 LaTeX Writer: fix polyglossia to babel env mapping
allow for optional argument in square brackets, closes #2728
2016-03-20 19:17:30 +01:00
John MacFarlane
3af753de47 Merge pull request #2637 from mb21/latex-figure-label
LaTeX writer: figure label
2016-03-19 13:56:14 -07:00
John MacFarlane
976e7e2054 ConTeXt writer: fix whitespace at line beginning in line blocks.
Add a `\strut` after `\crlf` before space.
Closes #2744, #2745.  Thanks to @c-foster.
This uses the fix suggested by @c-foster.

Mid-line spaces are still not supported, because of limitations
of the Markdown parser.
2016-03-18 16:36:56 -07:00
John MacFarlane
e821b05125 LaTeX writer: Avoid double toprule in headerless table with caption.
Closes #2742.
2016-03-18 16:16:18 -07:00
Jesse Rosenthal
28c7617f19 Docx reader: Handle alternate content
Some word functions -- especially graphics -- give various choices for
content so there can be backwards compatibility. This follows the
largely undocumented feature by working through the choices until we
find one that works.

Note that we had to split out the processing of child elems of runs into
a separate function so we can recurse properly. Any processing of an
element *within* a run (other than a plain run) should go into
`childElemToRun`.
2016-03-18 09:38:26 -04:00
Jesse Rosenthal
855c8b43f0 Docx reader: Don't make numbered heads into lists.
Word uses list numbering styles to number its headings. We only call
something a numbered list if it does not also heave a heading style.
2016-03-16 12:50:32 -04:00
Jesse Rosenthal
5c055b4cf3 Introduce file-scope parsing (parse-before-combine)
Traditionally pandoc operates on multiple files by first concetenating
them (around extra line breaks) and then processing the joined file. So
it only parses a multi-file document at the document scope. This has the
benefit that footnotes and links can be in different files, but it also
introduces a couple of difficulties:

  - it is difficult to join files with footnotes without some sort of
    preprocessing, which makes it difficult to write academic documents
    in small pieces.

  - it makes it impossible to process multiple binary input files, which
    can't be catted.

  - it makes it impossible to process files from different input
    formats.

This commit introduces alternative method. Instead of catting the files
first, it parses the files first, and then combines the parsed
output. This makes it impossible to have links across multiple files,
and auto-identified headers won't work correctly if headers in multiple
files have the same name. On the other hand, footnotes across multiple
files will work correctly and will allow more freedom for input formats.

Since ByteStringReaders can currently only read one binary file, and
will ignore subsequent files, we also changes the behavior to
automatically parse before combining if using the ByteStringReader. If
we use one file, it will work as normal. If there is more than one file
it will combine them after parsing (assuming that the format is the
same).

Note that this is intended to be an optional method, defaulting to
off. Turn it on with `--file-scope`.
2016-03-15 12:52:51 -04:00
Jesse Rosenthal
68fd333ec4 Add a general ByteStringReader with warnings.
Have docx reader use it.
2016-03-12 17:08:20 -05:00
Jesse Rosenthal
ee03e954d0 Add readDocxWithWarnings
The regular readDocx just becomes a special case.
2016-03-12 17:08:20 -05:00
Jesse Rosenthal
102ba9ecb8 Docx Reader: Add state to the parser, for warnings
In order to be able to collect warnings during parsing, we add a state
monad transformer to the D monad. At the moment, this only includes a
list of warning strings (nothing currently triggers them, however). We
use StateT instead of WriterT to correspond more closely with the
warnings behavior in T.P.Parsing.
2016-03-12 17:08:20 -05:00
John MacFarlane
a485c42d78 Fixed behavior of base tag.
+ If the base path does not end with slash, the last component
  will be replaced.  E.g. base = `http://example.com/foo`
  combines with `bar.html` to give `http://example.com/bar.html`.
+ If the href begins with a slash, the whole path of the base
  is replaced.  E.g. base = `http://example.com/foo/` combines
  with `/bar.html` to give `http://example.com/bar.html`.

Closes #2777.
2016-03-10 19:59:55 -08:00
mb21
139fa54d48 Docx Writer: handle image alt text
closes #2754
2016-03-10 08:56:08 +01:00
John MacFarlane
2b55b76ebe Markdown reader: Improved pipe table parsing.
Fixes #2765.
Added test case.
2016-03-09 11:46:00 -08:00
John MacFarlane
54a68616d7 Markdown reader: Clean up pipe table parsing. 2016-03-09 10:11:32 -08:00
John MacFarlane
6e950a8eb5 Markdown reader: allow + separators in pipe table cells.
We already allowed them in the header, but not in the body
rows, for some reason.  This gives compatibility with org-mode
tables.
2016-03-09 08:44:31 -08:00
John MacFarlane
4ed64835cb Markdown reader: don't cross line boundary parsing pipe table row.
Previously an emph element could be parsed across the newline
at the end of the pipe table row.

I thought this would help with #2765, but it doesn't.
2016-03-09 08:33:13 -08:00
John MacFarlane
6bfaa5ad15 DokuWiki writer: use $$ for display math. 2016-03-08 10:08:14 -08:00
Jesse Rosenthal
0b9c54d9f3 Docx reader: update feature checklist.
The feature checklist in the source code was out of date. Update.
2016-03-08 00:36:13 -05:00
John MacFarlane
7c6a3c0f69 LaTeX reader: handle interior $ characters in math.
e.g. `$$\hbox{$i$}$$`.

Partially addresses #2743.
2016-02-28 11:14:03 -08:00
Jesse Rosenthal
a7a0b452a5 Docx Reader: Get rid of Modifiable typeclass.
The docx reader used to use a Modifiable typeclass to combine both
Blocks and Inlines. But all the work was in the inlines. So most of the
generality was wasted, at the expense of making the code harder to
understand. This gets rid of the generality, and adds functions for
Blocks and Inlines. It should be a bit easier to work with going forward.
2016-02-26 08:57:53 -05:00
John MacFarlane
f2bd6fd37c Make protocol-relative URIs work again.
Closes #2737.
2016-02-23 21:58:10 -08:00
John MacFarlane
04d1e40f37 Markdown reader: use htmlInBalanced for rawVerbatimBlock.
This should give better performance.

See #2730.
2016-02-21 07:56:41 -08:00
John MacFarlane
9693de7f59 Fixed some linter warnings. 2016-02-20 22:16:39 -08:00
John MacFarlane
29706ee02d Merge pull request #2646 from tarleb/org-figure-with-no-name
Prefix even empty figure names with "fig:"
2016-02-20 21:44:39 -08:00
John MacFarlane
649cfb61b8 Merge pull request #2668 from monofon/fix/yaml-metadata-block-bottom-line
Markdown writer: Use hyphens for yaml metadata block bottom line
2016-02-20 21:43:15 -08:00
John MacFarlane
e369e60fb4 Merge pull request #2691 from tarleb/org-image-file-links
Org reader: Refactor link-target processing
2016-02-20 21:42:12 -08:00
John MacFarlane
1534052dd9 HTML reader: rewrote htmlInBalanced.
This version avoids an exponential performance problem with `<script>` tags,
and it should be faster in general.

Closes #2730.
2016-02-20 15:00:31 -08:00
Jesse Rosenthal
4438ff17fb LaTeX writer: clean up options parser.
Make sure that we require the closing bracket.
2016-02-18 23:35:38 -05:00
Jesse Rosenthal
4112b321cd LaTeX writer: treat memoir template with article opt as article
We currently treat all memoir templates as books. This means that pandoc
will infer the `--chapters` argument, even if the `article` iption is
set for memoir.

This commit makes pandoc treats the document as an article if there is
an article option (i.e., `\documentclass[12pt,article]{memoir}`).

Note that this refactors out the parsec parsers for document class and
options, to make it a little clearer what's going on.
2016-02-18 22:32:38 -05:00
John MacFarlane
b8dadc608a HTML reader: properly handle an empty cell in a simple table.
Closes #2718.
2016-02-16 11:05:51 -08:00
John MacFarlane
bbc67dee36 Removed tex_math_single_backslash from markdown_github options.
Closes #2707.
2016-02-09 22:30:52 -08:00
John MacFarlane
a692bd2872 Custom writer: Pass attributes parameter to CaptionedImage.
Closes #2697.
2016-02-05 16:49:27 -08:00
John MacFarlane
6cb4991f6b Markdown reader: Fixed bug with smart quotes around tex math.
Previously smart quotes were incorrect in the following:

    '$\neg(x \in x)$'.

(because of the following period).  This commit fixes the problem,
which was introduced by commit 4229cf2d92.
2016-02-04 12:09:26 -08:00
John MacFarlane
93a05dffd3 HTML writer: don't include alignment attribute for default table columns.
Previously these were given "left" alignment.  Better to leave off
alignment attributes altogether.

Closes #2694.
2016-02-03 13:31:21 -08:00
Jesse Rosenthal
2ee7752d14 Docx reader: Add a "Link" modifier to Reducible
We want to make sure that links have their spaces removed, and are
appropriately smushed together.

This closes #2689
2016-02-02 14:40:09 -05:00
Albert Krewinkel
92e6ae47f6 Org reader: Refactor link-target processing
Cleanup of the code for link target handling.  Most notably, the
canonicalization of a link is handled by a separate function.

This fixes #2684.
2016-01-31 23:23:09 +01:00
John MacFarlane
18745585c1 LaTeX reader: inlineCommand now gobbles an empty {} after any command.
This gives better results when people write e.g. `\TeX{}` in Markdown.

    \TeX{} and \LaTeX{}

now works as expected with `pandoc -f markdown -t latex`.

Closes #2687.
2016-01-31 10:52:46 -08:00
John MacFarlane
a02c26d9f4 HTML reader: handle multiple meta tags with same name.
Put them in a list in the metadata so they are all
preserved, rather than (as before) throwing out all
but one..
2016-01-29 11:51:01 -08:00
John MacFarlane
76983c31f2 Properly handle LaTeX "math" environment as inline math.
See #2171.
2016-01-29 10:11:45 -08:00
John MacFarlane
a1021bdda6 Textile reader: Support >, <, =, <> text alignment attributes.
Closes #2674.
2016-01-25 09:34:49 -08:00
John MacFarlane
11c5831a1f Make language extensions trigger highlighting.
For example, `py` will now work as well as `python`.
Closes jgm/highlighting-kate#83.
2016-01-24 14:15:06 -08:00
John MacFarlane
20170c328f Changed type of Shared.uniqueIdent argument from [String] to Set String.
This avoids performance problems in documents with many identically
named headers.

Closes #2671.
2016-01-22 10:16:47 -08:00
John MacFarlane
3b39b16a4b Merge pull request #2638 from c-forster/teiwriter
Add TEI Writer.
2016-01-21 15:23:50 -08:00
Henrik Tramberend
556d0c1810 Markdown writer: Use hyphens for yaml metadata block bottom line 2016-01-21 12:44:16 +01:00
Henrik Tramberend
7a18879a36 LaTeX writer: Allow more flexible table alignment 2016-01-20 13:21:26 +01:00
John MacFarlane
4d74a966c4 Added some entity tests in Markdown reader tests.
Change types of divs.

From Docbook "sect#" and "simplesect" to "level#" and
"section."

Add tests.

Add mention of TEI to README.

Small changes to TEI writer.
2016-01-19 14:03:57 -05:00
csforste
25a9ca697a Add TEI Writer. 2016-01-19 14:03:57 -05:00
John MacFarlane
f2c0974a26 HTML writer: harmless code simplification.
Since the 'math' is only put into the template if stMath is
set anyway, there's no need for this conditional.
2016-01-14 10:55:04 -08:00
John MacFarlane
f45a8e1d3b Org writer - pass through RawInline with format "org". 2016-01-13 23:01:51 -08:00
Albert Krewinkel
fabbd1aa79 Prefix even empty figure names with "fig:"
The convention used by pandoc for figures is to mark them by prefixing
the name with "fig:".  The org reader failed to do this if a figure had
no name.  The test for this was broken as well.

This fixes #2643.
2016-01-11 22:23:59 +01:00
John MacFarlane
f34382ef2c Depend on deepseq rather than deepseq-generics.
See fpco/stackage#1096.
2016-01-11 12:49:28 -08:00
John MacFarlane
8611ac56a6 Fixed regression in latex smart quote parsing.
Closes #2645.

In cases where a match was not found for a quote, everything
from the open quote to the end of the paragraph was being dropped.
2016-01-11 12:17:49 -08:00
mb21
1fde92053f LaTeX writer: figure label 2016-01-10 13:30:32 +01:00
John MacFarlane
1506e62f48 LaTeX writer: restore old treatment of Span.
A Span is rendered with surrounding {braces}.

This was a regression in 1.16.  Closes #2624.
2016-01-09 12:16:24 -08:00
John MacFarlane
729911ad74 Fixed shadowing warning. 2016-01-08 20:20:37 -08:00
John MacFarlane
5884ff6994 Work around tagsoup bug - not allowing uppercase x in hex entities.
Issue submitted at tagsoup.
2016-01-08 17:33:32 -08:00
John MacFarlane
12a5bd3c8d Entity handling fixes:
- Text.Pandoc.XML.fromEntities:  handle entities without a
  semicolon. Always lookup character references with the
  trailing ';', even if it wasn't present.  And never add
  it when looking up numerical entities.  (This is what
  tagsoup seems to require.)
- Text.Pandoc.Parsing.characterReference:  Always lookup
  character references with the trailing ';', and leave off
  the ';' when looking up numerical entities.

This fixes a regression for e.g. `&lang;`.
2016-01-08 17:08:01 -08:00
John MacFarlane
9320d359a2 Merge pull request #2629 from tarleb/org-noexport-fix
Fix function dropping subtrees tagged :noexport:
2016-01-07 11:34:27 -08:00
Albert Krewinkel
b3b00da43d Fix function dropping subtrees tagged :noexport:
Continue scanning for comment subtrees beyond only the first block.

Note to self: when writing an recursive function, don't forget to, you
know, actually recurse.

Shout to @mrvdb for noticing this.

This fixes #2628.
2016-01-07 19:56:44 +01:00
John MacFarlane
c4fdf28815 Markdown reader: renormalize table column widths if they exceed 100%.
Closes #2626.
2016-01-07 10:40:30 -08:00
John MacFarlane
a796538d84 RST, Markdown writers: Fixed rendering of grid tables with blank rows.
Closes #2615.
2016-01-05 14:04:10 -08:00
John MacFarlane
4990350fc7 Fixed v1.16 reversion with --latex-engine.
In 1.16 --latex-engine raises an error if a full path is
given. This commit fixes this reversion. Closes #2618.
2016-01-04 22:44:50 -08:00
John MacFarlane
97c9691696 Textile reader: don't allow block HTML tags in inline contexts.
The reader previously did allow this, following redcloth,
which happily parses

    Html blocks can be <div>inlined</div> as well.

as

    <p>Html blocks can be <div>inlined</div> as well.</p>

This is invalid HTML, and this kind of thing can lead
to parsing problems (stack overflows) as well.  So this
commit undoes this behavior.  The above sample now produces;

    <p>Html blocks can be</p>
    <div>
    <p>inlined</p>
    </div>
    <p>as well.</p>
2016-01-02 22:34:06 -08:00
John MacFarlane
75695b1817 MediaWiki reader: interpret markup inside <tt>, <code>.
Closes #2607.
2016-01-02 12:26:16 -08:00
John MacFarlane
a68e072bac MediaWiki writer: fix spacing issues.
+ Start cell on new line unless it's a single Para or Plain.
+ For single Para or Plain, insert a space after the `|` to
  avoid problems when the text begins with a character like
  `-`.

Closes #2604, closes #2606.
2016-01-02 12:14:12 -08:00
John MacFarlane
b27783e2ec Use cmark 0.5.
Closes #2605.
2015-12-29 19:52:06 -08:00
John MacFarlane
297345098d ConTeXt writer: set default layout based on margin-left, etc.
This sets up `\setuplayout` based on the variables `margin-left`,
`margin-right`, `margin-bottom`, and `margin-top`, if no layout
is given.
2015-12-22 13:28:11 -08:00
John MacFarlane
f9202f5d39 LaTeX writer: create defaults for geometry using margin-left etc.
If `geometry` has no value, but `margin-left`, `margin-right`,
`margin-top`, and/or `-margin-bottom` are given, a default value
for `geometry` is created from these.

Note that these variables already affect PDF production via HTML5
with wkhtmltopdf.
2015-12-22 13:10:46 -08:00
John MacFarlane
35e0544977 LaTeX reader: allow blank space between braced arguments of commands.
For example

    \foo
    {bar}
    {baz}

Closes #2592.
2015-12-22 11:06:06 -08:00
John MacFarlane
46e38d0a0a Improved treatment of margins in wkhtmltopdf. 2015-12-21 23:47:03 -08:00
John MacFarlane
8b8bdca56a Allow setting margins from metadata variables for wkhtmltopdf.
Variables margin-top, margin-bottom, margin-left, margin-right.
Setting them with css inside @page doesn't seem to work, at least
with the released wkhtmltopdf.
2015-12-21 22:59:01 -08:00
John MacFarlane
0596b65a74 pdf via wkhtmltopdf: take title and page-size from metadata.
Adjusted default `page-size` to `letter`, to match current LaTeX
template.
2015-12-21 22:13:44 -08:00
John MacFarlane
0a768f1cc5 Added preliminary support for PDF creation via wkhtmltopdf.
To use this:

    pandoc -t html5 -o result.pdf

(and add `--mathjax` if you have math.)
2015-12-21 17:22:12 -08:00
John MacFarlane
28b2d86b21 LaTeX/Beamer template changes (Thomas Hodgson):
* Added `thanks` variable
* Use `parskip.sty` when `indent` isn't set (fall
  back to using `setlength` as before if `parskip.sty`
  isn't available).
* Use `biblio-style` with biblatex.
* Added `biblatexoptions` variable.
* Added `section-titles` variable (defaults to true)
  to enable/suppress section title pages in beamer
  slide shows.
* Moved beamer themes after fonts, so that themes can
  change fonts.  (Previously the fonts set were being
  clobbered by lmodern.sty.)
2015-12-19 18:50:45 -08:00
John MacFarlane
9333814254 Added needed import of FromJSON.
Fixes build failure.
2015-12-19 17:54:20 -08:00
John MacFarlane
770641f741 Fix language code for Czech (cs not cz)
Closes #2597.
2015-12-19 17:54:02 -08:00
John MacFarlane
4c103f67f9 Merge branch 'master' of https://github.com/AndreasLoow/pandoc into AndreasLoow-master 2015-12-19 00:07:28 -08:00
John MacFarlane
e20f433f38 Markdown reader: fixed parsing bug with macros.
Previously macro definitions in indented code blocks
were being parsed as macro definitions, not code.
2015-12-19 00:00:04 -08:00
mb21
1ead1f39ad ICML writer: intersperse line breaks
instead of appending them to every ParagraphStyleRange
closes #2501
2015-12-17 10:26:59 +01:00
mb21
f3a9bdafef ICML writer: added figure handling, closes #2590 2015-12-16 11:07:23 +01:00
John MacFarlane
9f43acb5d2 ICML writer: removed redundant import. 2015-12-13 22:18:23 -08:00
John MacFarlane
f3133a8e9e Merge pull request #2570 from mb21/rst-reader-imgattrs
Image attributes
2015-12-13 20:29:13 -08:00
John MacFarlane
a924a3f43d Fixed ICML image syntax for local files.
`file:filename` rather than `file://./filename`.

I think this is right; it matches what we had before
with people actually using the ICML writer, and seems
to match examples in the spec.  I don't
have a copy of InDesign I can test on, though.
@DigitalPublishingToolkit and @mb21, can you have
a look?
2015-12-13 20:19:34 -08:00
John MacFarlane
90b8024fac Use posix path separators in ICML link URIs.
Closes #2589.
2015-12-13 17:40:24 -08:00