summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/SelfContained.hs
AgeCommit message (Collapse)Author
2024-02-29SelfContained: add `role="img"` to svgs.John MacFarlane
This is needed in conjunction with `aria-label` for screen readers. Completes the fix to #9525.
2024-02-29SelfContained: Add aria-label to svg elements.John MacFarlane
Screen readers don't seem to pay attention to an alt attribute on svg. But they do read the aria-label. So if there's an alt attribute, we copy its contents to aria-label, unless there is already an aria-label. This will make pandoc's output with `--embed-resources` more accessible. Closes #9525.
2024-02-16More fixes for SVG ids with `--self-contained`.John MacFarlane
This generalizes the fix to #9420 so it applies to things like `style="fill(url(#..."`. Closes #9467.
2024-02-09Fix id replacements in SVGs with clipping paths.John MacFarlane
This fixes `--embed-resources` when SVGs have `clip-path` attributes. Closes #9420.
2024-02-09Fix size of duplicated SVGs with `--embed-resources`.John MacFarlane
Closes #9439.
2023-12-06Revert "Use base64 instead of base64-bytestring."John MacFarlane
This reverts commit 6625e9655ed2bb0c4bd4dd91b5959a103deab1cb. base64 is currently buggy on 32-bit systems. Closes #9233.
2023-11-25SelfContained: improve treatment of embedded SVGs.John MacFarlane
- Ensure unique ids for elements by prefixing SVG id. - Ensure SVG `id` attribute except when `use` element is used. - Remove `width`, `height` attributes from svg element when `use` element is used. Instead, add `width` and `height` 100% to the `use` element. This seems to get the sizing right. Closes #9206. Ref: #8948.
2023-07-27SelfContained: retain attributes in svg tag...John MacFarlane
when referring to another svg's content using `<use>`. Closes #8969.
2023-07-27SelfContained: Allow units in width and height for svg.John MacFarlane
Units are optional but allowed.
2023-07-26SelfContained: don't coerce calculated width/height to Int.John MacFarlane
Fractional values are okay. See #8969.
2023-07-26SelfContained: fix calculation of svg width and height.John MacFarlane
We were computing width and height from viewBox incorrectly. See #8969.
2023-07-25SelfContained: Improve inline SVGs.John MacFarlane
- Ensure that width and height attributes don't get specified twice is both the img tag and the svg include them. - Omit unnecessary attributes xmlns, xmlns:xlink, and version on svg element. - Use 20 character rather than 40 character hashes for generated IDs. Closes #8965.
2023-07-13Fix bugs in implementation of #8948.John MacFarlane
2023-07-11SelfContained: Tweak identifier generation for svgs...John MacFarlane
so the difference between line endings between Windows and Unix is ignored. This allows test output to be deterministic across OS versions.
2023-07-11SelfContained: Use inline svg instead of data uris...John MacFarlane
for SVG images in HTML5. Closes #8948. Note that SelfContained does not have access to the writer name, so we check for HTML5 by determining whether the document starts with `<DOCTYPE! html>`. This means that inline SVG won't be used when generating document fragments. An API change could be contemplated to give more flexibility, but this is okay for now.
2023-01-10Update copyright years, it's 2023!Albert Krewinkel
2022-10-18T.P.SelfContained: use T.P.Parsing rather than direct Text.Parsec.John MacFarlane
2022-10-16T.P.Parsing: Remove gratuitious renaming of Parsec types.John MacFarlane
We were exporting Parser, ParserT as synonyms of Parsec, ParsecT. There is no good reason for this and it can cause confusion. Also, when possible, we replace imports of Text.Parsec with T.P.Parsing. The idea is to make it easier, at some point, to switch to megaparsec or another parsing engine if we want to. T.P.Parsing new exports: Stream(..), updatePosString, SourceName, Parsec, ParsecT [API change]. Removed exports: Parser, ParserT [API change].
2022-10-03Rename T.P.Network.HTTP -> T.P.URI.John MacFarlane
This is still an unexported internal module. Export `urlEncode`, `escapeURI`, `isURI`, `schemes`, `uriPathToPath`. Re-export `escapeURI` and `isURI` from T.P.Shared (as they were exported before); drop exports of `schemes` and `uriPathToPath` [API change]. With this change, T.P.Class no longer depends on T.P.Shared.
2022-08-21Fix regression with data uris in 2.19.1.John MacFarlane
In 2.19.1 we used the base64URL encoding rather than base64. This works in Safari, apparently, but not in other browsers. Closes #8239.
2022-08-14Use base64 instead of base64-bytestring.John MacFarlane
It is supposed to be faster and more standards-compliant.
2022-07-23--self-contained: Handle `url()` in style elements.John MacFarlane
Previously we handled these in included CSS files but not in style elements. Closes #8193.
2022-02-10--self-contained: issue warning rather than failing...John MacFarlane
with an error, if a resource can't be found. Closes #7904.
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2021-10-21SelfContained: fix bug that caused everything to be made a data uri.John MacFarlane
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 MacFarlane
2021-04-05SelfContained: use application/octet-stream for unknown mime types...John MacFarlane
instead of halting with an error. Closes #7202.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel
2020-11-19--self-contained: increase coverage.John MacFarlane
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 Krewinkel
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 Krewinkel
* 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 Krewinkel
* 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 MacFarlane
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc
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 MacFarlane
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 MacFarlane
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 Krewinkel
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 Krotov
Address #5163
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane
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 MacFarlane
2018-01-05Update copyright notices to include 2018Albert Krewinkel
2017-11-01SelfContained: use base64 for css links with media attribute.John MacFarlane
This fixes `--self-contained` with s5. Closes #4026.
2017-10-27hlint suggestions.John MacFarlane
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane
2017-10-20SelfContained: data-background-image instead of data-background.John MacFarlane
Really closes #3979.
2017-10-16SelfContained: handle data-background attribute on section.John MacFarlane
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 MacFarlane
2017-09-30Removed writerSourceURL, add source URL to common state.John MacFarlane
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 Krewinkel
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 MacFarlane