Commit graph

3913 commits

Author SHA1 Message Date
Jesse Rosenthal
1138ae6656 Docx reader utils: handle empty namespace in elemName
Previously, if given an empty namespace:

    (elemName ns "" "foo")

`elemName` would output a QName with a `Just ""` namespace. This is
never what we want. Now we output a `Nothing`. If someone *does* want a
`Just ""` in the namespace, they can enter the QName value explicitly.
2016-11-02 12:10:45 -04:00
John MacFarlane
bdda4b185b HTML reader: treat <math> as MathML by default...
unless something else is explicitly specified in xmlns.
Provided it parses as MathML, of course.

Also fixed default which should be to inline math if no
display attribute is used.
2016-11-02 16:43:36 +01:00
John MacFarlane
705df61198 LaTeX reader: Handle BVerbatim from fancyvrb. Fixes #3203. 2016-11-02 12:05:56 +01:00
John MacFarlane
eb5cb0f304 Handle hungarumlaut in LaTeX reader. Closes #3201. 2016-11-01 10:17:15 +01:00
hubertp-lshift
01a21dd43f [odt] Infer tables' header props from rows (#3199)
ODT reader simply provided an empty header list
which meant that the contents of the whole table,
even if not empty, was simply ignored.
While we still do not infer headers we at least have
to provide default properties of columns.
2016-11-01 10:07:39 +01:00
John MacFarlane
5d02e478d0 LaTeX reader: allow for []s inside LaTeX optional args.
Fixes cases like:

    \begin{center}
    \begin{tikzpicture}[baseline={([yshift=+-.5ex]current bounding box.center)}, level distance=24pt]
    \Tree [.{S} [.NP John\index{i} ] [.VP [.V likes ] [.NP himself\index{i,*j} ]]]
    \end{tikzpicture}
    \end{center}
2016-10-31 22:04:22 +01:00
Albert Krewinkel
4f06e6c445
Org reader: support ATTR_HTML for special blocks
Special blocks (i.e. blocks with unrecognized names) can be prefixed
with an `ATTR_HTML` block attribute.  The attributes defined in that
meta-directive are added to the `Div` which is used to represent the
special block.

Closes: #3182
2016-10-30 20:23:53 +01:00
Albert Krewinkel
63bdc5d08f
Org reader: support the todo export option
The `todo` export option allows to toggle the inclusion of TODO keywords
in the output.  Setting this to `nil` causes TODO keywords to be dropped
from headlines.  The default is to include the keywords.
2016-10-30 13:20:25 +01:00
Albert Krewinkel
d5182778c4
Org reader: add support for todo-markers
Headlines can have optional todo-markers which can be controlled via the
`#+TODO`, `#+SEQ_TODO`, or `#+TYP_TODO` meta directive.  Multiple such
directives can be given, each adding a new set of recognized todo-markers.
If no custom todo-markers are defined, the default `TODO` and `DONE`
markers are used.

Todo-markers are conceptually separate from headline text and are hence
excluded when autogenerating headline IDs.

