Commit graph

2688 commits

Author SHA1 Message Date
Matej Kollar
0bda602fcb Little restructuralization. 2014-07-04 23:48:58 +02:00
Matej Kollar
d2c81346e7 Move more things to Reader. 2014-07-04 23:42:10 +02:00
Matej Kollar
0bc900e36a HLint suggestions. 2014-07-04 23:25:44 +02:00
Matej Kollar
05b94c31ae Use Reader.
To avoid to pass opts explicitly around (as we
do not use it very much at the moment anyway)
2014-07-02 06:36:31 +02:00
Jesse Rosenthal
0abfd386a4 Docx reader: clean up parStyle processing.
This gets rid of `divAttrToContainers`: an internal convenience function
which had become pretty inconvenient. Rather than converting classes and
indentations to string lists and back, we deal with the `pPr` attribute
directly.
2014-06-30 11:19:06 -04:00
John MacFarlane
3fbbafd391 Rewrote normalize for efficiency. (Closes #1385.)
* Added normalizeInlines, normalizeBlocks.
* Type signature is now more narrow, `Pandoc -> Pandoc` instead of
  `Data a :: a -> a`.  Some users may need to change their uses of
  `normalize` to the newly exported `normalizeInlines` or
  `normalizeBlocks`.
2014-06-29 23:05:08 -07:00
John MacFarlane
aad618d9db Merge pull request #1386 from jkr/hanging_indent
Fix hanging indent behavior
2014-06-29 21:31:44 -07:00
Jesse Rosenthal
0f59196e0e Docx reader: Make use of new ParIndentation info.
Here, when hanging indents are greater than or equal to left indents, we
don't set it to block quote. Such indents are frequently used in
academic bibliographies. (Thanks to Caleb McDaniel.)
2014-06-29 23:20:10 -04:00
Jesse Rosenthal
c0fcc8a789 Docx reader: Add ParIndentation type to parser.
This lets us keep more information about the indentation, and act
accordingly in the reader.
2014-06-29 23:19:56 -04:00
John MacFarlane
45d26fd01a Merge pull request #1383 from jkr/writer-bookmark-fix
Docx writer: insert bookmark tags inside <w:p> tag.
2014-06-29 20:01:51 -07:00
Jesse Rosenthal
0587334bc0 Docx writer: insert bookmark tags inside <w:p> tag.
This makes the header anchors in pandoc-generated ooxml match those
generated by word.
2014-06-29 16:38:51 -04:00
Jesse Rosenthal
b1eba3c65c Docx Reader: Update state properly
Previously, a fresh state was created for the purpose of updating. In
the future, when there is more than one field in the state, this
obviously won't work.
2014-06-29 08:14:36 -04:00
Jesse Rosenthal
c0a8d5ac72 Docx Reader: All headers get auto id.
Previously, only those with an anchor got an auto id. Now, all do, which
puts it in line with pandoc's markdown extension.
2014-06-28 17:47:00 -04:00
Jesse Rosenthal
dce360e1e6 Docx Reader: Introduce link rewriting. 2014-06-28 04:00:16 -04:00
Jesse Rosenthal
b89a3ba2b1 make makeHeaderAnchors make an auto id
Record relationship between original id and auto id, so we can fix links
after.
2014-06-28 04:00:16 -04:00
Jesse Rosenthal
5969baf5b9 Rewrote header generation.
In preparation for auto ids.
2014-06-28 04:00:16 -04:00
Jesse Rosenthal
1de8d4d087 Docx Reader: Simplify makeHeaderAnchors
Using pattern guard, in preparation for doing some more complicated
stuff with it (recording header anchors, so we can change them to auto
ids.)
2014-06-28 04:00:16 -04:00
Jesse Rosenthal
ab76bbebbe Docx Reader: Clean up guards
Use PatternGuards to get rid of need for `isJust`, `fromJust`
altogether.
2014-06-28 04:00:16 -04:00
Jesse Rosenthal
db187348cd Docx rdr: Avoid mapping makeHeaderAnchors globally
It only applies to headers, so we can just apply it when we make a
header.
2014-06-28 04:00:16 -04:00
Jesse Rosenthal
4248f25152 Move Docx reader to DocxContext monad
This is a ReaderT State stack, which keeps track of some environment info, such
as the options and the docx doc. The state will come in handy in the future,
for a couple of planned features (rewriting the section anchors as auto_idents,
and hopefully smart-quoting).
2014-06-28 04:00:16 -04:00
John MacFarlane
b2127311cb Require haddock-library >= 1.1 and simplify haddock reader code.
See #1346.
2014-06-26 12:35:13 -07:00
John MacFarlane
9f694619cd Merge pull request #1374 from jkr/track-changes-options
Track changes with options
2014-06-25 23:51:16 -07:00
Jesse Rosenthal
2396be6f57 Docx reader: Code cleanup in parse.
Remove some redundant ways of dealing with Maybe.
2014-06-25 17:12:03 -04:00
Jesse Rosenthal
0e9bf37f64 Docx reader: Make use of track-changes option. 2014-06-25 14:17:20 -04:00
Jesse Rosenthal
d824f89fb3 Add TrackChanges to Options export. 2014-06-25 14:05:21 -04:00
Jesse Rosenthal
6ff84b5e8d Add reader option for track changes. 2014-06-25 13:57:56 -04:00
Jesse Rosenthal
3ec62d0064 Add TrackChanges type to options. 2014-06-25 13:50:08 -04:00
Jesse Rosenthal
9614ddfedc Docx reader: Remove unnecessary filter in Parse.
mapMaybe does the filtering for us.
2014-06-25 11:00:15 -04:00
Jesse Rosenthal
ed44e4ca8c Docx reader: Add rudimentary track changes support.
This will only read the insertions, and ignore the deletions.
2014-06-25 10:38:01 -04:00
Jesse Rosenthal
38e1d3e95b Docx reader: Parse Insertions and Deletions.
This is just for the Parse module, reading it into the Docx format. It
still has to be translated into pandoc.
2014-06-25 10:32:48 -04:00
Jesse Rosenthal
c343f1a90b Docx Reader: Add change types
Insertion and deletion. Dates are just strings for now.
2014-06-25 08:10:19 -04:00
Jesse Rosenthal
69743cd598 Docx reader: Ignore zero (or negative) indent
If a block has an indentation less than or equal to zero, it should not be
treated as a block quote.
2014-06-24 15:06:25 -04:00
Jesse Rosenthal
a8866bc121 Docx reader: remove T.P.Generic import.
This marks the removal of the final tree-walk in the code. (Though there
is still one in the Lists module.)
2014-06-24 12:15:26 -04:00
Jesse Rosenthal
5ae6b8c6f1 Docx reader: pass definition test.
This commit also fixes a problem with the previous code pushes, which
wouldn't allow code blocks to share a div.
2014-06-24 12:12:02 -04:00
Jesse Rosenthal
bebea5e936 Docx reader: pass code tests. 2014-06-24 10:34:07 -04:00
Jesse Rosenthal
08633fad33 Add copyright block to T.P.R.Docx.Reducible. 2014-06-23 20:26:08 -04:00
John MacFarlane
ac6756009f Merge pull request #1366 from jkr/reducible3
Docx rewrite and cleanup (in terms of Reducible typeclass)
2014-06-23 14:33:38 -07:00
Jesse Rosenthal
11b0778744 Use Reducible in docx reader.
This cleans up them implementation, and cuts down on tree-walking.
Anecdotally, I've seen about a 3-fold speedup.
2014-06-23 17:08:17 -04:00
Jesse Rosenthal
94d0fb1538 Move some of the clean-up logic into List module.
This will allow us to get rid of more general functions we no longer need in
the main reader.
2014-06-23 17:08:17 -04:00
Jesse Rosenthal
ef5fad2698 Add new typeclass, Reducible
This defines a typeclass `Reducible` which allows us to "reduce" pandoc
Inlines and Blocks, like so

    Emph [Strong [Str "foo", Space]] <++> Strong [Emph [Str "bar"]], Str
"baz"] =
        [Strong [Emph [Str "foo", Space, Str "bar"], Space, Str "baz"]]

