aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/SelfContained.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-10-21SelfContained: fix bug that caused everything to be made a data uri.John MacFarlane1-12/+12
All the code we needed to put most styles and scripts into inline style and script tags was there, but because of the order of pattern matching, it was never being called. Putting the catch-all clause at the end fixes the bug. Closes #7635, closes #7367. See also #3423.
2021-04-05SelfContained: remove unneeded imports.John MacFarlane1-2/+0
2021-04-05SelfContained: use application/octet-stream for unknown mime types...John MacFarlane1-5/+4
instead of halting with an error. Closes #7202.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-11-19--self-contained: increase coverage.John MacFarlane1-4/+11
Previously we only self-contained attributes for certain tag names (`img`, `embed`, `video`, `input`, `audio`, `source`, `track`, `section`). Now we self-contain any occurrence of `src`, `data-src`, `poster`, or `data-background-image`, on any tag; and also `href` on `link` tags. Closes #6854 (which specifically asked about `asciinema-player` tags).
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-1/+1
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-60/+61
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-03SelfContained: omit content-type on type attribute for `<style>`.John MacFarlane1-5/+8
It doesn't seem to be valid for HTML5, and as a result Chrome ignores the style element. Closes #5725.
2019-03-01Remove license boilerplate.John MacFarlane1-18/+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-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-12-18Decompress .svgz when converting to "data:" URIAlexander Krotov1-1/+1
Address #5163
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-16Monoid/Semiground cleanup relying on custom Prelude.John MacFarlane1-1/+0
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2017-11-01SelfContained: use base64 for css links with media attribute.John MacFarlane1-0/+1
This fixes `--self-contained` with s5. Closes #4026.
2017-10-27hlint suggestions.John MacFarlane1-8/+5
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-3/+3
2017-10-20SelfContained: data-background-image instead of data-background.John MacFarlane1-1/+1
Really closes #3979.
2017-10-16SelfContained: handle data-background attribute on section.John MacFarlane1-2/+3
This should help with #3979. In my test, I got a data uri for data-background. But it didn't actually work in the browser (the background image didn't show). Not sure whether this is a problem in reveal.js or a problem in pandoc...
2017-09-30Removed unneeded import.John MacFarlane1-1/+0
2017-09-30Removed writerSourceURL, add source URL to common state.John MacFarlane1-56/+54
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-05-23Shared: Provide custom isURI that rejects unknown schemes [isURI]Albert Krewinkel1-2/+2
We also export the set of known `schemes`. The new function replaces the function of the same name from `Network.URI`, as the latter did not check whether a scheme is well-known. E.g. MediaWiki wikis frequently feature pages with names like `User:John`. These links were interpreted as URIs, thus turning internal links into global links. This is prevented by also checking whether the scheme of a URI is frequently used (i.e. is IANA registered or an otherwise well-known scheme). Fixes: #2713 Update set of well-known URIs from IANA list All official IANA schemes (as of 2017-05-22) are included in the set of known schemes. The four non-official schemes doi, isbn, javascript, and pmid are kept.
2017-05-20SelfContained: handle @import with quoted string.John MacFarlane1-11/+25
2017-05-20SelfContained: fixed problem with embedded fonts.John MacFarlane1-13/+41
Closes #3629. However, there is still room for improvement. `@import` with following media declaration is not handled. Also `@import` with a simple filename (rather than `url(...)` is not handled.
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-05-05Revert "SelfContained: special handling for css @import."John MacFarlane1-36/+5
This reverts commit 89b3fcc8e050def3779fed716d70bfd4e7120a6b.
2017-05-05SelfContained: special handling for css @import.John MacFarlane1-5/+36
We now avoid creating a data URI for the url under an @import.
2017-05-05SelfContained: Handle url() inside material retrieved from url().John MacFarlane1-3/+12
This can happen e.g. with an @import of a google web font. (What is imported is some CSS which contains an url reference to the font itself.) Also, allow unescaped pipe (|) in URL. This is intended to help with #3629, but it doesn't seem to work.
2017-03-30SelfContained: export makeDataURIJohn MacFarlane1-1/+1
2017-03-04Stylish-haskell automatic formatting changes.John MacFarlane1-16/+16
2017-02-26`--self-contained`: don't incorporate elements with `data-external="1"`.John MacFarlane1-0/+2
You can leave an external link as it is by adding the attribute data-external="1" to the element. Pandoc will then not try to incorporate its content when `--self-contained` is used. This is similar to a feature already supported by the EPUB writer. Closes #2656.
2017-02-24Some fixes to the preceding revisions in SelfContained.John MacFarlane1-27/+42
Make sure we don't duplicate end tags for script or link.
2017-02-24SelfContained: don't use data URIs for script or style.John MacFarlane1-10/+36
Instead, just use script or style tags with the content inside. The old method with data URIs prevents certain optimizations outside pandoc. Exception: data URIs are still used when a script contains `</script>` or a style contains `</`. Closes #3423. Also, in MIME, use application/javascript (not application/x-javascript).
2017-02-24Refactored getData from getDataURI in SelfContained.John MacFarlane1-5/+15
2017-02-23Put makeSelfContained in PandocMonad instead of IO.John MacFarlane1-46/+43
This removes the need to pass MediaBag around and improves exceptions. It also opens up the possibility of using makeSelfContained purely.
2017-02-20Use lazy loading for reveal.js slide shows.John MacFarlane1-1/+1
* In HTML writer, with reveal.js we use data-src instead of src for images. * In SelfContained, we also load resources from data-src. Closes #2283.
2017-01-25Removed writerMediaBag from WriterOpts.John MacFarlane1-3/+3
...since this is now handled through PandocMonad. Added an explicit MediaBag parameter to makePDF and makeSelfContained.
2017-01-25Text.Pandoc.Shared: Removed fetchItem, fetchItem'.John MacFarlane1-2/+4
Made changes where these are used, so that the version of fetchItem from PandocMonad can be used instead.
2017-01-25SelfContained: put makeSelfContained in MonadIO.John MacFarlane1-2/+3
2016-03-22Updated copyright dates to include 2016.John MacFarlane1-2/+2
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-28Fixed omitted `url(...)` in CSS data-uri with `--self-contained`.John MacFarlane1-1/+1
Fixes #2489.
2015-10-14Use custom Prelude to avoid compiler warnings.John MacFarlane1-1/+1
- 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-07-15`--self-contained`: Fixed overaggressive CSS minimization.John MacFarlane1-1/+2
Previously `--self-contained` wiped out all spaces in CSS, including semantically significant spaces! Closes #2301. Closes #2286.
2015-06-28Fixed regression in CSS parsing with `--self-contained`.John MacFarlane1-39/+47
In 1b44acf0c59b70cc63f48a23c6f77e45a982aaf9 we replaced some hackish CSS parsing with css-text, which I thought was a complete CSS parser. It turns out that it is very buggy, which results in lots of things being silently dropped from CSS when `--self-contained` is used (#2224). This commit replaces the use of css-text with a small but more principled css preprocessor, which only removes whitespace and replaces URLs with base 64 data when possible. Closes #2224.
2015-05-04SelfContained: properly handle data URIs in css urls.John MacFarlane1-32/+48
Also use a proper css parser (adds dependency on text-css). Closes #2129.