aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx.hs
AgeCommit message (Collapse)AuthorFilesLines
2018-12-10Docx writer: Make Level into a real type.Jesse Rosenthal1-1/+1
It had previously been an alias for a tuple.
2018-11-11Text.Pandoc.Shared: add parameter to uniqueIdent, inlineListToIdentifier.John MacFarlane1-3/+7
The parameter is Extensions. This allows these functions to be sensitive to the settings of `Ext_gfm_auto_identifiers` and `Ext_ascii_identifiers`. This allows us to use `uniqueIdent` in the CommonMark reader, replacing some custom code. It also means that `gfm_auto_identifiers` can now be used in all formats. Semantically, `gfm_auto_identifiers` is now a modifier of `auto_identifiers`; for identifiers to be set, `auto_identifiers` must be turned on, and then the type of identifier produced depends on `gfm_auto_identifiers` and `ascii_identifiers` are set. Closes #5057.
2018-04-05Changes to tests to accommodate changes in pandoc-types.John MacFarlane1-1/+5
In https://github.com/jgm/pandoc-types/pull/36 we changed the table builder to pad cells. This commit changes tests (and two readers) to accord with this behavior.
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane1-0/+2
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-03-17hlint fixes.John MacFarlane1-1/+1
2018-03-13Docx reader: Parse nested smart tags.Jesse Rosenthal1-2/+0
Make unwrapSDT into a general `unwrap` function that can unwrap both nested SDT tags and smartTags. This makes the SmartTags constructor in the Docx type unnecessary, so we remove it. Closes #4446
2018-03-12Docx reader: remove unused docxWarningsAlexander Krotov1-2/+0
2018-02-23Docx reader: code cleanup.Jesse Rosenthal1-10/+9
Make the code in `runStyleToTransform` a bit more consistent.
2018-02-23Docx reader: simplify custom-style reading code.Jesse Rosenthal1-41/+23
2018-02-23Docx reader: Don't look up dependant run styles if +styles is enabled.Jesse Rosenthal1-36/+39
It makes more sense not to interpret -- otherwise using the original document as the reference-doc would produce two of everything: the interpreted version and the uninterpreted style version.
2018-02-22Docx reader: Move pandoc inline styling inside custom-style spanJesse Rosenthal1-7/+7
Previously Emph, Strong, etc were outside the custom-style span. This moves them inside in order to make it easier to write filters that act on the formatting in these contents. Tests and MANUAL example are changed to match.
2018-02-22Docx reader: Avoid repeated spans in custom styles.Jesse Rosenthal1-10/+20
The previous commit had a bug where custom-style spans would be read with every recurrsion. This fixes that, and changes the example given in the manual.
2018-02-22Docx reader: read custom stylesJesse Rosenthal1-60/+96
This will read all paragraph and character classes as divs and spans, respectively. Dependent styles will still be resolved, but will be wrapped with appropriate style tags. It is controlled by the `+styles` extension (`-f docx+styles`). This can be used in conjunction with the `custom-style` feature in the docx writer for a pandoc-docx editing workflow. Users can convert from an input docx, reading the custom-styles, and then use that same input docx file as a reference-doc for producing an output docx file. Styles will be maintained across the conversion, even if pandoc doesn't understand them. Without the extension: $ pandoc test/docx/custom-style-reference.docx -f docx -t markdown This is some text. This is text with an *emphasized* text style. And this is text with a **strengthened** text style. > Here is a styled paragraph that inherits from Block Text. With the extension: $ pandoc test/docx/custom-style-reference.docx -f docx+styles -t markdown ::: {custom-style="FirstParagraph"} This is some text. ::: ::: {custom-style="BodyText"} This is text with an *[[emphasized]{custom-style="Emphatic"}]{custom-style="Emphatic"}* text style. And this is text with a **[[strengthened]{custom-style="Strengthened"}]{custom-style="Strengthened"}** text style. ::: ::: {custom-style="MyBlockStyle"} Closes: #1843
2018-02-15Docx reader: Pick table width from the longest row or headerdanse1-5/+9
This change is intended to preserve as much of the table content as possible Closes #4360
2018-01-19hlint code improvements.John MacFarlane1-9/+7
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.