aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/FB2.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-08-03Stop using the HTTP package. (#7456)mt_caret1-2/+2
We only depend on the urlEncode function in the package, which is also provided by http-types. The HTTP package also depends on the network package, which has difficulty building on ghcjs. Add internal module Text.Pandoc.Network.HTTP, exporting `urlEncode`.
2021-02-16Rename Text.Pandoc.XMLParser -> Text.Pandoc.XML.Light...John MacFarlane1-74/+53
..and add new definitions isomorphic to xml-light's, but with Text instead of String. This allows us to keep most of the code in existing readers that use xml-light, but avoid lots of unnecessary allocation. We also add versions of the functions from xml-light's Text.XML.Light.Output and Text.XML.Light.Proc that operate on our modified XML types, and functions that convert xml-light types to our types (since some of our dependencies, like texmath, use xml-light). Update golden tests for docx and pptx. OOXML test: Use `showContent` instead of `ppContent` in `displayDiff`. Docx: Do a manual traversal to unwrap sdt and smartTag. This is faster, and needed to pass the tests. Benchmarks: A = prior to 8ca191604dcd13af27c11d2da225da646ebce6fc (Feb 8) B = as of 8ca191604dcd13af27c11d2da225da646ebce6fc (Feb 8) C = this commit | Reader | A | B | C | | ------- | ----- | ------ | ----- | | docbook | 18 ms | 12 ms | 10 ms | | opml | 65 ms | 62 ms | 35 ms | | jats | 15 ms | 11 ms | 9 ms | | docx | 72 ms | 69 ms | 44 ms | | odt | 78 ms | 41 ms | 28 ms | | epub | 64 ms | 61 ms | 56 ms | | fb2 | 14 ms | 5 ms | 4 ms |
2021-02-10Add new unexported module T.P.XMLParser.John MacFarlane1-3/+8
This exports functions that uses xml-conduit's parser to produce an xml-light Element or [Content]. This allows existing pandoc code to use a better parser without much modification. The new parser is used in all places where xml-light's parser was previously used. Benchmarks show a significant performance improvement in parsing XML-based formats (especially ODT and FB2). Note that the xml-light types use String, so the conversion from xml-conduit types involves a lot of extra allocation. It would be desirable to avoid that in the future by gradually switching to using xml-conduit directly. This can be done module by module. The new parser also reports errors, which we report when possible. A new constructor PandocXMLError has been added to PandocError in T.P.Error [API change]. Closes #7091, which was the main stimulus. These changes revealed the need for some changes in the tests. The docbook-reader.docbook test lacked definitions for the entities it used; these have been added. And the docx golden tests have been updated, because the new parser does not preserve the order of attributes. Add entity defs to docbook-reader.docbook. Update golden tests for docx.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-11-07Lint code in PRs and when committing to master (#6790)Albert Krewinkel1-1/+1
* Remove unused LANGUAGE pragmata * Apply HLint suggestions * Configure HLint to ignore some warnings * Lint code when committing to master
2020-05-21FB2 writer: properly handle cover-image containing spaces.John MacFarlane1-2/+2
Closes #6391.
2020-04-28Support new Underline element in readers and writers (#6277)Vaibhav Sagar1-0/+2
Deprecate `underlineSpan` in Shared in favor of `Text.Pandoc.Builder.underline`.
2020-04-15Use the new builders, modify readers to preserve empty headersdespresc1-2/+2
The Builder.simpleTable now only adds a row to the TableHead when the given header row is not null. This uncovered an inconsistency in the readers: some would unconditionally emit a header filled with empty cells, even if the header was not present. Now every reader has the conditional behaviour. Only the XWiki writer depended on the header row being always present; it now pads its head as necessary.
2020-04-15Adapt to the newest Table type, fix some previous adaptation issuesdespresc1-3/+3
- Writers.Native is now adapted to the new Table type. - Inline captions should now be conditionally wrapped in a Plain, not a Para block. - The toLegacyTable function now lives in Writers.Shared.
2020-04-15Implement the new Table typedespresc1-4/+5
2020-03-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel1-2/+2
This should speed-up recompilation after changes in `Text.Pandoc.Class`, as the number of modules affected by a change will be smaller in general. It also offers faster insights into the parts of `T.P.Class` used within a module.
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel1-2/+0
* Use implicit Prelude The previous behavior was introduced as a fix for #4464. It seems that this change alone did not fix the issue, and `stack ghci` and `cabal repl` only work with GHC 8.4.1 or newer, as no custom Prelude is loaded for these versions. Given this, it seems cleaner to revert to the implicit Prelude. * PandocMonad: remove outdated check for base version Only base versions 4.9 and later are supported, the check for `MIN_VERSION_base(4,8,0)` is therefore unnecessary. * Always use custom prelude Previously, the custom prelude was used only with older GHC versions, as a workaround for problems with ghci. The ghci problems are resolved by replacing package `base` with `base-noprelude`, allowing for consistent use of the custom prelude across all GHC versions.
2020-03-13Update copyright year (#6186)Albert Krewinkel1-1/+1
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-07Apply linter suggestions. Add fix_spacing to lint target in Makefile.John MacFarlane1-6/+2
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-74/+77
PR #5884. + Use pandoc-types 1.20 and texmath 0.12. + Text is now used instead of String, with a few exceptions. + In the MediaBag module, some of the types using Strings were switched to use FilePath instead (not Text). + In the Parsing module, new parsers `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`, `many1Till`, `manyUntil`, `mantyUntilChar` have been added: these are like their unsuffixed counterparts but pack some or all of their output. + `glob` in Text.Pandoc.Class still takes String since it seems to be intended as an interface to Glob, which uses strings. It seems to be used only once in the package, in the EPUB writer, so that is not hard to change.
2019-09-08Replace Element and makeHierarchical with makeSections.John MacFarlane1-17/+16
Text.Pandoc.Shared: + Remove `Element` type [API change] + Remove `makeHierarchicalize` [API change] + Add `makeSections` [API change] + Export `deLink` [API change] Now that we have Divs, we can use them to represent the structure of sections, and we don't need a special Element type. `makeSections` reorganizes a block list, adding Divs with class `section` around sections, and adding numbering if needed. This change also fixes some longstanding issues recognizing section structure when the document contains Divs. Closes #3057, see also #997. All writers have been changed to use `makeSections`. Note that in the process we have reverted the change c1d058aeb1c6a331a2cc22786ffaab17f7118ccd made in response to #5168, which I'm not completely sure was a good idea. Lua modules have also been adjusted accordingly. Existing lua filters that use `hierarchicalize` will need to be rewritten to use `make_sections`.
2019-05-15FB2 writer: do not wrap note references into <sup> and bracketsAlexander Krotov1-1/+1
Existing FB2 readers, such as FBReader, already display links with type="note" as a superscript.
2019-05-15hlint FB2 writerAlexander Krotov1-27/+22
2019-05-04FB2 writer: use genre metadata field (#5478)John1-1/+4
2019-03-01Remove license boilerplate.John MacFarlane1-20/+0
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-22Add section identifiers support for FB2 writer (#5315)John1-35/+28
Closes #5229.
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel1-2/+2
Quite a few modules were missing copyright notices. This commit adds copyright notices everywhere via haddock module headers. The old license boilerplate comment is redundant with this and has been removed. Update copyright years to 2019. Closes #4592.
2018-09-04hlint some writersAlexander Krotov1-1/+1
2018-08-24FB2 writer: put coverpage element between title and date...John MacFarlane1-2/+3
...rather than in document-info element. Closes #4854.
2018-06-12FB2 writer: convert Plain to Para in annotationAlexander Krotov1-1/+6
Address #2424
2018-06-12FB2 writer: fix order of items in title-infoAlexander Krotov1-1/+1
Address issue #2424
2018-04-26Merge branch 'fb2-hrblankline' of https://github.com/labdsf/pandoc into ↵John MacFarlane1-7/+4
labdsf-fb2-hrblankline
2018-04-19FB2 writer: convert metadata value "abstract" to book annotationAlexander Krotov1-1/+4
2018-04-07FB2 writer: output links inline instead of producing notesAlexander Krotov1-19/+2
Previously all links were turned into footnotes with unclickable URLs inside.
2018-04-05FB2 writer: represent HorizontalRule as empty lineAlexander Krotov1-7/+4
HorizontalRule corresponds to <hr> element in the default output format, HTML. Current HTML standard defines <hr> element as "paragraph-level thematic break". In typography it is often represented by extra space or centered asterism ("⁂"), but since FB2 does not support text centering, empty line (similar to extra space) is the only solution. Line breaks, on the other hand, don't generate <empty-line /> anymore. Previously line breaks generated <empty-line /> element inside paragraph, which is not allowed. So, this commit addresses issue #2424 ("FB2 produced by pandoc doesn't validate"). FB2 does not have a way to represent line breaks inside paragraphs. They are replaced with LF character, which is not rendered by FB2 readers, but at least preserves some information.
2018-04-04FB2 writer: allow emphasis and notes in titlesAlexander Krotov1-6/+4
Only <p> and <empty-line /> are allowed in titles, but <p> has the same type as an ordinary paragraphs. Therefore, there is no need to remove emphasis from titles. Also, don't intersperse paragraph with empty lines.
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-01-19hlint code improvements.John MacFarlane1-2/+1
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2017-12-28FB2 writer: add cover image specified by "cover-image" metaAlexander Krotov1-1/+10
Fixes #4195
2017-11-01hlintAlexander Krotov1-1/+1
2017-11-01FB2 writer: Add "unrecognised" genre to <title-info>Alexander Krotov1-1/+2
XML schema requires at least one genre.
2017-11-01FB2 writer: remove <annotation> from <body>Alexander Krotov1-11/+2
<annotation> is not allowed inside <body> according to FictionBook2 XML schema. Besides that, the same information is already placed inside <description>. Related bug: #2424
2017-11-01Merge pull request #4008 from labdsf/fb2-bulletsJohn MacFarlane1-8/+4
FB2 writer: make bullet lists consistent with ordered lists
2017-10-31FB2 writer: write blocks outside of <p> in definitionsAlexander Krotov1-18/+2
2017-10-31FB2 writer: make bullet lists consistent with ordered listsAlexander Krotov1-8/+4
Previously bullet lists interacted in odd way with ordered lists. For example, bullet lists nested in ordered list had incorrect indentation. Besides that, indentation with spaces is not rendered by FBReader and fbless. To avoid this problem, bullet lists are indented by appending bullets to marker just the same way it is done for ordered lists.
2017-10-29hlint suggestions.John MacFarlane1-4/+4
2017-10-29Write FB2 lists without nesting blocks inside <p> (#4004)Alexander1-16/+32
According to FB2 XML schema <empty-line /> cannot be placed inside <p>. Linux FBReader can't display such paragraphs, e.g. any "loose" lists produced by pandoc prior to this commit. Besides that, FB2 writer placed <p> inside <p> when writing nested lists, this commit fixes the bug. Also this commit removes leading non-breaking space from ordered lists for consistency with bullet lists. Definition lists are not affected at all.
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-5/+4
2017-10-11FB2 Writer: format LineBlock as poemAlexander Krotov1-2/+6
Previously writer produced one paragraph with <empty-line/> elements, which are not allowed inside <p> according to FB2 schema.
2017-10-09FB2 writer: replace concatMap with cMapAlexander Krotov1-10/+10
2017-10-09hlint FB2 writerAlexander Krotov1-50/+50
2017-09-30Removed writerSourceURL, add source URL to common state.John MacFarlane1-1/+1
Removed `writerSourceURL` from `WriterOptions` (API change). Added `stSourceURL` to `CommonState`. It is set automatically by `setInputFiles`. Text.Pandoc.Class now exports `setInputFiles`, `setOutputFile`. The type of `getInputFiles` has changed; it now returns `[FilePath]` instead of `Maybe [FilePath]`. Functions in Class that formerly took the source URL as a parameter now have one fewer parameter (`fetchItem`, `downloadOrRead`, `setMediaResource`, `fillMediaBag`). Removed `WriterOptions` parameter from `makeSelfContained` in `SelfContained`.
2017-06-20Removed redundant import.John MacFarlane1-1/+0
2017-06-20FB2 writer: don't fail with an error on interior headers (e.g. in list).John MacFarlane1-3/+5
Instead, omit them with an INFO message. Closes #3750.