aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx.hs
AgeCommit message (Collapse)AuthorFilesLines
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.
2014-08-13Docx reader: Interpret "Strong" and Emphasis run styles.Jesse Rosenthal1-2/+6
2014-08-12Docx Reader: Trim line breaks from the beginning and end of SectionJesse Rosenthal1-2/+10
Headers. We might also want to do this elsewhere (for pars, for example).
2014-08-12Docx: More robust handling of multiple bookmarks in header.Jesse Rosenthal1-6/+8
2014-08-12Docx reader: Check for null-id'd anchors too.Jesse Rosenthal1-1/+0
Otherwise they get left dangling in the document.
2014-08-12Docx reader: accept explicit "Italic" and "Bold" rStyles.Jesse Rosenthal1-5/+18
Note that "Italic" can be on, and, from the last commit, `<w:i>` can be present, but be turned off. In that case, the turned-off tag takes precedence. So, we have to distinguish between something being off and something not being there. Hence, isItalic, isBold, isStrike, and isSmallCaps have become Maybes.
2014-08-12Docx reader: Add "BlockQuotation" to divs list.Jesse Rosenthal1-1/+1
2014-08-12Docx reader: move combining logic to ReducibleJesse Rosenthal1-3/+1
Introduces a new function in Reducibles, concatR. The idea is that if we have two list of Reducibles (blocks or inlines), we can combine them and just perform the reduction on the joining parts (the last element of the first list, the first element of the second list). This is useful in cases where the two lists are already reduced, and we're only worried about the joining elements. This actually improves the efficiency a bit further, because concatR can be smart about empty lists.
2014-08-12Docx reader: Make dropcap combining more efficient.Jesse Rosenthal1-1/+3
Before, we had to run reduceList on the whole combined paragraph, which was redundant, and could take some time for long paragraphs. We only need to combine the drop cap with the first inline of the next paragraph.
2014-08-11Docx reader: combine inlines properly in dropcaps.Jesse Rosenthal1-1/+1
Make sure that adjacent inlines are combined properly in dropcaps. This updates the test results as well.
2014-08-11Docx reader: Use dropcap state.Jesse Rosenthal1-9/+17
If we get to a dropcap, we keep hold the inlines until the next paragraph, and combine it there.
2014-08-08OMath parser: Change signature of exported function.Jesse Rosenthal1-5/+4
This changes the signature of the exported `readOMML` to `String -> Either String [Exp]`, so it can now, in theory, be slotted into TeXMath. It doesn't have any real error reporting yet, but that might make more sense once I put it in a branch, and understand how it works in the other readers. It also now reads strings that parse to either oMath or oMathPara elements. Note that the distinction is lost in the output. It's up to the caller to remember the display type.
2014-08-07Merge pull request #1494 from jkr/math-moduleJohn MacFarlane1-219/+27
Math module
2014-08-07Docx reader: Handle inline drawings.Jesse Rosenthal1-0/+7
Previous drawings that were under some other toplevel run (i.e., a hyperlink) wouldn't be properly handled. This should fix that.
2014-08-07Docx reader: Split math out into math module.Jesse Rosenthal1-194/+7
Could use some cleanup, but this is the first step for getting an OMML reader into TeXMath.
2014-08-06Docx Reader: Added Default instances and removed withDStateMatthew Pickering1-28/+23
Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>
2014-08-06Get rid of unused docx variable.Jesse Rosenthal1-5/+3
Since changing the Docx type, this is no longer necessary. Thanks to Matthew Pickering for picking up on this.
2014-08-06Docx reader: remove now-unnecessary state variable.Jesse Rosenthal1-4/+2
This also introduces a `defaultDState` value.
2014-08-06Docx reader: Use TeXMath to write mathJesse Rosenthal1-155/+190
The new version of TeXMath can translate from its type system into LaTeX. So instead of writing the LaTeX ourself, we write to the TeXMath `Exp` type, and let TeXMath do the rest.
2014-08-04Use `stripPrefix` where appropriate.Artyom Kazak1-7/+7
2014-07-31Docx Reader: Single underlines are "emph"Jesse Rosenthal1-1/+2
All other underlines are ignored.
2014-07-31New module, Text.Pandoc.MediaBag.John MacFarlane1-1/+3
Moved `MediaBag` definition and functions from Shared: `lookupMedia`, `mediaDirectory`, `insertMedia`, `extractMediaBag`. Removed `emptyMediaBag`; use `mempty` instead, since `MediaBag` is a Monoid.
2014-07-31Made MediaBag a newtype, and added mime type information to media.John MacFarlane1-2/+2
Shared now exports functions for interacting with a MediaBag: - `emptyMediaBag` - `lookuMedia` - `insertMedia` - `mediaDirectory` - `extractMediaBag`
2014-07-30Docx reader: Make docx reader put image data in MediaBag.Jesse Rosenthal1-32/+25
Image data will not be put in a media bag map, which will be output along with the pandoc output.
2014-07-29Docx reader: Make metavalues out of styled paragraphs.Jesse Rosenthal1-11/+73
This will make paragraphs styled with `Author`, `Title`, `Subtitle`, `Date`, and `Abstract` into pandoc metavalues, rather than text. The implementation only takes those elements from the beginning of the document (ignoring empty paragraphs). Multiple paragraphs in the `Author` style will be made into a metaList, one paragraph per item. Hard linebreaks (shift-return) in the paragraph will be maintained, and can be used for institution, email, etc.
2014-07-16Docx Reader: Fix hdr auto-id when already auto-id.Jesse Rosenthal1-11/+19
If header anchors (bookmarks in a header paragraph) already have an auto-id, which will happen if they're generated by pandoc, we don't want to rename it twice, and thus end up with an unnecessary number at the end. So we add a state value to check if we're in a header. If we are, we don't rename the bookmark -- wait until we rename it in our header handling.
2014-07-16Docx Reader: Change state handling.Jesse Rosenthal1-16/+12
We don't need `updateDState` -- the built-in `modify` works just fine. And we redefine `withDState` to use modify.
2014-07-12Removed space at ends of lines in source.John MacFarlane1-9/+9
2014-07-12Docx Reader: A nicer Docx type.Jesse Rosenthal1-66/+42
This modifies the Docx type in the parser to avoid all the extra files (Notes, numbering, etc). A reader monad keeps track of these, and applies them at the end. The reader monad is stacked with ErrorT to enable better error-handling than the old Maybes. (Note that the better error handling isn't really there yet, but it is now possible.) One long-term goal of these changes is to make it easier to write the Docx type. This should make it easier to develop a standalone docx package in the future.
2014-07-02Docx Reader: Write LaTeX based on equations in word.Jesse Rosenthal1-4/+172
This is a first stab at writing out equations in LaTeX based on omml equations in Word. There are some glitches: unicode chars not known to LaTeX are silently skipped, and functions (such as `\oiiint`) not in the standard LaTeX packages are inserted, which can lead to pdf compilation errors (depending, of course, on your preamble). Adding, for example, `\usepackage[charter]{mathdesign}` to the preamble will allow you to use most of the more esoteric functions.
2014-06-30Docx reader: clean up parStyle processing.Jesse Rosenthal1-45/+36
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-29Merge pull request #1386 from jkr/hanging_indentJohn MacFarlane1-10/+25
Fix hanging indent behavior
2014-06-29Docx reader: Make use of new ParIndentation info.Jesse Rosenthal1-10/+25
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-29Docx Reader: Update state properlyJesse Rosenthal1-3/+8
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-28Docx Reader: All headers get auto id.Jesse Rosenthal1-1/+10
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-28Docx Reader: Introduce link rewriting.Jesse Rosenthal1-7/+30
2014-06-28make makeHeaderAnchors make an auto idJesse Rosenthal1-3/+7
Record relationship between original id and auto id, so we can fix links after.
2014-06-28Rewrote header generation.Jesse Rosenthal1-25/+25
In preparation for auto ids.
2014-06-28Docx Reader: Simplify makeHeaderAnchorsJesse Rosenthal1-8/+5
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-28Docx Reader: Clean up guardsJesse Rosenthal1-9/+9
Use PatternGuards to get rid of need for `isJust`, `fromJust` altogether.