The markers are rendered as spans and labelled with two classes: One
class is the markers name, the other signals the todo-state of the
marker (either `todo` or `done`).
2016-10-30 10:27:47 +01:00
Daniele D'Orazio
78e4fbda51 Markdown Reader: add attributes for autolink (#3183) 2016-10-26 12:18:58 +02:00
John MacFarlane
c46ad7c8db reveal.js: don't change slide title to level 1 header.
This also affects other HTML slide show formats.

Closes #2221.
2016-10-25 17:07:51 +02:00
John MacFarlane
d51e475bad Export Text.Pandoc.Error in Text.Pandoc.
[API change]
2016-10-24 22:31:36 +02:00
John MacFarlane
bf72a482eb Tighten up parsing of raw email addresses.
Technically `**@user` is a valid email address, but if we
allow things like this, we get bad results in markdown flavors
that autolink raw email addresses. (See #2940.)
So we exclude a few valid email addresses in order to
avoid these more common bad cases.

Closes #2940.
2016-10-23 23:12:36 +02:00
Thomas Weißschuh
96fa1daa6e fix example in documentation (#3176)
Errors are encountered while reading, not writing
2016-10-23 21:48:22 +02:00
Mauro Bieg
9dd18ebf34 ICML writer: replace partial function (!!) in table handling (#3175) 2016-10-23 21:42:33 +02:00
John MacFarlane
696dfbc993 Added angle_brackets_escapable extension.
This is needed because github flavored Markdown has a slightly
different set of escapable symbols than original Markdown;
it includes angle brackets.

Closes #2846.
2016-10-22 23:41:55 +02:00
John MacFarlane
d2a6533d6e EPUB reader: don't add root path to data: URIs.
Closes #3150.

Thanks to @lep for the bug report and patch.
2016-10-22 23:07:15 +02:00
John MacFarlane
1da40d63b1 Merge pull request #3108 from tarleb/part
Add command line option allowing to set type of top-level divisions
2016-10-19 14:07:44 +02:00
Albert Krewinkel
595a171407
Add option for top-level division type
The `--chapters` option is replaced with `--top-level-division` which allows
users to specify the type as which top-level headers should be output. Possible
values are `section` (the default), `chapter`, or `part`.

The formats LaTeX, ConTeXt, and Docbook allow `part` as top-level division, TEI
only allows to set the `type` attribute on `div` containers.  The writers are
altered to respect this option in a sensible way.
2016-10-19 13:12:57 +02:00
Hubert Plociniczak
dd799df0ae Image with a caption needs special formatting
Latex Writer only handles captions if the image's title
is prefixed with 'fig:'.
2016-10-19 11:40:44 +02:00
John MacFarlane
4a2a7a21e5 Merge pull request #3166 from hubertp-lshift/bug/3134
Issue 3143: Don't duplicate text for anchors
2016-10-18 22:03:45 +02:00
John MacFarlane
0cd11b3e54 Merge pull request #3165 from hubertp-lshift/feature/odt-image
[odt] images parser
2016-10-18 22:00:58 +02:00
John MacFarlane
8264ae2abe Better fix for the problem with ghc 7.8. 2016-10-18 16:25:13 +02:00
John MacFarlane
3747abf029 Try to fix build error on ghc 7.8.
@tarleb this is an interesting one, see the build log in
https://travis-ci.org/jgm/pandoc/jobs/168612017

It only failed on ghc 7.8; I think this must have to do with
the change making Monad a superclass of Applicative, hence
this change.
2016-10-18 16:03:34 +02:00
Hubert Plociniczak
c74c5fdd97 Issue 3143: Don't duplicate text for anchors
When creating an anchor element we were adding its representation
as well as the original content, leading to text duplication.
2016-10-18 10:50:37 +02:00
Albert Krewinkel
1266b210ac
Org writer: drop space before footnote markers
The writer no longer adds an extra space before footnote markers.

Fixes: #3162
2016-10-17 22:11:03 +02:00
Hubert Plociniczak
4417e33ea9 Use bind function instead of pattern matching 2016-10-17 16:58:53 +02:00
Hubert Plociniczak
7234321e8f Minor refactoring 2016-10-17 16:50:03 +02:00
Hubert Plociniczak
a02f276ff1 Infer caption from the text following the img
Frame can contain other frames with the text boxes.
This is something that has not been considered before
and meant that the whole construction of images was
broken in those cases. Also the captions were fixed/ignored.
2016-10-17 16:35:13 +02:00
Jesse Rosenthal
e666c92bc9 RST reader: skip whitespace before note.
RST requires a space before a footnote marker. We discard those spaces
so that footnotes will be adjacent to the text that comes before
it. This is in line with what rst2latex does. rst2html does not discard
the space, but its html output is different than pandoc's, so this seems
the most semantically correct approach.

Closes #3163
2016-10-17 09:54:59 -04:00
Albert Krewinkel
462c140eb6
Org reader: allow figure with empty caption
A `#+CAPTION` attribute before an image is enough to turn an image into a
figure. This wasn't the case because the `parseFromString` function, which
processes the caption value, would fail on empty values. Adding a newline
character to the caption value fixes this.

Fixes: #3161
2016-10-14 23:16:51 +02:00
John MacFarlane
9bd1da122a Merge pull request #3146 from hubertp-lshift/feature/odt-list-start-value
[ODT Parser] Include list's starting value
2016-10-14 15:15:50 +02:00
Hubert Plociniczak
9282fadc6b Added tests and a corner case for starting number
Review revealed that we didn't handle the case
when the starting point is an empty string. While
this is not a valid .odt file, we simply added
a special case to deal with it.

Also added tests for the new feature.
2016-10-14 13:56:24 +02:00
Jesse Rosenthal
cd1427876e Markdown writer: Abstract out note/ref function.
We do basically the same thing every time we insert notes, so let's cut
down on code duplication.
2016-10-13 11:04:35 -04:00
John MacFarlane
6d13567ac5 Allow http-client 0.4.30, which is the version in stackage lts.
Previously we required 0.5.
Remove CPP conditionals for earlier versions.
2016-10-13 13:01:49 +02:00
John MacFarlane
4a1ef0b51d Revert "Remove http-client CPP conditionals."
This reverts commit 3f82471355.

We might want to revert the requirement of http-client 0.5,
as this is not yet in Stackage and that is starting to
cause problems.  I can't recall why it is there.
2016-10-13 12:35:58 +02:00
Albert Krewinkel
3e60ed9c03
Allow empty lines when parsing line blocks
Line blocks are allowed to contain empty lines and should be parsed as a
single block in that case.  Previously an empty (line block) line would
have terminated parsing of the line block element.
2016-10-13 08:46:44 +02:00
Albert Krewinkel
c9460e7013
Parse line-oriented markup as LineBlock
Markup-features focusing on lines as distinctive part of the markup are read
into `LineBlock` elements. This currently means line blocks in reStructuredText
and Markdown (the latter only if the `line_block` extension is enabled), the
`linegroup`/`line` combination from the Docbook 5.1 working draft, and Org-mode
`VERSE` blocks.
2016-10-13 08:46:44 +02:00
Albert Krewinkel
22cb9e3327
Add support for the LineBlock element to writers
The following markup features are used to output the lines of the `LineBlock`
element:

  - AsciiDoc: a `[verse]` block,
  - ConTeXt: text surrounded by `\startlines` and `\endlines`,
  - HTML: `div` with an per-element style setting to interpret the content as
    pre-wrapped,
  - Markdown: line blocks if the `line_blocks` extension is enabled, a simple
    paragraph with hard linebreaks otherwise,
  - Org: VERSE block,
  - RST: a line block, and
  - all other formats: a paragraph, containing hard linebreaks between lines.

Custom lua writers should be updated to use the `LineBlock` element.
2016-10-13 08:46:44 +02:00
Albert Krewinkel
64b77cc2c5
Shared: add function combining lines using LineBreak
The `linesToBlock` function takes a list of lines and combines them by appending
a hard `LineBreak` to each line and concatenating the result, putting the result
it into a `Para`. This is most useful when dealing when converting `LineBlock`
elements.
2016-10-13 08:46:38 +02:00
Hubert Plociniczak
edc951ee7d [ODT Parser] Include list's starting value
Previously the starting value of the lists' items has been
hardcoded to 1. In reality ODT's list style definition can
provide a new starting value in one of its attributes.

Writers already handle the modified start value so no need
to change anything in that area.
2016-10-12 18:36:40 +02:00
Hubert Plociniczak
c924611de5 Basic support for images in ODT documents
Highly influenced by the docx support, refactored
some code to avoid DRY.
2016-10-12 17:50:35 +02:00
John MacFarlane
901045b0bb Merge pull request #3159 from jkr/refs
Specify location for footnotes (and reference links) in MD output
2016-10-12 11:11:06 +02:00
Jesse Rosenthal
ca50deeeee Markdown writer: Allow footnotes/refs at the end of blocks, sections
This allows footnotes and refs to be placed at the end of blocks and
sections. Note that we only place them at the end of blocks that are at
the top level and before headers that are the top level. We add an
environment variable to keep track of this. Because we clear the
footnotes and refs when we use them, we also add a state variable to
keep track of the starting number.

Finally, note that we still add any remaining footnotes at the end. This
takes care of the final section, if we are placing at the end of a
section, and will always come after a final block as well.
2016-10-11 15:17:01 -04:00
Jesse Rosenthal
6914808139 Add ReaderT monad for environment variables.
This will make it easier to keep track of what level of block we are at.
2016-10-11 13:53:47 -04:00
Jesse Rosenthal
27113bda1f Options: Add references location.
This will be used by the markdown writer for deciding where to put links
and footnotes.
2016-10-11 13:30:01 -04:00
Albert Krewinkel
bb48f2edc4
Org reader: trim verse lines properly
An empty verse line should not result in `Str ""` but in `mempty`.
2016-10-10 21:12:47 +02:00
John MacFarlane
f4b7ab125e More checks for Ext_raw_html when rendering HTML in Markdown.
Previously we'd emit raw HTML tables even if the `raw_html`
extension was disabled.

Now we just emit `[TABLE]` if no table formats are enabled
and raw HTML is not enabled.

We also check for the `raw_html` extension before emiting
a raw HTML block.

Closes #3154.
2016-10-10 11:23:04 +02:00
KolenCheung
46be319ca9 removed mmd raw_tex in src/Text/Pandoc/Options.hs 2016-10-09 21:30:03 +02:00
Jesse Rosenthal
6d05c378d0 Docx writer: Move one more env var to Reader monad
PrintWidth is set at the beginning and stays the same throughout the
document writing, so we just set it as an env variable in the Reader
monad.
2016-10-05 08:15:55 -04:00
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