aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx.hs
AgeCommit message (Collapse)AuthorFilesLines
2018-01-16Docx reader: Parse hyperlinks in instrText tagsJesse Rosenthal1-2/+4
This was a form of hyperlink found in older versions of word. The changes introduced for this, though, create a framework for parsing further fields in MS Word (see the spec, ECMA-376-1:2016, ยง17.16.5, for more on these fields). Closes #3389 and #4266.
2018-01-16Docx reader: Parse fldChar tagsJesse Rosenthal1-0/+3
This will allow us to parse instrTxt inside fldChar tags.
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2018-01-02Docx reader: remove MultiWayIfJesse Rosenthal1-38/+39
Different formatting rules across 7.X and 8.X. Use empty case expression instead.
2018-01-02Docx reader: Allow for insertion/deletion of paragraphs.Jesse Rosenthal1-4/+44
If the paragraph has a deleted or inserted paragraph break (depending on the track-changes setting) we hold onto it until the next paragraph. This takes care of accept and reject. For this we introduce a new state which holds the ils from the previous para if necessary. For `--track-changes=all`, we add an empty span with class `paragraph-insertion`/`paragraph-deletion` at the end of the paragraph prior to the break to be inserted or deleted. Closes #3927.
2018-01-02Docx reader: Extract tracked changes type from parpart.Jesse Rosenthal1-2/+2
We're going to want to use it elsewhere as well, in upcoming tracking of paragraph insertion/deletion.
2017-12-31Docx reader: minor cleanup.Jesse Rosenthal1-1/+2
2017-12-31Docx Reader: Combine adjacent anchors.Jesse Rosenthal1-20/+47
There isn't any reason to have numberous anchors in the same place, since we can't maintain docx's non-nesting overlapping. So we reduce to a single anchor, and have all links pointing to one of the overlapping anchors point to that one. This changes the behavior from commit e90c714c7 slightly (use the first anchor instead of the last) so we change the expected test result. Note that because this produces a state that has to be set after every invocation of `parPartToInlines`, we make the main function into a primed subfunction `parPartToInlines'`, and make `parPartToInlines` a wrapper around that.
2017-12-30Docx reader: Remove unused anchors.Jesse Rosenthal1-5/+27
Docx produces a lot of anchors with nothing pointing to them -- we now remove these to produce cleaner output. Note that this has to occur at the end of the process because it has to follow link/anchor rewriting. Closes #3679.
2017-12-22API change: export blocksToInlines' from Text.Pandoc.Sharedmb211-1/+1
2017-12-13Docx writer: Continue lists after interruption.Jesse Rosenthal1-15/+22
Docx expects that lists will continue where they left off after an interruption and introduces a new id if a list is starting again. So we keep track of the state of lists and use them to define a "start" attribute, if necessary. Closes #4025
2017-12-04Add `empty_paragraphs` extension.John MacFarlane1-1/+4
* Deprecate `--strip-empty-paragraphs` option. Instead we now use an `empty_paragraphs` extension that can be enabled on the reader or writer. By default, disabled. * Add `Ext_empty_paragraphs` constructor to `Extension`. * Revert "Docx reader: don't strip out empty paragraphs." This reverts commit d6c58eb836f033a48955796de4d9ffb3b30e297b. * Implement `empty_paragraphs` extension in docx reader and writer, opendocument writer, html reader and writer. * Add tests for `empty_paragraphs` extension.
2017-12-02Docx reader: don't strip out empty paragraphs.John MacFarlane1-3/+1
We now have the `--strip-empty-paragraphs` option for that, if you want it. Closes #2252. Updated docx reader tests. We use stripEmptyParagraphs to avoid changing too many tests. We should add new tests for empty paragraphs.
2017-10-29Source code reformatting.John MacFarlane1-2/+2
2017-10-27hlint suggestions.John MacFarlane1-38/+37
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-2/+2
2017-10-27Consistent underline for Readers (#2270)hftf1-2/+3
* Added underlineSpan builder function. This can be easily updated if needed. The purpose is for Readers to transform underlines consistently. * Docx Reader: Use underlineSpan and update test * Org Reader: Use underlineSpan and add test * Textile Reader: Use underlineSpan and add test case * Txt2Tags Reader: Use underlineSpan and update test * HTML Reader: Use underlineSpan and add test case
2017-06-17Use Control.Monad.State.Strict throughout.John MacFarlane1-1/+1
This gives 20-30% speedup and reduction of memory usage in most of the writers.
2017-05-13Update dates in copyright noticesAlbert Krewinkel1-2/+2
This follows the suggestions given by the FSF for GPL licensed software. <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>
2017-04-15Docx reader: removed readDocxWithWarnings (API change).John MacFarlane1-9/+1
No longer necessary with pandoc 2.0 framework.
2017-03-10Docx reader: more efficient trimSps.John MacFarlane1-9/+9
Replacing trimLineBreaks. This does the work of normalizeSpaces as well, so we avoid the need for that function here. See #1530.
2017-03-04Stylish-haskell automatic formatting changes.John MacFarlane1-41/+43
2017-02-11Use new warnings throughout the code base.John MacFarlane1-3/+6
2017-02-03Docx reader: Don't drop smartTag contents.John MacFarlane1-0/+3
This just parses inside smartTags and yields their contents, ignoring the attributes of the smartTag. @jkr, you may want to adjust this, but I wanted to get a fix in as fast as possible for the dropped content. Closes #2242; see also #3412.
2017-01-25Class: rename addWarning[WithPos] to warning[WithPos].John MacFarlane1-2/+2
There's already a function addWarning in Parsing! Maybe we can dispense with that now, but I still like 'warning' better as a name.
2017-01-25Class: Renamed 'warn' to 'addWarning' and consolidated RTF writer.John MacFarlane1-2/+2
* Renaming Text.Pandoc.Class.warn to addWarning avoids conflict with Text.Pandoc.Shared.warn. * Removed writeRTFWithEmbeddedImages from Text.Pandoc.Writers.RTF. This is no longer needed; we automatically handle embedded images using the PandocM functions. [API change]
2017-01-25Unify Errors.Jesse Rosenthal1-1/+2
2017-01-25Working on readers.Jesse Rosenthal1-52/+44
2017-01-25Deleted whitespace at end of source lines.John MacFarlane1-2/+2
2016-12-13Docx reader: Empty header should be list of lists.Jesse Rosenthal1-9/+11
In the past, the docx reader wrote an empty header as an empty list. It should have the same width as a row (and be filled with empty cells). (Note that I've reordered the code here slightly to get rid of a call to `head`. It wasn't unsafe because it tested for null, but it was a bit of a smell.)
2016-12-08Docx reader: Ensure one-row tables don't have header.Jesse Rosenthal1-1/+2
Tables in MS Word are set by default to have special first-row formatting, which pandoc uses to determine whether or not they have a header. This means that one-row tables will, by default, have only a header -- which we imagine is not what people want. This change ensures that a one-row table is not understood to be a header only. Note that this means that it is impossible to produce a header-only table from docx, even though it is legal pandoc. But we believe that in nearly all cases, it will be an accidental (and unwelcome) result Closes #3285.
2016-11-10Docx reader: add a placeholder value for CHART.Jesse Rosenthal1-0/+3
We wrap `[CHART]` in a `<span class="chart">`. Note that it maps to inlines because, in docx, anything in a drawing tag can be part of a larger paragraph.
2016-11-02Docx reader: Handle Alt text and titles in images.Jesse Rosenthal1-4/+4
We use the "description" field as alt text and the "title" field as title. These can be accessed through the "Format Picture" dialog in Word.
2016-09-02Remove Text.Pandoc.Compat.ExceptJesse Rosenthal1-1/+1
2016-08-29Docx reader: make all compilers happy with traversable.Jesse Rosenthal1-1/+3
The last attempt to make 7.8 happy made 7.10 unhappy. So we need some conditional logic to appease all versions.
2016-08-29Docx reader: Import traverse for ghc 7.8Jesse Rosenthal1-0/+1
The GHC 7.8 build was erroring without it.
2016-08-29Docx reader: clean up function with `traverse`Jesse Rosenthal1-6/+1
2016-08-28Docx reader: update copyright.Jesse Rosenthal1-2/+2
2016-08-28Docx reader: use all anchor spans for header ids.Jesse Rosenthal1-1/+1
Previously we only used the first anchor span to affect header ids. This allows us to use all the anchor spans in a header, whether they're nested or not. Along with 62882f97, this closes #3088.
2016-08-28Docx reader: Let headers use exisiting id.Jesse Rosenthal1-6/+10
Previously we always generated an id for headers (since they wouldn't bring one from Docx). Now we let it use an existing one if possible. This should allow us to recurs through anchor spans.
2016-08-28Docx reader: Handle anchor spans with content in headers.Jesse Rosenthal1-7/+8
Previously, we would only be able to figure out internal links to a header in a docx if the anchor span was empty. We change that to read the inlines out of the first anchor span in a header. This still leaves another problem: what to do if there are multiple anchor spans in a header. That will be addressed in a future commit.
2016-06-23Docx reader: Add warning for advanced comment formatting.Jesse Rosenthal1-2/+18
We can't guarantee we'll convert every comment correctly, though we'll do the best we can. This warns if the comment includes something other than Para or Plain.
2016-06-23docx reader: enable warnings in top-level readerJesse Rosenthal1-6/+10
Previously we had only allowed for warnings in the parser. Now we allow for them in the `Docx.hs` as well. The warnings are simply concatenated.
2016-06-23Docx reader: add simple comment functionality.Jesse Rosenthal1-0/+16
This adds simple track-changes comment parsing to the docx reader. It is turned on with `--track-changes=all`. All comments are converted to inlines, which can list some information. In the future a warning will be added for comments with formatting that seems like it will be excessively denatured. Note that comments can extend across blocks. For that reason there are two spans: `comment-start` and `comment-end`. `comment-start` will contain the comment. `comment-end` will always be empty. The two will be associated by a numeric id.
2016-05-01Docx Reader: Throw PandocError on unzip failureJesse Rosenthal1-4/+5
Previously, readDocx would error out if zip-archive failed. We change the archive extraction step from `toArchive` to `toArchiveOrFail`, which returns an Either value.
2016-03-12Add readDocxWithWarningsJesse Rosenthal1-6/+15
The regular readDocx just becomes a special case.
2016-03-08Docx reader: update feature checklist.Jesse Rosenthal1-5/+3
The feature checklist in the source code was out of date. Update.
2016-02-26Docx Reader: Get rid of Modifiable typeclass.Jesse Rosenthal1-15/+15
The docx reader used to use a Modifiable typeclass to combine both Blocks and Inlines. But all the work was in the inlines. So most of the generality was wasted, at the expense of making the code harder to understand. This gets rid of the generality, and adds functions for Blocks and Inlines. It should be a bit easier to work with going forward.
2016-01-22Changed type of Shared.uniqueIdent argument from [String] to Set String.John MacFarlane1-3/+4
This avoids performance problems in documents with many identically named headers. Closes #2671.
2015-12-13Docx reader: image attributesmb211-4/+11