Comparing changes
Open a pull request
jgm |
stack.yaml: Use pandoc-types commit with SoftBreak.
|
83c56bd
|
||
jgm |
Markdown reader: parse soft break as SoftBreak.
|
63d875c
|
jgm |
Implemented SoftBreak and new `--wrap` option.
Added threefold wrapping option. * Command line option: deprecated `--no-wrap`, added `--wrap=[auto|none|preserve]` * Added WrapOption, exported from Text.Pandoc.Options * Changed type of writerWrapText in WriterOptions from Bool to WrapOption. * Modified Text.Pandoc.Shared functions for SoftBreak. * Supported SoftBreak in writers. * Updated tests. * Updated README. Closes #1701. |
536b6bf
|
||
jgm |
Removed deprecated options `--offline` and `--html5`.
These have been deprecated forever. |
b747243
|
||
jgm |
FB2 writer: support SoftBreak.
This was omitted earlier. |
1b0e099
|
||
jgm |
Fixed cite key parsing regression.
We were capturing final colons as in [@foo: bar]; the citation id was being parsed as "@foo:". Closes jgm/pandoc-citeproc#201. |
28a2f4c
|
||
jgm |
Restore no wrapping of XML in Docx, ODT.
It's possible that wrapping causes problems; safer to turn it off. |
47cc5ad
|
||
jgm |
Updated pandoc-types commit in stack.yaml
|
d9c2f50
|
||
jgm |
Modified readers to emit SoftBreak when appropriate.
|
af7e782
|
||
jgm |
Test fixes.
|
d6a4c70
|
||
jgm |
stack.yaml - use latest pandoc-types.
|
9ce7029
|
jgm |
Fixed tests.
|
202d848
|
||
jgm |
Update to use latest releases of highlighting-kate and texmath.
|
60d383e
|
||
jgm |
Implemented `east_asian_line_breaks` extension.
Text.Pandoc.Options: Added `Ext_east_asian_line_breaks` constructor to `Extension` (API change). This extension is like `ignore_line_breaks`, but smarter -- it only ignores line breaks between two East Asian wide characters. This makes it better suited for writing with a mix of East Asian and non-East Asian scripts. Closes #2586. |
44120ea
|
||
jgm |
AsciiDoc writers: Add anchors on Div elements.
This partially addresses jgm/pandoc-citeproc#143. It does not use the native asciidoc syntax for citations, but it does get the links to individual citations working. |
3e079a2
|
||
jgm |
AsciiDoc writer: support anchors in spans with id elements.
|
e4b3da6
|
||
mb21 |
RST reader: image attributes
|
30644b2
|
||
mb21 |
new function to extract multiple properties at once in CSS.hs
and use it in Textile reader |
2060f5f
|
||
mb21 |
Docx reader: image attributes
|
37931cb
|
||
mb21 |
ODT/OpenDocument writer: improved image attributes
- support for percentage widths/heights - use Attr instead of title to get dimensions from ODT walker to writeOpenDocument |
df68f25
|
jgm |
Use lts-3.18 resolver to avoid Windows build problems.
|
6c8a930
|
||
jgm |
Use lts-3.18 in stack.yamls.
|
36c589a
|
||
jgm |
Use posix path separators in ICML link URIs.
Closes #2589. |
90b8024
|
||
jgm |
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? |
a924a3f
|
||
jgm |
Merge pull request #2570 from mb21/rst-reader-imgattrs
Image attributes |
f3133a8
|
||
jgm |
ICML writer: removed redundant import.
|
9f43acb
|
||
jgm |
Updated changelog.
|
3573d99
|
||
jgm |
Removed deprecated --strict option entirely.
|
678e7da
|
||
jgm |
Removed "compatibility mode" when called as hsmarkdown.
|
c16efea
|
||
jgm |
Factored out convertWithOpts
|
a6d810a
|
jgm |
Fixed benchmark for new API.
|
3e005aa
|
||
jgm |
Reorganized changelog.
|
7c22959
|
mb21 |
ICML writer: added figure handling, closes #2590
|
f3a9bda
|
||
jgm |
Merge pull request #2591 from mb21/ICML-figures
ICML writer: added figure handling, closes #2590 |
2af6bf3
|
||
jgm |
Fixed typos in changelog.
Thanks to Ophir Lifshitz. |
62910d4
|
||
jgm |
Updated changelog.
|
d925cd6
|
mb21 |
ICML writer: intersperse line breaks
instead of appending them to every ParagraphStyleRange closes #2501 |
1ead1f3
|
||
adunning |
Document change to subtitle in LaTeX.
One could also tell users to add this to header-includes if `subtitle` is desired for `article` and so forth, but I will leave it out for now for the sake of simplicity: ```tex \providecommand{\subtitle}[1]{% \usepackage{titling} \posttitle{% \par\large#1\end{center}} } ``` |
eb8a758
|
jgm |
Merge pull request #2594 from adunning/patch-1
Document change to subtitle in LaTeX. |
e670435
|
||
jgm |
Merge pull request #2593 from mb21/icml-linebreaks
ICML writer: intersperse line breaks |
efb34a1
|
||
jgm |
Explain how to get `subtitle` to work with latex article etc.
Thanks to Andrew Dunning. |
ad3ef55
|
||
jgm |
Markdown reader: fixed parsing bug with macros.
Previously macro definitions in indented code blocks were being parsed as macro definitions, not code. |
e20f433
|
||
jgm |
README: reflowed to avoid overly long lines.
|
ce21b2c
|
||
jgm |
Merge branch 'master' of https://github.com/AndreasLoow/pandoc into A…
…ndreasLoow-master |
4c103f6
|
||
jgm |
Merge branch 'AndreasLoow-master'
|
2998618
|
jgm |
Fix language code for Czech (cs not cz)
Closes #2597. |
770641f
|
||
jgm |
Added needed import of FromJSON.
Fixes build failure. |
9333814
|
||
jgm |
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.) |
28b2d86
|
||
jgm |
Beamer: Moved header-includes before setting of title etc.
This matches a change already made in the LaTeX template (Thomas Hodgson). Closes jgm/pandoc-templates#168 |
6924937
|
||
twsh |
Removed hyphen
|
cab20a9
|
||
jgm |
Updated changelog
|
5c4e247
|
||
jgm |
Merge pull request #2598 from twsh/biblatexoptions
Removed hyphen |
32d2789
|
jgm |
Added preliminary support for PDF creation via wkhtmltopdf.
To use this: pandoc -t html5 -o result.pdf (and add `--mathjax` if you have math.) |
0a768f1
|
||
jgm |
pdf via wkhtmltopdf: take `title` and `page-size` from metadata.
Adjusted default `page-size` to `letter`, to match current LaTeX template. |
0596b65
|
||
jgm |
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. |
8b8bdca
|
||
jgm |
Improved treatment of margins in wkhtmltopdf.
|
46e38d0
|
||
jgm |
LaTeX reader: allow blank space between braced arguments of commands.
For example \foo {bar} {baz} Closes #2592. |
35e0544
|
||
jgm |
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. |
f9202f5
|
||
jgm |
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. |
2973450
|
||
jgm |
Updated README with margin and papersize variables.
|
3861df5
|
jgm |
Added 'paper' after $papersize$ variable in latex template.
Thus you can say `papersize: a4` and the latex will contain `a4paper`. This change may break some existing workflows; if you currently specify `a4paper`, you'll get `a4paperpaper` which is meaningless. However, the change seems worth it, as it will make the `papersize` variable work uniformly across ConTeXt, LaTeX, and html->pdf via wkhtmltopdf. See 3861df5 62d#commitcomment-15135193 |
59d6f02
|
jgm |
Use cmark 0.5.
Closes #2605. |
b27783e
|
||
jgm |
stack.yaml - use simpler extra-deps field.
|
a2fa460
|
jgm |
Fixed debpkg target.
|
90a2df3
|
||
jgm |
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> |
97c9691
|
jgm |
Updated binary package stack.yamls to ensure pandoc-citeproc...
is built with embed_data_files. This fixes a problem with the original 1.16 binary packages. |
1cee481
|
||
jgm |
windows/stack.yaml - use local pandoc-citeproc.
I'm not sure why this is needed, but it is. Otherwise the build fails. |
a6d20b3
|
jgm |
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. |
4990350
|
||
jgm |
Updated .travis.yml, added ghc 7.10.3 to tested-with.
|
694eb87
|
||
jgm |
Added 7.10.3 to make_travis_yml.hs known versions.
|
51a415e
|
||
jgm |
Regenerated .travis.yml to include 7.10.3.
|
e792920
|
||
jgm |
Go back to testing with ghc 7.10.2.
Avoids the dreaded "the version of cabal being used has changed" error. https://www.reddit.com/r/haskell/comments/3f4bgr/the_version_of_cabal_being_used_has_changed/ |
a81b093
|
||
jgm |
RST, Markdown writers: Fixed rendering of grid tables with blank rows.
Closes #2615. |
a796538
|
conklech |
Add .stack-work to gitignore
The .stack-work directory is analogous to a cabal sandbox; it comprises temporary build artifacts. |
45f5fc9
|
||
jgm |
Merge pull request #2622 from conklech/ignore-stack
Add .stack-work to gitignore |
2aee5a3
|
||
jgm |
stack.yaml: bump pandoc-types version to 1.16.0.1.
|
73d1175
|
||
jgm |
Make file globbing work on windows.
Windows cmd doesn't expand wildcards; the application has to do this. So on windows we use 'glob' to expand. |
363ecfe
|
||
jgm |
Revert "Make file globbing work on windows."
This reverts commit 363ecfe. |
197f301
|
||
jgm |
stack.yaml, stack.full.yaml - use lts-4.0 resolver.
|
f6fe430
|
||
jgm |
Improved default template lookup for custom lua scripts.
Previously, if you tried to do `pandoc -s -t /path/to/lua/script.lua`, pandoc would look for the template in `~/.pandoc/templates/default./path/to/lua/script.lua`. With this change it will look in the more reasonable `~/.pandoc/templates/default.script.lua`. This makes it possible to store default templates for custom writers. Closes #2625. |
a5efd2a
|
matt-e |
Update stack.full.yaml
|
dbff1d1
|
||
matt-e |
Update stack.yaml
Another typo? |
1730e63
|
||
jgm |
Merge pull request #2632 from matt-e/fix-stack-build
Fix typo in stack build files |
52d95dd
|
jgm |
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. `⟨`. |
12a5bd3
|
||
jgm |
Work around tagsoup bug - not allowing uppercase x in hex entities.
Issue submitted at tagsoup. |
5884ff6
|
||
jgm |
Added some entity tests in Markdown reader tests.
|
d5f6782
|
||
jgm |
Fixed shadowing warning.
|
729911a
|
||
jgm |
LaTeX writer: restore old treatment of Span.
A Span is rendered with surrounding {braces}. This was a regression in 1.16. Closes #2624. |
1506e62
|
||
jgm |
Version bump to 1.16.0.1
|
687c39e
|
||
jgm |
Updated changelog.
|
1fbbc2b
|
||
jgm |
Updated stack.yaml.
|
5eb8087
|
||
jgm |
Fixed typo in deb/stack.yaml.
|
a412104
|
mb21 |
LaTeX writer: figure label
|
1fde920
|
jgm |
osx package fixes: correct version, allow installation to any drive.
|
6936a6a
|
||
jgm |
README - changed date.
|
37ac274
|
||
jgm |
Regenerated man page.
|
293f31c
|
||
jgm |
Release checklist: added note on regenerating Hackage docs.
|
4db912f
|
||
jgm |
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. |
8611ac5
|
||
jgm |
Depend on deepseq rather than deepseq-generics.
See fpco/stackage#1096. |
f34382e
|
||
tarleb |
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. |
fabbd1a
|
jgm |
Version to 1.16.0.2, updated changelog.
|
3004306
|
||
jgm |
Updated README date.
|
ee09ee1
|
||
jgm |
Updated man page.
|
f8776ed
|
jgm |
Org writer - pass through RawInline with format "org".
|
f45a8e1
|
||
jgm |
make_osx_package.sh: Use env variable for developer id certs.
|
20c55ab
|
||
jgm |
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. |
f2c0974
|
csforste |
Add TEI Writer.
|
25a9ca6
|
||
jgm |
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. |
4d74a96
|
Henrik Tramberend |
LaTeX writer: Allow more flexible table alignment
|
7a18879
|
||
jgm |
Merge pull request #2665 from monofon/fix/table-alignment
LaTeX writer: Allow more flexible table alignment |
3875df7
|
||
jgm |
Adjusted longtable in tests.
New default is not to include `[c]` option. |
7ea4d17
|
jgm |
Changed type of Shared.uniqueIdent argument from [String] to Set String.
This avoids performance problems in documents with many identically named headers. Closes #2671. |
20170c3
|
||
jgm |
Bump version to 1.17.
API change in type of Text.Pandoc.Shared.uniqueIdent. |
f35fa88
|
jgm |
stack.yaml - use cmark 0.5.1.
|
d015284
|
jgm |
Make language extensions trigger highlighting.
For example, `py` will now work as well as `python`. Closes jgm/highlighting-kate#83. |
11c5831
|
jgm |
Textile reader: Support `>`, `<`, `=`, `<>` text alignment attributes.
Closes #2674. |
a1021bd
|
pra85 |
Update license year range to 2016
|
fdc9f0e
|
||
jgm |
Merge pull request #2681 from pra85/patch-1
Update license year range to 2016 |
373aaa8
|
jgm |
Properly handle LaTeX "math" environment as inline math.
See #2171. |
76983c3
|
||
jgm |
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.. |
a02c26d
|
jgm |
LaTeX reader: `inlineCommand` now gobbles an empty `{}` after any com…
…mand. 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. |
1874558
|
||
tarleb |
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. |
92e6ae4
|
jkr |
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 |
2ee7752
|
||
jkr |
Docx reader: Add tests for adjacent hyperlinks.
|
7a10507
|
jgm |
HTML writer: don't include alignment attribute for default table colu…
…mns. Previously these were given "left" alignment. Better to leave off alignment attributes altogether. Closes #2694. |
93a05df
|
jgm |
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 4229cf2. |
6cb4991
|
MathieuDuponchelle |
CONTRIBUTING.md : update test enabling documentation
On my end, in a clean sandbox, I had to run this before I could run the tests, I'm a cabal / haskell noob so that might not be the best way to do so but :) |
a326600
|
jgm |
Custom writer: Pass attributes parameter to CaptionedImage.
Closes #2697. |
a692bd2
|
||
jgm |
Merge pull request #2699 from MathieuDuponchelle/patch-1
CONTRIBUTING.md : update test enabling documentation |
7358b47
|
||
jgm |
Added info on Stack to CONTRIBUTING.md.
|
c0515e0
|
rski |
Fix stack link in INSTALL
Stack installation instructions have moved to docs.haskellstack.org |
c428231
|
||
jgm |
Merge pull request #2703 from rski/stack_link_fix
Fix stack link in INSTALL |
7034366
|
jgm |
Allow aeson 0.11.
|
e552a14
|
||
jgm |
Updated to lts-5.2 resolver, aeson 0.11 in stack.yaml.
|
522f8f3
|
||
jgm |
Changed aeson version in stack.yaml to 0.11.0.0.
|
1aaf4b8
|
jgm |
HTML reader: properly handle an empty cell in a simple table.
Closes #2718. |
b8dadc6
|
jgm |
Try new travis stack+cabal script.
|
1a87794
|
||
jgm |
Fixed stack.yaml.
|
134a5e5
|
||
jgm |
Travis fixes.
cabal sdist has problems on cabal 1.16, because of our Text.Pandoc.Data module. So we don't test it. |
dda7c27
|
||
jgm |
Travis: don't build with lts-3.
It doesn't have recent enough dependencies. |
9e3f739
|
||
jgm |
Don't build with lts-2 or lts-3.
|
44bcc88
|
adunning |
Remove stray line from stack.full.yaml
The line causes an error with stack 1.0.2: ``` Could not parse '/pandoc-build/pandoc/stack.full.yaml': AesonException "Error in $.extra-deps: failed to parse field 'extra-deps': failed to parse field extra-deps: expected [a], encountered Null" See http://docs.haskellstack.org/en/stable/yaml_configuration.html. ``` |
4dfe373
|
jgm |
Merge pull request #2725 from adunning/patch-1
Remove stray line from stack.full.yaml |
5848416
|
||
jkr |
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. |
4112b32
|
||
jkr |
LaTeX writer: clean up options parser.
Make sure that we require the closing bracket. |
4438ff1
|
pra85 |
Fix typos in Readme
Remove extra `be` `overriden` → `overridden` |
8a114e9
|
||
jgm |
Merge pull request #2732 from pra85/patch-2
Fix typos in Readme |
d45fcf9
|
||
jgm |
HTML reader: rewrote htmlInBalanced.
This version avoids an exponential performance problem with `<script>` tags, and it should be faster in general. Closes #2730. |
1534052
|
jgm |
Merge pull request #2691 from tarleb/org-image-file-links
Org reader: Refactor link-target processing |
e369e60
|
||
jgm |
Merge pull request #2668 from monofon/fix/yaml-metadata-block-bottom-…
…line Markdown writer: Use hyphens for yaml metadata block bottom line |
649cfb6
|
||
jgm |
Merge pull request #2646 from tarleb/org-figure-with-no-name
Prefix even empty figure names with "fig:" |
29706ee
|
||
jgm |
Fixed some linter warnings.
|
9693de7
|
||
jkr |
Update README to reflect 4112b32.
We don't infer `--chapters` if `article` document option is set. For example: `\documentclass[article]{memoir}`. |
f1c59b2
|
||
jgm |
Markdown reader: use htmlInBalanced for rawVerbatimBlock.
This should give better performance. See #2730. |
04d1e40
|
jgm |
Raise tagsoup lower bound to 0.13.7.
This fixes entity-related problems. Closes #2734. |
0180807
|
jgm |
Make protocol-relative URIs work again.
Closes #2737. |
f2bd6fd
|
jgm |
Allow zip-archive 0.3.
|
38bd416
|
jkr |
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. |
a7a0b45
|
||
mb21 |
Add relocatable stack build
|
752be50
|
||
jgm |
Merge pull request #2739 from mb21/patch-2
Add relocatable stack build |
ea70495
|
jgm |
LaTeX reader: handle interior `$` characters in math.
e.g. `$$\hbox{$i$}$$`. Partially addresses #2743. |
7c6a3c0
|
ickc |
Update pandoc.1
|
b411e0f
|
||
ickc |
Update README
|
846fa87
|
||
jgm |
Merge pull request #2760 from ickc/master
Very Minor update on the documentation |
0510396
|
||
jgm |
Stack-based appveyor setup.
|
928a050
|
jkr |
Docx reader: update feature checklist.
The feature checklist in the source code was out of date. Update. |
0b9c54d
|
||
jgm |
DokuWiki writer: use $$ for display math.
|
6bfaa5a
|
jgm |
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. |
4ed6483
|
||
jgm |
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. |
6e950a8
|
||
jgm |
Markdown reader: Clean up pipe table parsing.
|
54a6861
|
||
jgm |
Markdown reader: Improved pipe table parsing.
Fixes #2765. Added test case. |
2b55b76
|
mb21 |
Docx Writer: handle image alt text
closes #2754 |
139fa54
|
||
jgm |
Merge pull request #2771 from mb21/docx-alt-text
Docx Writer: handle image alt text |
06a57b2
|
jgm |
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. |
a485c42
|
jkr |
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. |
102ba9e
|
||
jkr |
Add readDocxWithWarnings
The regular readDocx just becomes a special case. |
ee03e95
|
||
jkr |
Add a general ByteStringReader with warnings.
Have docx reader use it. |
68fd333
|
jkr |
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`. |
5c055b4
|
||
jkr |
README: Add description of `--file-scope` option.
|
c7c4ee4
|
||
jkr |
pandoc.hs: Also use filescope for json files.
JSON files have metadata and list structure, so they can't be simply catted, but they're useful as intermediate build files in large projects. |
09b4f29
|
jkr |
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. |
855c8b4
|
||
jkr |
Docx reader: Add test for enumerated headers.
We don't want them to turn into a list. |
7f4a404
|
jkr |
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`. |
28c7617
|
||
jgm |
README: document that --toc works with docx.
Closes #2787. |
8d1c018
|
||
jgm |
LaTeX writer: Avoid double toprule in headerless table with caption.
Closes #2742. |
e821b05
|
||
jgm |
ConTeXt writer: fix whitespace at line beginning in line blocks.
|
976e7e2
|
jkr |
Fix stdin handling for file-scope
Regardless of input type, we should use default handling if we are dealing with stdin. In other words, there should be no file-scope if there are no files. This was an issue with pandoc json, which could be piped on stdin, but which was read by default with `--file-scope`. |
a8a2d4f
|
||
jgm |
Improved documentation of templates.
Note that there's no docx template. Closes #2797. |
2649a0d
|
||
jgm |
Version to 1.17.0.1.
|
edcb8b6
|
||
jgm |
Updated changelog.
|
650c12d
|
||
jgm |
Updated man page.
|
db20790
|
- +1 −0 .gitignore
- +112 −74 .travis.yml
- +25 −4 CONTRIBUTING.md
- +1 −1 COPYRIGHT
- +5 −1 INSTALL
- +5 −2 Makefile
- +242 −103 README
- +3 −0 RELEASE-CHECKLIST
- +14 −33 appveyor.yml
- +2 −2 benchmark/benchmark-pandoc.hs
- +557 −19 changelog
- +7 −3 data/sample.lua
- +1 −1 data/templates
- +3 −2 deb/Makefile
- +3 −7 { → deb}/make_deb.sh
- +6 −2 deb/stack.yaml
- +6 −2 make_osx_package.sh
- +1 −1 make_travis_yml.hs
- +278 −102 man/pandoc.1
- +1 −1 man/removeLinks.hs
- +3 −3 osx/{distribution.xml → distribution.xml.in}
- +6 −2 osx/stack.yaml
- +38 −37 pandoc.cabal
- +139 −115 pandoc.hs
- +18 −7 src/Text/Pandoc.hs
- +15 −6 src/Text/Pandoc/CSS.hs
- +871 −870 src/Text/Pandoc/Emoji.hs
- +5 −5 src/Text/Pandoc/Highlighting.hs
- +137 −15 src/Text/Pandoc/ImageSize.hs
- +20 −5 src/Text/Pandoc/Options.hs
- +96 −23 src/Text/Pandoc/PDF.hs
- +26 −10 src/Text/Pandoc/Parsing.hs
- +1 −1 src/Text/Pandoc/Pretty.hs
- +15 −7 src/Text/Pandoc/Readers/CommonMark.hs
- +17 −7 src/Text/Pandoc/Readers/DocBook.hs
- +55 −36 src/Text/Pandoc/Readers/Docx.hs
- +154 −0 src/Text/Pandoc/Readers/Docx/Combine.hs
- +88 −42 src/Text/Pandoc/Readers/Docx/Parse.hs
- +0 −181 src/Text/Pandoc/Readers/Docx/Reducible.hs
- +7 −7 src/Text/Pandoc/Readers/EPUB.hs
- +77 −50 src/Text/Pandoc/Readers/HTML.hs
- +69 −29 src/Text/Pandoc/Readers/LaTeX.hs
- +84 −57 src/Text/Pandoc/Readers/Markdown.hs
- +30 −18 src/Text/Pandoc/Readers/MediaWiki.hs
- +2 −1 src/Text/Pandoc/Readers/Odt/ContentReader.hs
- +40 −37 src/Text/Pandoc/Readers/Org.hs
- +23 −14 src/Text/Pandoc/Readers/RST.hs
- +27 −5 src/Text/Pandoc/Readers/Textile.hs
- +1 −1 src/Text/Pandoc/Readers/Txt2Tags.hs
- +47 −23 src/Text/Pandoc/Shared.hs
- +1 −1 src/Text/Pandoc/Slides.hs
- +42 −18 src/Text/Pandoc/Writers/AsciiDoc.hs
- +22 −21 src/Text/Pandoc/Writers/CommonMark.hs
- +60 −12 src/Text/Pandoc/Writers/ConTeXt.hs
- +8 −6 src/Text/Pandoc/Writers/Custom.hs
- +32 −9 src/Text/Pandoc/Writers/Docbook.hs
- +18 −24 src/Text/Pandoc/Writers/Docx.hs
- +30 −8 src/Text/Pandoc/Writers/DokuWiki.hs
- +11 −9 src/Text/Pandoc/Writers/EPUB.hs
- +10 −8 src/Text/Pandoc/Writers/FB2.hs
- +97 −67 src/Text/Pandoc/Writers/HTML.hs
- +12 −7 src/Text/Pandoc/Writers/Haddock.hs
- +96 −57 src/Text/Pandoc/Writers/ICML.hs
- +134 −71 src/Text/Pandoc/Writers/LaTeX.hs
- +6 −4 src/Text/Pandoc/Writers/Man.hs
- +79 −40 src/Text/Pandoc/Writers/Markdown.hs
- +39 −7 src/Text/Pandoc/Writers/MediaWiki.hs
- +2 −2 src/Text/Pandoc/Writers/Native.hs
- +27 −14 src/Text/Pandoc/Writers/ODT.hs
- +1 −1 src/Text/Pandoc/Writers/OPML.hs
- +40 −41 src/Text/Pandoc/Writers/OpenDocument.hs
- +18 −7 src/Text/Pandoc/Writers/Org.hs
- +58 −22 src/Text/Pandoc/Writers/RST.hs
- +8 −7 src/Text/Pandoc/Writers/RTF.hs
- +4 −2 src/Text/Pandoc/Writers/Shared.hs
- +320 −0 src/Text/Pandoc/Writers/TEI.hs
- +27 −11 src/Text/Pandoc/Writers/Texinfo.hs
@@ -1,87 +1,125 @@ | ||
-# This file has been generated -- see https://github.com/hvr/multi-ghc-travis | ||
-language: c | ||
+# Copy these contents into the root directory of your Github project in a file | ||
+# named .travis.yml | ||
+ | ||
+# Use new container infrastructure to enable caching | ||
sudo: false | ||
+# Choose a lightweight base image; we provide our own build tools. | ||
+language: c | ||
+ | ||
+# Caching so the next build will be fast too. | ||
cache: | ||
directories: | ||
- - $HOME/.cabsnap | ||
- - $HOME/.cabal/packages | ||
- | ||
-before_cache: | ||
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log | ||
- - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar | ||
+ - $HOME/.ghc | ||
+ - $HOME/.cabal | ||
+ - $HOME/.stack | ||
+# The different configurations we want to test. We have BUILD=cabal which uses | ||
+# cabal-install, and BUILD=stack which uses Stack. More documentation on each | ||
+# of those below. | ||
+# | ||
+# We set the compiler values here to tell Travis to use a different | ||
+# cache file per set of arguments. | ||
+# | ||
+# If you need to have different apt packages for each combination in the | ||
+# matrix, you can use a line such as: | ||
+# addons: {apt: {packages: [libfcgi-dev,libgmp-dev]}} | ||
matrix: | ||
include: | ||
- - env: CABALVER=1.16 GHCVER=7.4.2 GHCOPTS=-Werror | ||
- compiler: ": #GHC 7.4.2" | ||
- addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}} | ||
- - env: CABALVER=1.16 GHCVER=7.6.3 GHCOPTS=-Werror | ||
- compiler: ": #GHC 7.6.3" | ||
- addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}} | ||
- - env: CABALVER=1.18 GHCVER=7.8.4 GHCOPTS=-Werror | ||
- compiler: ": #GHC 7.8.4" | ||
- addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}} | ||
- - env: CABALVER=1.22 GHCVER=7.10.2 GHCOPTS=-Werror | ||
- compiler: ": #GHC 7.10.2" | ||
- addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}} | ||
+ # We grab the appropriate GHC and cabal-install versions from hvr's PPA. See: | ||
+ # https://github.com/hvr/multi-ghc-travis | ||
+ - env: BUILD=cabal GHCVER=7.4.2 CABALVER=1.16 | ||
+ compiler: ": #GHC 7.4.2" | ||
+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}} | ||
+ - env: BUILD=cabal GHCVER=7.6.3 CABALVER=1.16 | ||
+ compiler: ": #GHC 7.6.3" | ||
+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}} | ||
+ - env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18 | ||
+ compiler: ": #GHC 7.8.4" | ||
+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}} | ||
+ - env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22 | ||
+ compiler: ": #GHC 7.10.3" | ||
+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}} | ||
-before_install: | ||
- - unset CC | ||
- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH | ||
+ # Build with the newest GHC and cabal-install. This is an accepted failure, | ||
+ # see below. | ||
+ - env: BUILD=cabal GHCVER=head CABALVER=head | ||
+ compiler: ": #GHC HEAD" | ||
+ addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}} | ||
-install: | ||
- - cabal --version | ||
- - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" | ||
- - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ]; | ||
- then | ||
- zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz > | ||
- $HOME/.cabal/packages/hackage.haskell.org/00-index.tar; | ||
- fi | ||
- - travis_retry cabal update -v | ||
- - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config | ||
- - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt | ||
- - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt | ||
+ # The Stack builds. We can pass in arbitrary Stack arguments via the ARGS | ||
+ # variable, such as using --stack-yaml to point to a different file. | ||
+ - env: BUILD=stack ARGS="--resolver lts-5" | ||
+ compiler: ": #stack 7.10.3" | ||
+ addons: {apt: {packages: [ghc-7.10.3], sources: [hvr-ghc]}} | ||
-# check whether current requested install-plan matches cached package-db snapshot | ||
- - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt; | ||
- then | ||
- echo "cabal build-cache HIT"; | ||
- rm -rfv .ghc; | ||
- cp -a $HOME/.cabsnap/ghc $HOME/.ghc; | ||
- cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/; | ||
- else | ||
- echo "cabal build-cache MISS"; | ||
- rm -rf $HOME/.cabsnap; | ||
- mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin; | ||
- cabal install --only-dependencies --enable-tests --enable-benchmarks; | ||
- fi | ||
- | ||
-# snapshot package-db on cache miss | ||
- - if [ ! -d $HOME/.cabsnap ]; | ||
- then | ||
- echo "snapshotting package-db to build-cache"; | ||
- mkdir $HOME/.cabsnap; | ||
- cp -a $HOME/.ghc $HOME/.cabsnap/ghc; | ||
- cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/; | ||
- fi | ||
+ # Nightly builds are allowed to fail | ||
+ - env: BUILD=stack ARGS="--resolver nightly" | ||
+ compiler: ": #stack nightly" | ||
+ addons: {apt: {packages: [libgmp-dev]}} | ||
-# Here starts the actual work to be performed for the package under test; | ||
-# any command which exits with a non-zero exit code causes the build to fail. | ||
-script: | ||
- - if [ -f configure.ac ]; then autoreconf -i; fi | ||
- - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging | ||
- - cabal build --ghc-options=$GHCOPTS # this builds all libraries and executables (including tests/benchmarks) | ||
- - cabal test | ||
- - cabal check | ||
-# Test that a source-distribution can be generated | ||
-# (with cabal >= 1.18 'cabal sdist' would work too): | ||
- - ./dist/setup/setup sdist | ||
+ - env: BUILD=stack ARGS="--resolver lts-5" | ||
+ compiler: ": #stack 7.10.3 osx" | ||
+ os: osx | ||
-# Check that the resulting source distribution can be built & installed. | ||
-# If there are no other `.tar.gz` files in `dist`, this can be even simpler: | ||
-# `cabal install --force-reinstalls dist/*-*.tar.gz` | ||
- - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && | ||
- (cd dist && cabal install --force-reinstalls "$SRC_TGZ") | ||
+ - env: BUILD=stack ARGS="--resolver nightly" | ||
+ compiler: ": #stack nightly osx" | ||
+ os: osx | ||
-# EOF | ||
+ allow_failures: | ||
+ - env: BUILD=cabal GHCVER=head CABALVER=head | ||
+ - env: BUILD=stack ARGS="--resolver nightly" | ||
+ | ||
+before_install: | ||
+# Using compiler above sets CC to an invalid value, so unset it | ||
+- unset CC | ||
+ | ||
+# We want to always allow newer versions of packages when building on GHC HEAD | ||
+- CABALARGS="" | ||
+- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi | ||
+ | ||
+# Download and unpack the stack executable | ||
+- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:$PATH | ||
+- mkdir -p ~/.local/bin | ||
+- | | ||
+ if [ `uname` = "Darwin" ] | ||
+ then | ||
+ curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin | ||
+ else | ||
+ curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' | ||
+ fi | ||
+ | ||
+install: | ||
+- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" | ||
+- if [ -f configure.ac ]; then autoreconf -i; fi | ||
+- | | ||
+ case "$BUILD" in | ||
+ stack) | ||
+ stack --no-terminal --install-ghc $ARGS test --only-dependencies | ||
+ ;; | ||
+ cabal) | ||
+ cabal --version | ||
+ travis_retry cabal update | ||
+ cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS | ||
+ ;; | ||
+ esac | ||
+ | ||
+script: | ||
+- | | ||
+ case "$BUILD" in | ||
+ stack) | ||
+ stack --no-terminal $ARGS test --haddock --no-haddock-deps | ||
+ ;; | ||
+ cabal) | ||
+ cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options="-O0 -Werror" | ||
+ cabal build | ||
+ cabal check || [ "$CABALVER" == "1.16" ] | ||
+ cabal test | ||
+ cabal copy | ||
+ # cabal sdist fails on cabal 1.16: | ||
+ cabal sdist || [ "$CABALVER" == "1.16" ] | ||
+ SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && \ | ||
+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ" || \ | ||
+ [ "$CABALVER" == "1.16" ]) | ||
+ ;; | ||
+ esac |
@@ -1,38 +1,19 @@ | ||
-install: | ||
-- cmd: 'git submodule update --init' | ||
-- ps: | | ||
- choco install haskellplatform -version 2014.2.0.0 -y | ||
- # Haskell Platfrom package doesn't update PATH for the current shell instance | ||
+cache: | ||
+- "c:\\sr" # stack root, short paths == fewer problems | ||
- $env:Path += ";${env:ProgramFiles}\Haskell Platform\2014.2.0.0\bin" | ||
- $env:Path += ";${env:ProgramFiles}\Haskell Platform\2014.2.0.0\lib\extralibs\bin" | ||
- $env:Path += ";${env:ProgramFiles}\Haskell Platform\2014.2.0.0\mingw\bin" | ||
- # choco install wixtoolset | ||
- cabal sandbox init | ||
- $env:Path += ";.\.cabal-sandbox\bin" | ||
- cabal update | ||
- cabal install --force hsb2hs | ||
+build: off | ||
-build_script: | ||
-- cmd: | | ||
- cabal install --force --enable-tests -fembed_data_files | ||
+before_test: | ||
+- curl -ostack.zip -L --insecure http://www.stackage.org/stack/windows-i386 | ||
+- 7z x stack.zip stack.exe | ||
-# after_build: | ||
-# - cmd: | | ||
-# cabal install -fembed_data_files pandoc-citeproc | ||
-# strip .\.cabal-sandbox\bin\pandoc.exe | ||
-# strip .\.cabal-sandbox\bin\pandoc-citeproc.exe | ||
-# .\.cabal-sandbox\bin\pandoc.exe -s --template data\templates\default.html -S README -o README.html | ||
-# .\.cabal-sandbox\bin\pandoc.exe -s --template data\templates\default.rtf COPYING -t rtf -S -o COPYING.rtf | ||
-# copy COPYRIGHT COPYRIGHT.txt | ||
-# for /f "tokens=2 delims= " %%a in ('.\.cabal-sandbox\bin\pandoc --version') do ( set "VERSION=%%a" && exit ) | ||
-# if "%VERSION%" == "" ( echo "Error: could not determine version number." && exit /b 1 ) | ||
-# cd windows | ||
-# echo Creating msi... | ||
-# candle -dVERSION=%VERSION% pandoc.wxs | ||
-# if %errorlevel% neq 0 exit /b %errorlevel% | ||
-# light -sw1076 -ext WixUIExtension -ext WixUtilExtension -out pandoc-%VERSION%-windows.msi pandoc.wixobj | ||
+clone_folder: "c:\\stack" | ||
+environment: | ||
+ global: | ||
+ STACK_ROOT: "c:\\sr" | ||
test_script: | ||
-- cmd: | | ||
- cabal test | ||
+- stack setup > nul | ||
+# The ugly echo "" hack is to avoid complaints about 0 being an invalid file | ||
+# descriptor | ||
+- echo "" | stack --no-terminal test |
@@ -1 +1 @@ | ||
-Subproject commit c31874467bb58ac1735dc28af458e7603a166397 | ||
+Subproject commit d39b2207f98e8a6c6f91b0498c183069a0aa7c97 |
@@ -0,0 +1,154 @@ | ||
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, | ||
+ PatternGuards #-} | ||
+ | ||
+module Text.Pandoc.Readers.Docx.Combine ( smushInlines | ||
+ , smushBlocks | ||
+ ) | ||
+ where | ||
+ | ||
+import Text.Pandoc.Builder | ||
+import Data.List | ||
+import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr, (><), (|>)) | ||
+import qualified Data.Sequence as Seq (null) | ||
+ | ||
+data Modifier a = Modifier (a -> a) | ||
+ | AttrModifier (Attr -> a -> a) Attr | ||
+ | NullModifier | ||
+ | ||
+spaceOutInlinesL :: Inlines -> (Inlines, Inlines) | ||
+spaceOutInlinesL ms = (l, stackInlines fs (m' <> r)) | ||
+ where (l, m, r) = spaceOutInlines ms | ||
+ (fs, m') = unstackInlines m | ||
+ | ||
+spaceOutInlinesR :: Inlines -> (Inlines, Inlines) | ||
+spaceOutInlinesR ms = (stackInlines fs (l <> m'), r) | ||
+ where (l, m, r) = spaceOutInlines ms | ||
+ (fs, m') = unstackInlines m | ||
+ | ||
+spaceOutInlines :: Inlines -> (Inlines, Inlines, Inlines) | ||
+spaceOutInlines ils = | ||
+ let (fs, ils') = unstackInlines ils | ||
+ contents = unMany ils' | ||
+ left = case viewl contents of | ||
+ (Space :< _) -> space | ||
+ _ -> mempty | ||
+ right = case viewr contents of | ||
+ (_ :> Space) -> space | ||
+ _ -> mempty in | ||
+ (left, (stackInlines fs $ trimInlines . Many $ contents), right) | ||
+ | ||
+stackInlines :: [Modifier Inlines] -> Inlines -> Inlines | ||
+stackInlines [] ms = ms | ||
+stackInlines (NullModifier : fs) ms = stackInlines fs ms | ||
+stackInlines ((Modifier f) : fs) ms = | ||
+ if isEmpty ms | ||
+ then stackInlines fs ms | ||
+ else f $ stackInlines fs ms | ||
+stackInlines ((AttrModifier f attr) : fs) ms = f attr $ stackInlines fs ms | ||
+ | ||
+unstackInlines :: Inlines -> ([Modifier Inlines], Inlines) | ||
+unstackInlines ms = case ilModifier ms of | ||
+ NullModifier -> ([], ms) | ||
+ _ -> (f : fs, ms') where | ||
+ f = ilModifier ms | ||
+ (fs, ms') = unstackInlines $ ilInnards ms | ||
+ | ||
+ilModifier :: Inlines -> Modifier Inlines | ||
+ilModifier ils = case viewl (unMany ils) of | ||
+ (x :< xs) | Seq.null xs -> case x of | ||
+ (Emph _) -> Modifier emph | ||
+ (Strong _) -> Modifier strong | ||
+ (SmallCaps _) -> Modifier smallcaps | ||
+ (Strikeout _) -> Modifier strikeout | ||
+ (Superscript _) -> Modifier superscript | ||
+ (Subscript _) -> Modifier subscript | ||
+ (Link attr _ tgt) -> Modifier $ linkWith attr (fst tgt) (snd tgt) | ||
+ (Span attr _) -> AttrModifier spanWith attr | ||
+ _ -> NullModifier | ||
+ _ -> NullModifier | ||
+ | ||
+ilInnards :: Inlines -> Inlines | ||
+ilInnards ils = case viewl (unMany ils) of | ||
+ (x :< xs) | Seq.null xs -> case x of | ||
+ (Emph lst) -> fromList lst | ||
+ (Strong lst) -> fromList lst | ||
+ (SmallCaps lst) -> fromList lst | ||
+ (Strikeout lst) -> fromList lst | ||
+ (Superscript lst) -> fromList lst | ||
+ (Subscript lst) -> fromList lst | ||
+ (Link _ lst _) -> fromList lst | ||
+ (Span _ lst) -> fromList lst | ||
+ _ -> ils | ||
+ _ -> ils | ||
+ | ||
+inlinesL :: Inlines -> (Inlines, Inlines) | ||
+inlinesL ils = case viewl $ unMany ils of | ||
+ (s :< sq) -> (singleton s, Many sq) | ||
+ _ -> (mempty, ils) | ||
+ | ||
+inlinesR :: Inlines -> (Inlines, Inlines) | ||
+inlinesR ils = case viewr $ unMany ils of | ||
+ (sq :> s) -> (Many sq, singleton s) | ||
+ _ -> (ils, mempty) | ||
+ | ||
+combineInlines :: Inlines -> Inlines -> Inlines | ||
+combineInlines x y = | ||
+ let (xs', x') = inlinesR x | ||
+ (y', ys') = inlinesL y | ||
+ in | ||
+ xs' <> (combineSingletonInlines x' y') <> ys' | ||
+ | ||
+combineSingletonInlines :: Inlines -> Inlines -> Inlines | ||
+combineSingletonInlines x y = | ||
+ let (xfs, xs) = unstackInlines x | ||
+ (yfs, ys) = unstackInlines y | ||
+ shared = xfs `intersect` yfs | ||
+ x_remaining = xfs \\ shared | ||
+ y_remaining = yfs \\ shared | ||
+ x_rem_attr = filter isAttrModifier x_remaining | ||
+ y_rem_attr = filter isAttrModifier y_remaining | ||
+ in | ||
+ case null shared of | ||
+ True | isEmpty xs && isEmpty ys -> | ||
+ stackInlines (x_rem_attr ++ y_rem_attr) mempty | ||
+ | isEmpty xs -> | ||
+ let (sp, y') = spaceOutInlinesL y in | ||
+ (stackInlines x_rem_attr mempty) <> sp <> y' | ||
+ | isEmpty ys -> | ||
+ let (x', sp) = spaceOutInlinesR x in | ||
+ x' <> sp <> (stackInlines y_rem_attr mempty) | ||
+ | otherwise -> | ||
+ let (x', xsp) = spaceOutInlinesR x | ||
+ (ysp, y') = spaceOutInlinesL y | ||
+ in | ||
+ x' <> xsp <> ysp <> y' | ||
+ False -> stackInlines shared $ | ||
+ combineInlines | ||
+ (stackInlines x_remaining xs) | ||
+ (stackInlines y_remaining ys) | ||
+ | ||
+combineBlocks :: Blocks -> Blocks -> Blocks | ||
+combineBlocks bs cs | ||
+ | bs' :> (BlockQuote bs'') <- viewr (unMany bs) | ||
+ , (BlockQuote cs'') :< cs' <- viewl (unMany cs) = | ||
+ Many $ (bs' |> (BlockQuote (bs'' <> cs''))) >< cs' | ||
+combineBlocks bs cs = bs <> cs | ||
+ | ||
+instance (Monoid a, Eq a) => Eq (Modifier a) where | ||
+ (Modifier f) == (Modifier g) = (f mempty == g mempty) | ||
+ (AttrModifier f attr) == (AttrModifier g attr') = (f attr mempty == g attr' mempty) | ||
+ (NullModifier) == (NullModifier) = True | ||
+ _ == _ = False | ||
+ | ||
+isEmpty :: (Monoid a, Eq a) => a -> Bool | ||
+isEmpty x = x == mempty | ||
+ | ||
+isAttrModifier :: Modifier a -> Bool | ||
+isAttrModifier (AttrModifier _ _) = True | ||
+isAttrModifier _ = False | ||
+ | ||
+smushInlines :: [Inlines] -> Inlines | ||
+smushInlines xs = foldl combineInlines mempty xs | ||
+ | ||
+smushBlocks :: [Blocks] -> Blocks | ||
+smushBlocks xs = foldl combineBlocks mempty xs |
@@ -1,181 +0,0 @@ | ||
-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, | ||
- PatternGuards #-} | ||
- | ||
-module Text.Pandoc.Readers.Docx.Reducible ( concatReduce | ||
- , (<+>) | ||
- ) | ||
- where | ||
- | ||
- | ||
-import Text.Pandoc.Builder | ||
-import Data.List | ||
-import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr) | ||
-import qualified Data.Sequence as Seq (null) | ||
- | ||
-data Modifier a = Modifier (a -> a) | ||
- | AttrModifier (Attr -> a -> a) Attr | ||
- | NullModifier | ||
- | ||
-class (Eq a) => Modifiable a where | ||
- modifier :: a -> Modifier a | ||
- innards :: a -> a | ||
- getL :: a -> (a, a) | ||
- getR :: a -> (a, a) | ||
- spaceOut :: a -> (a, a, a) | ||
- | ||
-spaceOutL :: (Monoid a, Modifiable a) => a -> (a, a) | ||
-spaceOutL ms = (l, stack fs (m' <> r)) | ||
- where (l, m, r) = spaceOut ms | ||
- (fs, m') = unstack m | ||
- | ||
-spaceOutR :: (Monoid a, Modifiable a) => a -> (a, a) | ||
-spaceOutR ms = (stack fs (l <> m'), r) | ||
- where (l, m, r) = spaceOut ms | ||
- (fs, m') = unstack m | ||
- | ||
-instance (Monoid a, Show a) => Show (Modifier a) where | ||
- show (Modifier f) = show $ f mempty | ||
- show (AttrModifier f attr) = show $ f attr mempty | ||
- show (NullModifier) = "NullModifier" | ||
- | ||
-instance (Monoid a, Eq a) => Eq (Modifier a) where | ||
- (Modifier f) == (Modifier g) = (f mempty == g mempty) | ||
- (AttrModifier f attr) == (AttrModifier g attr') = (f attr mempty == g attr' mempty) | ||
- (NullModifier) == (NullModifier) = True | ||
- _ == _ = False | ||
- | ||
-instance Modifiable Inlines where | ||
- modifier ils = case viewl (unMany ils) of | ||
- (x :< xs) | Seq.null xs -> case x of | ||
- (Emph _) -> Modifier emph | ||
- (Strong _) -> Modifier strong | ||
- (SmallCaps _) -> Modifier smallcaps | ||
- (Strikeout _) -> Modifier strikeout | ||
- (Superscript _) -> Modifier superscript | ||
- (Subscript _) -> Modifier subscript | ||
- (Span attr _) -> AttrModifier spanWith attr | ||
- _ -> NullModifier | ||
- _ -> NullModifier | ||
- | ||
- innards ils = case viewl (unMany ils) of | ||
- (x :< xs) | Seq.null xs -> case x of | ||
- (Emph lst) -> fromList lst | ||
- (Strong lst) -> fromList lst | ||
- (SmallCaps lst) -> fromList lst | ||
- (Strikeout lst) -> fromList lst | ||
- (Superscript lst) -> fromList lst | ||
- (Subscript lst) -> fromList lst | ||
- (Span _ lst) -> fromList lst | ||
- _ -> ils | ||
- _ -> ils | ||
- | ||
- getL ils = case viewl $ unMany ils of | ||
- (s :< sq) -> (singleton s, Many sq) | ||
- _ -> (mempty, ils) | ||
- | ||
- getR ils = case viewr $ unMany ils of | ||
- (sq :> s) -> (Many sq, singleton s) | ||
- _ -> (ils, mempty) | ||
- | ||
- spaceOut ils = | ||
- let (fs, ils') = unstack ils | ||
- contents = unMany ils' | ||
- left = case viewl contents of | ||
- (Space :< _) -> space | ||
- _ -> mempty | ||
- right = case viewr contents of | ||
- (_ :> Space) -> space | ||
- _ -> mempty in | ||
- (left, (stack fs $ trimInlines .Many $ contents), right) | ||
- | ||
-instance Modifiable Blocks where | ||
- modifier blks = case viewl (unMany blks) of | ||
- (x :< xs) | Seq.null xs -> case x of | ||
- (BlockQuote _) -> Modifier blockQuote | ||
- -- (Div attr _) -> AttrModifier divWith attr | ||
- _ -> NullModifier | ||
- _ -> NullModifier | ||
- | ||
- innards blks = case viewl (unMany blks) of | ||
- (x :< xs) | Seq.null xs -> case x of | ||
- (BlockQuote lst) -> fromList lst | ||
- -- (Div attr lst) -> fromList lst | ||
- _ -> blks | ||
- _ -> blks | ||
- | ||
- spaceOut blks = (mempty, blks, mempty) | ||
- | ||
- getL ils = case viewl $ unMany ils of | ||
- (s :< sq) -> (singleton s, Many sq) | ||
- _ -> (mempty, ils) | ||
- | ||
- getR ils = case viewr $ unMany ils of | ||
- (sq :> s) -> (Many sq, singleton s) | ||
- _ -> (ils, mempty) | ||
- | ||
- | ||
-unstack :: (Modifiable a) => a -> ([Modifier a], a) | ||
-unstack ms = case modifier ms of | ||
- NullModifier -> ([], ms) | ||
- _ -> (f : fs, ms') where | ||
- f = modifier ms | ||
- (fs, ms') = unstack $ innards ms | ||
- | ||
-stack :: (Monoid a, Modifiable a) => [Modifier a] -> a -> a | ||
-stack [] ms = ms | ||
-stack (NullModifier : fs) ms = stack fs ms | ||
-stack ((Modifier f) : fs) ms = | ||
- if isEmpty ms | ||
- then stack fs ms | ||
- else f $ stack fs ms | ||
-stack ((AttrModifier f attr) : fs) ms = f attr $ stack fs ms | ||
- | ||
-isEmpty :: (Monoid a, Eq a) => a -> Bool | ||
-isEmpty x = x == mempty | ||
- | ||
- | ||
-combine :: (Monoid a, Modifiable a, Eq a) => a -> a -> a | ||
-combine x y = | ||
- let (xs', x') = getR x | ||
- (y', ys') = getL y | ||
- in | ||
- xs' <> (combineSingleton x' y') <> ys' | ||
- | ||
-isAttrModifier :: Modifier a -> Bool | ||
-isAttrModifier (AttrModifier _ _) = True | ||
-isAttrModifier _ = False | ||
- | ||
-combineSingleton :: (Monoid a, Modifiable a, Eq a) => a -> a -> a | ||
-combineSingleton x y = | ||
- let (xfs, xs) = unstack x | ||
- (yfs, ys) = unstack y | ||
- shared = xfs `intersect` yfs | ||
- x_remaining = xfs \\ shared | ||
- y_remaining = yfs \\ shared | ||
- x_rem_attr = filter isAttrModifier x_remaining | ||
- y_rem_attr = filter isAttrModifier y_remaining | ||
- in | ||
- case null shared of | ||
- True | isEmpty xs && isEmpty ys -> | ||
- stack (x_rem_attr ++ y_rem_attr) mempty | ||
- | isEmpty xs -> | ||
- let (sp, y') = spaceOutL y in | ||
- (stack x_rem_attr mempty) <> sp <> y' | ||
- | isEmpty ys -> | ||
- let (x', sp) = spaceOutR x in | ||
- x' <> sp <> (stack y_rem_attr mempty) | ||
- | otherwise -> | ||
- let (x', xsp) = spaceOutR x | ||
- (ysp, y') = spaceOutL y | ||
- in | ||
- x' <> xsp <> ysp <> y' | ||
- False -> stack shared $ | ||
- combine | ||
- (stack x_remaining xs) | ||
- (stack y_remaining ys) | ||
- | ||
-(<+>) :: (Monoid a, Modifiable a, Eq a) => a -> a -> a | ||
-x <+> y = combine x y | ||
- | ||
-concatReduce :: (Monoid a, Modifiable a) => [a] -> a | ||
-concatReduce xs = foldl combine mempty xs |
@@ -0,0 +1,320 @@ | ||
+{-# LANGUAGE OverloadedStrings, PatternGuards #-} | ||
+{- | ||
+Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu> | ||
+ | ||
+This program is free software; you can redistribute it and/or modify | ||
+it under the terms of the GNU General Public License as published by | ||
+the Free Software Foundation; either version 2 of the License, or | ||
+(at your option) any later version. | ||
+ | ||
+This program is distributed in the hope that it will be useful, | ||
+but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
+GNU General Public License for more details. | ||
+ | ||
+You should have received a copy of the GNU General Public License | ||
+along with this program; if not, write to the Free Software | ||
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
+-} | ||
+ | ||
+{- | | ||
+ Module : Text.Pandoc.Writers.Docbook | ||
+ Copyright : Copyright (C) 2006-2015 John MacFarlane | ||
+ License : GNU GPL, version 2 or above | ||
+ | ||
+ Maintainer : John MacFarlane <jgm@berkeley.edu> | ||
+ Stability : alpha | ||
+ Portability : portable | ||
+ | ||
+Conversion of 'Pandoc' documents to Docbook XML. | ||
+-} | ||
+module Text.Pandoc.Writers.TEI (writeTEI) where | ||
+import Text.Pandoc.Definition | ||
+import Text.Pandoc.XML | ||
+import Text.Pandoc.Shared | ||
+import Text.Pandoc.Writers.Shared | ||
+import Text.Pandoc.Options | ||
+import Text.Pandoc.Templates (renderTemplate') | ||
+import Data.List ( stripPrefix, isPrefixOf, isSuffixOf ) | ||
+import Data.Char ( toLower ) | ||
+import Text.Pandoc.Highlighting ( languages, languagesByExtension ) | ||
+import Text.Pandoc.Pretty | ||
+import Text.Pandoc.ImageSize | ||
+import qualified Text.Pandoc.Builder as B | ||
+ | ||
+-- | Convert list of authors to a docbook <author> section | ||
+authorToTEI :: WriterOptions -> [Inline] -> B.Inlines | ||
+authorToTEI opts name' = | ||
+ let name = render Nothing $ inlinesToTEI opts name' | ||
+ colwidth = if writerWrapText opts == WrapAuto | ||
+ then Just $ writerColumns opts | ||
+ else Nothing | ||
+ in B.rawInline "tei" $ render colwidth $ | ||
+ inTagsSimple "author" (text $ escapeStringForXML name) | ||
+ | ||
+-- | Convert Pandoc document to string in Docbook format. | ||
+writeTEI :: WriterOptions -> Pandoc -> String | ||
+writeTEI opts (Pandoc meta blocks) = | ||
+ let elements = hierarchicalize blocks | ||
+ colwidth = if writerWrapText opts == WrapAuto | ||
+ then Just $ writerColumns opts | ||
+ else Nothing | ||
+ render' = render colwidth | ||
+ opts' = if "/book>" `isSuffixOf` | ||
+ (trimr $ writerTemplate opts) | ||
+ then opts{ writerChapters = True } | ||
+ else opts | ||
+ startLvl = if writerChapters opts' then 0 else 1 | ||
+ auths' = map (authorToTEI opts) $ docAuthors meta | ||
+ meta' = B.setMeta "author" auths' meta | ||
+ Just metadata = metaToJSON opts | ||
+ (Just . render colwidth . (vcat . | ||
+ (map (elementToTEI opts' startLvl)) . hierarchicalize)) | ||
+ (Just . render colwidth . inlinesToTEI opts') | ||
+ meta' | ||
+ main = render' $ vcat (map (elementToTEI opts' startLvl) elements) | ||
+ context = defField "body" main | ||
+ $ defField "mathml" (case writerHTMLMathMethod opts of | ||
+ MathML _ -> True | ||
+ _ -> False) | ||
+ $ metadata | ||
+ in if writerStandalone opts | ||
+ then renderTemplate' (writerTemplate opts) context | ||
+ else main | ||
+ | ||
+-- | Convert an Element to TEI. | ||
+elementToTEI :: WriterOptions -> Int -> Element -> Doc | ||
+elementToTEI opts _ (Blk block) = blockToTEI opts block | ||
+elementToTEI opts lvl (Sec _ _num (id',_,_) title elements) = | ||
+ -- TEI doesn't allow sections with no content, so insert some if needed | ||
+ let elements' = if null elements | ||
+ then [Blk (Para [])] | ||
+ else elements | ||
+ divType = case lvl of | ||
+ n | n == 0 -> "chapter" | ||
+ | n >= 1 && n <= 5 -> "level" ++ show n | ||
+ | otherwise -> "section" | ||
+ in inTags True "div" [("type", divType) | not (null id')] $ | ||
+-- ("id", writerIdentifierPrefix opts ++ id') | not (null id')] $ | ||
+ inTagsSimple "head" (inlinesToTEI opts title) $$ | ||
+ vcat (map (elementToTEI opts (lvl + 1)) elements') | ||
+ | ||
+-- | Convert a list of Pandoc blocks to TEI. | ||
+blocksToTEI :: WriterOptions -> [Block] -> Doc | ||
+blocksToTEI opts = vcat . map (blockToTEI opts) | ||
+ | ||
+-- | Auxiliary function to convert Plain block to Para. | ||
+plainToPara :: Block -> Block | ||
+plainToPara (Plain x) = Para x | ||
+plainToPara x = x | ||
+ | ||
+-- | Convert a list of pairs of terms and definitions into a TEI | ||
+-- list with labels and items. | ||
+deflistItemsToTEI :: WriterOptions -> [([Inline],[[Block]])] -> Doc | ||
+deflistItemsToTEI opts items = | ||
+ vcat $ map (\(term, defs) -> deflistItemToTEI opts term defs) items | ||
+ | ||
+-- | Convert a term and a list of blocks into a TEI varlistentry. | ||
+deflistItemToTEI :: WriterOptions -> [Inline] -> [[Block]] -> Doc | ||
+deflistItemToTEI opts term defs = | ||
+ let def' = concatMap (map plainToPara) defs | ||
+ in inTagsIndented "label" (inlinesToTEI opts term) $$ | ||
+ inTagsIndented "item" (blocksToTEI opts def') | ||
+ | ||
+-- | Convert a list of lists of blocks to a list of TEI list items. | ||
+listItemsToTEI :: WriterOptions -> [[Block]] -> Doc | ||
+listItemsToTEI opts items = vcat $ map (listItemToTEI opts) items | ||
+ | ||
+-- | Convert a list of blocks into a TEI list item. | ||
+listItemToTEI :: WriterOptions -> [Block] -> Doc | ||
+listItemToTEI opts item = | ||
+ inTagsIndented "item" $ blocksToTEI opts $ map plainToPara item | ||
+ | ||
+imageToTEI :: WriterOptions -> Attr -> String -> Doc | ||
+imageToTEI _ attr src = selfClosingTag "graphic" $ | ||
+ ("url", src) : idAndRole attr ++ dims | ||
+ where | ||
+ dims = go Width "width" ++ go Height "depth" | ||
+ go dir dstr = case (dimension dir attr) of | ||
+ Just a -> [(dstr, show a)] | ||
+ Nothing -> [] | ||
+ | ||
+-- | Convert a Pandoc block element to TEI. | ||
+blockToTEI :: WriterOptions -> Block -> Doc | ||
+blockToTEI _ Null = empty | ||
+-- Add ids to paragraphs in divs with ids - this is needed for | ||
+-- pandoc-citeproc to get link anchors in bibliographies: | ||
+blockToTEI opts (Div (ident,_,_) [Para lst]) = | ||
+ let attribs = [("id", ident) | not (null ident)] in | ||
+ inTags False "p" attribs $ inlinesToTEI opts lst | ||
+blockToTEI opts (Div _ bs) = blocksToTEI opts $ map plainToPara bs | ||
+blockToTEI _ (Header _ _ _) = empty -- should not occur after hierarchicalize | ||
+-- For TEI simple, text must be within containing block element, so | ||
+-- we use plainToPara to ensure that Plain text ends up contained by | ||
+-- something. | ||
+blockToTEI opts (Plain lst) = blockToTEI opts $ Para lst | ||
+-- title beginning with fig: indicates that the image is a figure | ||
+--blockToTEI opts (Para [Image attr txt (src,'f':'i':'g':':':_)]) = | ||
+-- let alt = inlinesToTEI opts txt | ||
+-- capt = if null txt | ||
+-- then empty | ||
+-- else inTagsSimple "title" alt | ||
+-- in inTagsIndented "figure" $ | ||
+-- capt $$ | ||
+-- (inTagsIndented "mediaobject" $ | ||
+-- (inTagsIndented "imageobject" | ||
+-- (imageToTEI opts attr src)) $$ | ||
+-- inTagsSimple "textobject" (inTagsSimple "phrase" alt)) | ||
+blockToTEI opts (Para lst) = | ||
+ inTags False "p" [] $ inlinesToTEI opts lst | ||
+blockToTEI opts (BlockQuote blocks) = | ||
+ inTagsIndented "quote" $ blocksToTEI opts blocks | ||
+blockToTEI _ (CodeBlock (_,classes,_) str) = | ||
+ text ("<ab type='codeblock " ++ lang ++ "'>") <> cr <> | ||
+ flush (text (escapeStringForXML str) <> cr <> text "</ab>") | ||
+ where lang = if null langs | ||
+ then "" | ||
+ else escapeStringForXML (head langs) | ||
+ isLang l = map toLower l `elem` map (map toLower) languages | ||
+ langsFrom s = if isLang s | ||
+ then [s] | ||
+ else languagesByExtension . map toLower $ s | ||
+ langs = concatMap langsFrom classes | ||
+blockToTEI opts (BulletList lst) = | ||
+ let attribs = [("type", "unordered")] | ||
+ in inTags True "list" attribs $ listItemsToTEI opts lst | ||
+blockToTEI _ (OrderedList _ []) = empty | ||
+blockToTEI opts (OrderedList (start, numstyle, _) (first:rest)) = | ||
+ let attribs = case numstyle of | ||
+ DefaultStyle -> [] | ||
+ Decimal -> [("type", "ordered:arabic")] | ||
+ Example -> [("type", "ordered:arabic")] | ||
+ UpperAlpha -> [("type", "ordered:upperalpha")] | ||
+ LowerAlpha -> [("type", "ordered:loweralpha")] | ||
+ UpperRoman -> [("type", "ordered:upperroman")] | ||
+ LowerRoman -> [("type", "ordered:lowerroman")] | ||
+ items = if start == 1 | ||
+ then listItemsToTEI opts (first:rest) | ||
+ else (inTags True "item" [("n",show start)] | ||
+ (blocksToTEI opts $ map plainToPara first)) $$ | ||
+ listItemsToTEI opts rest | ||
+ in inTags True "list" attribs items | ||
+blockToTEI opts (DefinitionList lst) = | ||
+ let attribs = [("type", "definition")] | ||
+ in inTags True "list" attribs $ deflistItemsToTEI opts lst | ||
+blockToTEI _ (RawBlock f str) | ||
+ | f == "tei" = text str -- raw TEI block (should such a thing exist). | ||
+-- | f == "html" = text str -- allow html for backwards compatibility | ||
+ | otherwise = empty | ||
+blockToTEI _ HorizontalRule = | ||
+ selfClosingTag "milestone" [("unit","undefined"), ("type","separator"),("rendition","line")] | ||
+ | ||
+-- | TEI Tables | ||
+-- TEI Simple's tables are composed of cells and rows; other | ||
+-- table info in the AST is here lossily discard. | ||
+blockToTEI opts (Table _ _ _ headers rows) = | ||
+ let | ||
+ headers' = tableHeadersToTEI opts headers | ||
+-- headers' = if all null headers | ||
+-- then return empty | ||
+-- else tableRowToTEI opts headers | ||
+ in | ||
+ inTags True "table" [] $ | ||
+ vcat $ [headers'] <> map (tableRowToTEI opts) rows | ||
+ | ||
+tableRowToTEI :: WriterOptions | ||
+ -> [[Block]] | ||
+ -> Doc | ||
+tableRowToTEI opts cols = | ||
+ inTagsIndented "row" $ vcat $ map (tableItemToTEI opts) cols | ||
+ | ||
+tableHeadersToTEI :: WriterOptions | ||
+ -> [[Block]] | ||
+ -> Doc | ||
+tableHeadersToTEI opts cols = | ||
+ inTags True "row" [("role","label")] $ vcat $ map (tableItemToTEI opts) cols | ||
+ | ||
+tableItemToTEI :: WriterOptions | ||
+ -> [Block] | ||
+ -> Doc | ||
+tableItemToTEI opts item = | ||
+ inTags False "cell" [] $ vcat $ map (blockToTEI opts) item | ||
+ | ||
+-- | Convert a list of inline elements to TEI. | ||
+inlinesToTEI :: WriterOptions -> [Inline] -> Doc | ||
+inlinesToTEI opts lst = hcat $ map (inlineToTEI opts) lst | ||
+ | ||
+-- | Convert an inline element to TEI. | ||
+inlineToTEI :: WriterOptions -> Inline -> Doc | ||
+inlineToTEI _ (Str str) = text $ escapeStringForXML str | ||
+inlineToTEI opts (Emph lst) = | ||
+ inTags False "hi" [("rendition","simple:italic")] $ inlinesToTEI opts lst | ||
+inlineToTEI opts (Strong lst) = | ||
+ inTags False "hi" [("rendition", "simple:bold")] $ inlinesToTEI opts lst | ||
+inlineToTEI opts (Strikeout lst) = | ||
+ inTags False "hi" [("rendition", "simple:strikethrough")] $ | ||
+ inlinesToTEI opts lst | ||
+inlineToTEI opts (Superscript lst) = | ||
+ inTags False "hi" [("rendition", "simple:superscript")] $ inlinesToTEI opts lst | ||
+inlineToTEI opts (Subscript lst) = | ||
+ inTags False "hi" [("rendition", "simple:subscript")] $ inlinesToTEI opts lst | ||
+inlineToTEI opts (SmallCaps lst) = | ||
+ inTags False "hi" [("rendition", "simple:smallcaps")] $ | ||
+ inlinesToTEI opts lst | ||
+inlineToTEI opts (Quoted _ lst) = | ||
+ inTagsSimple "quote" $ inlinesToTEI opts lst | ||
+inlineToTEI opts (Cite _ lst) = | ||
+ inlinesToTEI opts lst | ||
+inlineToTEI opts (Span _ ils) = | ||
+ inlinesToTEI opts ils | ||
+inlineToTEI _ (Code _ str) = | ||
+ inTags False "seg" [("type","code")] $ text (escapeStringForXML str) | ||
+-- Distinguish display from inline math by wrapping the former in a "figure." | ||
+inlineToTEI _ (Math t str) = | ||
+ case t of | ||
+ InlineMath -> inTags False "formula" [("notation","TeX")] $ | ||
+ text (str) | ||
+ DisplayMath -> inTags True "figure" [("type","math")] $ | ||
+ inTags False "formula" [("notation","TeX")] $ text (str) | ||
+ | ||
+inlineToTEI _ (RawInline f x) | f == "tei" = text x | ||
+ | otherwise = empty | ||
+inlineToTEI _ LineBreak = selfClosingTag "lb" [] | ||
+inlineToTEI _ Space = space | ||
+-- because we use \n for LineBreak, we can't do soft breaks: | ||
+inlineToTEI _ SoftBreak = space | ||
+inlineToTEI opts (Link attr txt (src, _)) | ||
+ | Just email <- stripPrefix "mailto:" src = | ||
+ let emailLink = text $ | ||
+ escapeStringForXML $ email | ||
+ in case txt of | ||
+ [Str s] | escapeURI s == email -> emailLink | ||
+ _ -> inlinesToTEI opts txt <+> | ||
+ char '(' <> emailLink <> char ')' | ||
+ | otherwise = | ||
+ (if isPrefixOf "#" src | ||
+ then inTags False "ref" $ ("target", drop 1 src) : idAndRole attr | ||
+ else inTags False "ref" $ ("target", src) : idAndRole attr ) $ | ||
+ inlinesToTEI opts txt | ||
+inlineToTEI opts (Image attr description (src, tit)) = | ||
+ let titleDoc = if null tit | ||
+ then empty | ||
+ else inTags False "figDesc" [] (text $ escapeStringForXML tit) | ||
+ imageDesc = if null description | ||
+ then empty | ||
+ else inTags False "head" [] (inlinesToTEI opts description) | ||
+ in inTagsIndented "figure" $ imageDesc $$ | ||
+ imageToTEI opts attr src $$ titleDoc | ||
+inlineToTEI opts (Note contents) = | ||
+ inTagsIndented "note" $ blocksToTEI opts contents | ||
+ | ||
+idAndRole :: Attr -> [(String, String)] | ||
+idAndRole (id',cls,_) = ident ++ role | ||
+ where | ||
+ ident = if null id' | ||
+ then [] | ||
+ else [("id", id')] | ||
+ role = if null cls | ||
+ then [] | ||
+ else [("role", unwords cls)] | ||
+ |
Showing you all comments on commits in this comparison.
At the top of the releases page the version number 1.16.0.1 is missing. I'm wondering if it's manually added to that page? Would it be useful to include the release dates here?
Nice !
I just have a question (unrelated to this commit), is there a special argument or a way to prevent the italic on the markdown generated links ? In my docx In-file the links have a regular style but there are all converted with surrounded '*' in the markdown out-file.
The problem is that your file explicitly tells word to underline the hyperlink, and underlines are understood as emphasis. Usually the underline is built into the hyperlink style, so we can ignore it. I could consider ignoring underlines in a hyperlink in general, but that could be tricky. (What if someone changes their hyperlink style, but still wants to use underline for emphasis?) I think this comes out of a problem with the copy-paste job that created the file. Do you have this problem with the file you created from scratch?
Note you could write a pandoc filter to unitalicize links pretty easily. (I could help you with it some other time, but it should be fairly trivial given the procedures outlines in the documentation.)
I tried to do something but I'm stuck with an error.
According to this forum on python filters, "Link" seem to expect 2 arguments but after I tried making this filter for links:
from pandocfilters import toJSONFilter, Link
def linksimple(key, value, format, meta):
if key == 'Link':
return Link(value[0],value[1])
if __name__ == "__main__":
toJSONFilter(linksimple)
It throw me this error:
ValueError: Link expects 3 arguments, but given 2
full detail of the error here:
$ pandoc -s -o sauceFF.odt kbcorrect.odt -F ./ln.py
Traceback (most recent call last):
File "./ln.py", line 15, in <module>
toJSONFilter(linksimple)
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 46, in toJSONFilter
toJSONFilters([action])
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 76, in toJSONFilters
altered = reduce(lambda x, action: walk(x, action, format, doc[0]['unMeta']), actions, doc)
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 76, in <lambda>
altered = reduce(lambda x, action: walk(x, action, format, doc[0]['unMeta']), actions, doc)
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 34, in walk
array.append(walk(item, action, format, meta))
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 27, in walk
array.append(walk(item, action, format, meta))
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 39, in walk
obj[k] = walk(x[k], action, format, meta)
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 25, in walk
res = action(item['t'], item['c'], format, meta)
File "./ln.py", line 12, in linksimple
return Link("sauce", [value[0],value[1]])
File "C:\Users\etudiant\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandocfilters.py", line 119, in fun
+ str(lenargs))
ValueError: Link expects 3 arguments, but given 2
pandoc.exe: Error running filter ./ln.py
Filter returned error status 1
There are three arguments to Link in the newest version of pandoc. I have to admit that I don't know much about the python filters, so there might be a better way to do this, but the below should work. (The only problem with it is that it deals with the JSON directly in one place, which could be a problem if the JSON format changes.) You might be able to get some improvements on the pandoc-discuss list. In any case, it should work for the document you're dealing with.
from pandocfilters import toJSONFilter, Link, Emph
def linksimple(key, value, format, meta):
if key == 'Link':
ils = value[1]
# move the inlines into a variable.
newval = ils
# If there is only one element in the inlines and it has a
# type...
if len(ils) == 1 and "t" in ils[0]:
# And that type is emph
if ils[0]["t"] == "Emph":
# we unwrap the inlines from that emph
newval = ils[0]["c"]
return Link(value[0],newval, value[2])
if __name__ == "__main__":
toJSONFilter(linksimple)
stack complains about the use of aeson-0.11
instead of aeson-0.11.0.0
:
Populated index cache.
Didn't see aeson-0.11 in your package indices.
Updating and trying again.
Updating package index Hackage (mirrored at https://github.co/commercialhaskell
Fetched package index.
Populated index cache.
The following package identifiers were not found in your indices: aeson-0.11
Possible candidates: aeson-0.11.0.0.
But changing stack.yaml to aeson-0.11.0.0
produces unresolvable dependency problems.
FWIW, there are a few typos on lines 16, 147 (Maura), 72 (Raniere), and 63 (divs with).