Commit graph

5441 commits

Author SHA1 Message Date
Jesse Rosenthal
ae8c0cdba8 Docx reader: Parse instrText info in fldChar tags.
We introduce a new module, Text.Pandoc.Readers.Docx.Fields which
contains a simple parsec parser. At the moment, only simple hyperlink
fields are accepted, but that can be extended in the future.
2018-01-16 13:22:02 -05:00
Jesse Rosenthal
404706d29a Docx reader: Parse fldChar tags
This will allow us to parse instrTxt inside fldChar tags.
2018-01-16 13:22:02 -05:00
Robert Schütz
b2268b1fc7 LaTeX writer: escape & in lstinline 2018-01-16 16:34:39 +01:00
n3fariox
f5f0b76636 HTML reader: Fix col width parsing for percentages < 10% (#4262)
Rather than take user input, and place a "0." in front, actually
calculate the percentage to catch cases where small column sizes
(e.g. `2%`)  are needed.
2018-01-15 21:46:12 -07:00
Henri Menke
6910267abf ConTeXt writer: Use xtables instead of Tables (#4223)
- Default to xtables for context output.
- Added `ntb` extension (affecting context writer only) to use Natural Tables instead.
- Added `Ext_ntb` constructor to `Extension` (API change).
2018-01-15 18:38:33 -07:00
Jesse Rosenthal
c6a55f8e9f Powerpoint writer: Improve table placement. 2018-01-15 15:51:58 -05:00
Jesse Rosenthal
e408ae6278 Powerpoint writer: Make our own _rels/.rels file.
The toplevel .rels file could have a thumbnail image if taken from the
template. Rather than removing it from the inherited file, it's easier
to just make our own.
2018-01-15 15:35:06 -05:00
Jesse Rosenthal
f79a6f1163 Powerpoint writer: Import reference-doc images properly.
There was a glob error that was leading to images from the
reference-doc pptx not being imported. We don't need a glob here --
just replace it with `isPrefixOf`.
2018-01-15 14:48:35 -05:00
John MacFarlane
4b7bc40e8b Renaming: Json -> JSON in modules and functions. 2018-01-15 10:46:40 -08:00
John MacFarlane
f114153481
Merge pull request #4227 from tarleb/lua-run-json-filter
Run JSON filters from Lua filters
2018-01-15 11:43:46 -07:00
Jesse Rosenthal
b010113f3f Powerpoint writer: Move Presentation.hs out of PandocMonad
We don't need it for anything but the log messages, and we can just
keep track of that in state and pass it along to the `writePowerpoint`
function. This will simplify the code.
2018-01-15 10:01:59 -05:00
Jesse Rosenthal
a7d131cf44 Powerpoint writer: Ignore anchor links to nowehere.
We don't convert a '#target' ExternalTarget to an InternalTarget if
`target` is not in the AnchorMap. We just remove the link. This
prevents broken links in the Powerpoint output.
2018-01-15 08:56:20 -05:00
Jesse Rosenthal
3156722ac4 Powerpoint writer: Fix anchor links.
They were broken when I refactored (the Output module wanted to use
state left over from the construction of the Presentation type). This
change introduces a new type `LinkTarget = InternalTarget |
ExternalTarget`. Internal target points to a slide number, and these
will all be resolved before the Presentation is passed along to the
Output module.
2018-01-14 21:59:06 -05:00
John MacFarlane
615a99c2c2 RST reader: add aligned environment when needed in math.
rst2latex.py uses an align* environment for math in
`.. math::` blocks, so this math may contain line breaks.
If it does, we put the math in an `aligned` environment
to simulate rst2latex.py's behavior.

Closes #4254.
2018-01-14 15:11:11 -08:00
John MacFarlane
d9584d73f9 Markdown reader: Improved inlinesInBalancedBrackets.
The change both improves performance and fixes a
regression whereby normal citations inside inline notes
were not parsed correctly.

Closes jgm/pandoc-citeproc#315.
2018-01-14 12:24:21 -08:00
John MacFarlane
4debcf7bdc LaTeX reader: Advance source position at end of stream. 2018-01-14 12:24:21 -08:00
Jesse Rosenthal
431f6166fa Powerpoint writer: Refactor into separate modules.
There are two steps in the conversion: a conversion from pandoc to a
Presentation datatype modeling pptx, and a conversion from
Presentation to a pptx archive. The two steps were sharing the same
state and environment, and the code was getting a bit
spaghetti-ish. This separates the conversion into separate
modules (T.P.W.Powerpoint.Presentation, which defineds the
Presentation datatype and goes Pandoc->Presentation)
and (T.P.W.Pandoc.Output, which goes Presentation->Archive).
Text.Pandoc.Writers.Powerpoint a thin wrapper around the two modules.
2018-01-14 09:39:39 -05:00
Jesse Rosenthal
90dcd0bc87 Powerpoint writer: Avoid overlapping blocks in column output.
Just as a slide can't have an image and text on the same slide because
of overlapping, we can't have both in a single column. We run
splitBlocks on the text in the column and discard the rest.
2018-01-14 01:50:16 -05:00
Jesse Rosenthal
64c4451ef3 Powerpoint writer: Position images correctly in two-column layout.
You can have two images side-by-side, or text alongside an image. The
image will be fit correctly within the column.
2018-01-14 01:50:16 -05:00
Jesse Rosenthal
1577289672 Powerpoint writer: Make content shape retrieval environment-aware
We put `getContentShape` and `getContentShapeSize` inside the P monad,
so that we can (in the future) make use of knowledge of what slide
environment we're in to get the correct shape. This will allow us, for
example, to get individual columns for a two-column layout, and place
images in them appropriately.
2018-01-14 01:50:16 -05:00
John MacFarlane
e7d95cadf5 LaTeX reader: pass through macro defs in rawLaTeXBlock...
even if the `latex_macros` extension is set.
This reverts to earlier behavior and is probably safer
on the whole, since some macros only modify things in
included packages, which pandoc's macro expansion can't
modify.

Closes #4246.
2018-01-13 22:12:32 -08:00
John MacFarlane
485535464d LaTeX reader: fixed pos calculation in tokenizing escaped space. 2018-01-13 22:04:55 -08:00
Jesse Rosenthal
50b64bcf1c Powerpoint writer: Improve image handling.
We now determine image and caption placement by getting the dimensions
of the content box in a given layout. This allows for images to be
correctly sized and positioned in a different template.

Note that iamges without captions and headers are no longer
full-screened. We can't do this dependably in different layouts,
because we don't know where the header is (it could be to the side of
the content, for example).
2018-01-13 21:42:38 -05:00
John MacFarlane
44222e0373 LaTeX reader: allow macro definitions inside macros.
Previously we went into an infinite loop with

```
\newcommand{\noop}[1]{#1}
\noop{\newcommand{\foo}[1]{#1}}
\foo{hi}
```

See #4253.
2018-01-13 12:11:36 -08:00
Jesse Rosenthal
944ed5e098 Powerpoint writer: read presentation size from reference file.
Our presentation size is now dependent on the reference/template file
we use. This will make it easier to set different output sizes by
supplying different reference files. The alternative (allowing a user
to explicitly set output size regardless of the template) will lead to
too many thorny issues, as explicitly set sizes at the various level
of powerpoint layout would have to be reset.
2018-01-13 14:58:46 -05:00
Jesse Rosenthal
e08776b9d5 Powerpoint writer: code cleanup
Last commit accidentally left commented-out code in.
2018-01-13 09:34:03 -05:00
Jesse Rosenthal
a842d3ae7d Powerpoint writer: Handle (sub)headers above slidelevel correctly.
Above the slidelevel, subheaders will be printed in bold and given a
bit of extra space before them. Note that at the moment, no
distinction is made between levels of headers above the slide header,
though that can be changed. (It has to be changed in pandoc, since
PowerPoint has no concept of paragraph or character classes.)

This allows us to clean up the code as well: the code in
`blockToParagraphs` since it will only touch content blocks, and
therefore will not deal with headers at or below the slidelevel.
2018-01-13 09:08:28 -05:00
Jesse Rosenthal
194f08d17a Powerpoint writer: Check for required files
Since we now import from reference/dist file by glob, we need to make
sure that we're getting the files we need to make a non-corrupt
Powerpoint. This performs that check.

(In the process, this change also cleaned up a lot of commented-out
code left from the switch to the new reference-doc method.)
2018-01-13 07:37:02 -05:00
Jesse Rosenthal
a2870a1aeb Powerpoint writer: Improve templating using --reference-doc
Templating should work much more reliably now. There is still some
problem with image placement when we change sizes. A further commit
will address this.
2018-01-12 22:59:03 -05:00
Albert Krewinkel
8d5422f36b
Lua modules: add function pandoc.utils.run_json_filter
Runs a JSON filter on a Pandoc document.
2018-01-13 00:07:03 +01:00
Albert Krewinkel
5d49cbd35e
Move filter functions to separate module 2018-01-13 00:05:11 +01:00
Albert Krewinkel
6528082401
Lua filters: improve error messages
Provide more context about the task which caused an error.
2018-01-12 21:28:27 +01:00
Jesse Rosenthal
f130109b90 Powerpoint writer: Include Notes slide in TOC 2018-01-12 14:27:53 -05:00
Albert Krewinkel
5b852f8d2a
Lua filters: make PANDOC_READER_OPTIONS available
The options which were used to read the document are made available to
Lua filters via the `PANDOC_READER_OPTIONS` global.
2018-01-12 18:54:19 +01:00
Jesse Rosenthal
624abeec5c Powerpoint writer: allow setting toc-title in metadata.
Accompanying change in MANUAL.txt
2018-01-12 11:09:17 -05:00
Jesse Rosenthal
6d74b35751 Move metaValueToInlines to T.P.W.Shared
This will allow the Powerpoint writer to use it as well.
2018-01-12 11:06:03 -05:00
Jesse Rosenthal
1d9c2770e3 Powerpoint writer: Set notes slide header with slide-level
It used to be hardcoded to 2. This will set it to the appropriate
slide-level.
2018-01-12 10:48:28 -05:00
Jesse Rosenthal
021e5ac89d Powerpoint writer: Add table of contents
This is triggered by the `--toc` flag. Note that in a long slide deck
this risks overrunning the text box. The user can address this by
setting `--toc-depth=1`.
2018-01-12 10:43:02 -05:00
Jesse Rosenthal
4ce07c20d7 Powerpoint writer: Set notes slide number correctly
Previously, this hadn't been aware of a metadata slide. We also
clarify the logic for setting the startnumber of different slide
sections correctly.
2018-01-12 10:00:59 -05:00
Jesse Rosenthal
53c48dd2c9 Powerpoint writer: Ignore internal links without targets.
If the user entered an internal link without a corresponding anchor,
it would produce a corrupted file. Now we check the anchor map, and
make sure the target is in the file. If it isn't, we ignore it.
2018-01-12 09:45:01 -05:00
Jesse Rosenthal
0b66b56523 Powerpoint writer: Clean up adding metadata slide
We want to count the slide numbers correctly if it's in there.
2018-01-12 09:24:15 -05:00
Jesse Rosenthal
2afca42f77 Powerpoint writer: Add anchor links
For anchor-type links (`[foo](#bar)`) we produce an anchor link. In
powerpoint these are links to slides, so we keep track of a map
relating anchors to the slides they occur on.
2018-01-12 06:56:09 -05:00
Jesse Rosenthal
da72d0f412 Powerpoint writer: Make the slide number available to the blocks.
For anchors, block-processing functions need to know what slide number
they're in. We make the envCurSlideId available to blocks.
2018-01-12 06:56:09 -05:00
Jesse Rosenthal
206545c675 Powerpoint writer: move curSlideId to environment.
It really isn't a moving state, and that can be misleading.
2018-01-12 06:56:09 -05:00
John MacFarlane
c5ba3b8ee3 LaTeX reader: fix inconsistent column widths.
This fixes a bug whereby column widths for the body were
different from widths for the header in some tables.

Closes #4238.
2018-01-10 12:28:42 -08:00
John MacFarlane
49007ded7b RST reader: better handling for headers with an anchor.
Instead of creating a div containing the header, we put
the id directly on the header. This way header promotion
will work properly. Closes #4240.
2018-01-10 12:07:33 -08:00
newmana
6b40b8c27c Add header and footer parameters 2018-01-10 13:58:35 +10:00
John MacFarlane
e3f01235e9 HTML writer: Fixed footnote backlinks with --id-prefix.
Closes #4235.
2018-01-09 15:29:27 -08:00
John MacFarlane
ae6ba1533b Use latest skylighting and omit the 'missingincludes' check.
If you use a custom syntax definition that refers to a syntax
you haven't loaded, pandoc will now complain when it is highlighting
the text, rather than at the start.

This saves a huge performance hit from the `missingIncludes` check.

Closes #4226.
2018-01-07 19:24:08 -08:00
Albert Krewinkel
f5dec4bdc1
Lua: make pandoc-types version available as PANDOC_API_VERSION
The current pandoc-types version is made available to Lua programs in
the global PANDOC_API_VERSION. It contains the version as a list of
numbers.
2018-01-07 14:06:34 +01:00