So adjacent formattings and strings are appropriately grouped.

Another set of operators for `(Reducible a) => (Many a)` are also
included.
2014-06-23 17:08:05 -04:00
John MacFarlane
87ab01637e LaTeX writer: Use \textquotesingle for ' in inline code.
Otherwise we get curly quotes in the PDF output.
Closes #1364.
2014-06-23 12:51:10 -07:00
John MacFarlane
e03ed7377c Markdown reader: Combine consecutive latex environments.
This helps when you have two minipages which can't have
blank lines between them.

See #690, #1196.
2014-06-23 12:42:27 -07:00
Jesse Rosenthal
8e5bd9d851 Docx reader: Fix spacing in formatting.
The normalizing tests revealed a problem with unformatted spaces, brought about
by `spanTrim`. This fixes by not trimming the spaces out of spans until they
are in their final form.
2014-06-22 01:53:30 -04:00
Jesse Rosenthal
9c7e0dc84b Implement new normalization.
There were some problems with the old str normalization. This fixes those
problems. Also, since it drills down on its own, it only needs to be
mapped over the blocks, not walked over the tree.
2014-06-22 00:45:18 -04:00
John MacFarlane
5d0103606f Markdown reader: Support smallcaps through span.
`<span style="font-variant:small-caps;">foo</span>` will be
parsed as a `SmallCaps` inline, and will work in all output
formats that support small caps.

Closes #1360.
2014-06-20 15:26:45 -07:00
John MacFarlane
d397a66107 MediaWiki reader: Tightened up template parsing.
The opening "{{" must be followed by an alphanumeric or ':'.
This prevents the exponential slowdown in #1033.
Closes #1033.
2014-06-20 12:00:26 -07:00
John MacFarlane
8f20ac3da3 MediaWiki reader: Support --trace. 2014-06-20 11:39:24 -07:00
John MacFarlane
d81b4358ea LaTeX writer: Correctly handle figures in notes.
Notes can't contain figures in LaTeX, so we fake it to avoid
an error.  Closes #1053.
2014-06-20 11:26:38 -07:00
John MacFarlane
56c410ef6a Markdown reader: Prevent spurious line breaks after list items.
When the `hard_line_breaks` option was specified, pandoc would
produce a spurious line break after a tight list item.  This
patch solves the problem.  Closes #1137.
2014-06-20 11:10:35 -07:00
John MacFarlane
2eadc78053 ImageSize: Use default instead of failing if image size not found
in exif header.  Closes #1358.
2014-06-20 10:58:26 -07:00