aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx.hs
AgeCommit message (Collapse)AuthorFilesLines
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
2015-11-23Docx Reader: Remove DummyListItem typeJesse Rosenthal1-2/+2
Change 5527465c introduced a `DummyListItem` type in Docx/Parse.hs. In retrospect, this seems like it mixes parsing and iterpretation excessively. What's *really* going on is that we have a list item without and associate level or numeric info. We can decide what to do what that in Docx.hs (treat it like a list paragraph), but the parser shouldn't make that decision. This commit makes what is going on a bit more explicit. `LevelInfo` is now a Maybe value in the `ListItem` type. If it's a Nothing, we treat it as a ListParagraph. If it's a Just, it's a normal list item.
2015-11-19Merge branch 'new-image-attributes' of https://github.com/mb21/pandoc into ↵John MacFarlane1-2/+2
mb21-new-image-attributes * Bumped version to 1.16. * Added Attr field to Link and Image. * Added `common_link_attributes` extension. * Updated readers for link attributes. * Updated writers for link attributes. * Updated tests * Updated stack.yaml to build against unreleased versions of pandoc-types and texmath. * Fixed various compiler warnings. Closes #261. TODO: * Relative (percentage) image widths in docx writer. * ODT/OpenDocument writer (untested, same issue about percentage widths). * Update pandoc-citeproc.
2015-11-18Docx reader: Handle dummy list items.Jesse Rosenthal1-0/+4
These come up when people create a list item and then delete the bullet. It doesn't refer to any real list item, and we used to ignore it. We handle it with a DummyListItem type, which, in Docx.hs, is turned into a normal paragraph with a "ListParagraph" class. If it follow another list item, it is folded as another paragraph into that item. If it doesn't, it's just its own (usually indented, and therefore block-quoted) paragraph.
2015-11-09Revert "Use -XNoImplicitPrelude and 'import Prelude' explicitly."John MacFarlane1-1/+0
This reverts commit c423dbb5a34c2d1195020e0f0ca3aae883d0749b.
2015-11-08Use -XNoImplicitPrelude and 'import Prelude' explicitly.John MacFarlane1-0/+1
This is needed for ghci to work with pandoc, given that we now use a custom prelude. Closes #2503.
2015-10-14Use custom Prelude to avoid compiler warnings.John MacFarlane1-2/+0
- The (non-exported) prelude is in prelude/Prelude.hs. - It exports Monoid and Applicative, like base 4.8 prelude, but works with older base versions. - It exports (<>) for mappend. - It hides 'catch' on older base versions. This allows us to remove many imports of Data.Monoid and Control.Applicative, and remove Text.Pandoc.Compat.Monoid. It should allow us to use -Wall again for ghc 7.10.
2015-10-04Docx Reader: Parse soft, no-break hyphen elementsOphir Lifshitz1-0/+4
2015-08-07Updated readers, writers and README for link attributemb211-2/+2
2015-03-28Merge branch 'errortype' of https://github.com/mpickering/pandoc into ↵John MacFarlane1-8/+11
mpickering-errortype Conflicts: benchmark/benchmark-pandoc.hs src/Text/Pandoc/Readers/Markdown.hs src/Text/Pandoc/Readers/Org.hs src/Text/Pandoc/Readers/RST.hs tests/Tests/Readers/LaTeX.hs
2015-02-21Docx reader: Minor cleanup.Jesse Rosenthal1-3/+4
The previous commits had some code repetition. This just makes it a bit easier to read.
2015-02-21Docx reader: allow sub/superscript verbatims.Jesse Rosenthal1-1/+6
Verbatim usually shuts off all other run styles, but we don't want it to shut off sub/superscript.
2015-02-18Change return type of Docx readerMatthew Pickering1-8/+11
2015-02-13Docx reader: Handle lists correctly inside table cells.Jesse Rosenthal1-1/+3
Previously we didn't transform lists inside table cells.
2014-10-25Docx reader: fix for Issue #1692 (i18n styles)Nikolay Yakimov1-27/+6
This patch builds paragraph styles tree, then checks if paragraph has style.styleId or style/name.val matching predetermined patterns. Works with "Heading#" (name.val="heading #") for headings and "Quote"|"BlockQuote"|"BlockQuotation" (name.val="Quote"|"Block Text") for block quotes.
2014-09-06Docx Reader: Remove header class properly in other langsJesse Rosenthal1-4/+4
When we encounter one of the polyglot header styles, we want to remove that from the par styles after we convert to a header. To do that, we have to keep track of the style name, and remove it appropriately.
2014-09-05Docx reader: Use polyglot header list.Jesse Rosenthal1-7/+7
We're just keeping a list of header formats that different languages use as their default styles. At the moment, we have English, German, Danish, and French. We can continue to add to this. This is simpler than parsing the styles file, and perhaps less error-prone, since there seems to be some variations, even within a language, of how a style file will define headers.
2014-09-05Docx Reader: Start list of polyglot section headers.Jesse Rosenthal1-0/+7
2014-09-04Docx reader: Rewrite rewriteLink to work with new headers.Jesse Rosenthal1-9/+4
There could be new top-level headers after making lists, so we have to rewrite links after that.
2014-08-28Docx Reader: Read single para in table cell as plainJesse Rosenthal1-1/+12
This makes to docx reader's native output fit with the way the markdown reader understands its markdown output. Ie, as far as table cells go: docx -> native == docx -> native -> markdown -> native (This identity isn't true for other things outside of table cells, of course).
2014-08-17Docx reader: whitespace fix.Jesse Rosenthal1-6/+6
2014-08-17Docx reader: remove emph styles and strong styles list.Jesse Rosenthal1-6/+0
We no longer need the explicit lists since we're deriving them from the ground up.
2014-08-17Docx reader: Add "Hyperlink" to blacklisted styles.Jesse Rosenthal1-2/+2
This is the only one so far. We'll add others as they show up.
2014-08-17Docx reader: Use style resolver.Jesse Rosenthal1-23/+9
We now no longer check against explicit styles.
2014-08-17Docx Reader: Introduce function for resolving dependent run styles.Jesse Rosenthal1-0/+31
We always favor an explicit positive or negative in a style in a descendent, and only turn to the ancestor if nothing is set. We also introduce an (empty) list of styles that are black-listed. We won't check them. (Think underlines in hyperlinks).
2014-08-17Docx reader: work with new rStyle.Jesse Rosenthal1-4/+4
Just discards info at the moment, so at least it works the same.
2014-08-17Docx reader: Change behavior of Super/SubscriptJesse Rosenthal1-4/+4
In docx, super- and subscript are attributes of Vertalign. It makes more sense to follow this, and have different possible values of Vertalign in runStyle. This is mainly a preparatory step for real style parsing, since it can distinguish between vertical align being explicitly turned off and it not being set. In addition, it makes parsing a bit clearer, and makes sure we don't do docx-impossible things like being simultaneously super and sub.
2014-08-16Docx reader: Remove unnecessary plural functionsJesse Rosenthal1-11/+5
functions like runElemsToInlines and parPartsToInlines are just defined in terms of concatting and mapping their singular version (e.g. `runElemToInlines`). Having two functions with almost identical names makes it easier to introduce errors. It's easy enough to just concat and map inline, and it makes it clearer what is going on in the code.
2014-08-16Docx reader: Fix bug in character styles.Jesse Rosenthal1-2/+2
Style handling has been cleaned up, but introduced a bug here. There wasn't previously a test to catch it.
2014-08-16Rewrite Docx.hs and Reducible to use Builder.Jesse Rosenthal1-226/+193
The big news here is a rewrite of Docx to use the builder functions. As opposed to previous attempts, we now see a significant speedup -- times are cut in half (or more) in a few informal tests. Reducible has also been rewritten. It can doubtless be simplified and clarified further. We can consider this, at the moment, a reference for correct behavior.