The pulldown_cmark escaping functionality is now shipped in a separate
pulldown_cmark_escape crate
(https://crates.io/crates/pulldown-cmark-escape), starting with v0.10.0.
The markdown.rs module has to be adapted to a few API changes in
pulldown_cmark, and we have to introduce explicit handling of <img> alt
text to ensure it continues to be properly escaped.
There are also a few other behavior changes that are caught by the
tests, but these actually seem to be desired, so I've updated the insta
snapshot files for those tests to incorporate those changes.
Specifically, one footnote-parsing case seems to be handled better now,
and pulldown-cmark's `push_html` now doesn't escape quotes in text nodes
anymore (see https://github.com/pulldown-cmark/pulldown-cmark/pull/836).
* adding optional `lang` arugment to `get_section` global function
* Add handling of default language passed in `lang` argument of `get_section`
* Remove clones for path. Change "?" to an explicit check for error
* lint changes
* Clean up error handling for add_lang_to_path call
* fix format
* Add optional parameter "lang" to get_page template function. Add check for language available in config.
* Modify helper function name from calculate_path to get_path_with_lang. Modify documentation for get_section and get_page to include equivalent calls without using lang argument to demostrate how lang argument effects pathing.
* Remove ensure_directory_exists since it's identical to create_directory, and misleading
* Don't create directories unless needed; rely on create_dir_all instead of manually iterating over components
* Fixed "unnecessary mut" warning
* Fixed minor typo
* Use more than 8 threads for links checking if hardware supports it
* Fixed failing azure Linux check
* Avoid unnecessary HTTP requests to the same, already checked links
The warning about unknown highlight languages was displayed even when
code highlighting was disabled via `markdown.highlight_code = false`.
This commit adds a condition to check this setting before issuing the
warning, effectively suppressing it when code highlighting is disabled.
Issue: #2280
The `rel` and `type` HTML attributes are needed in the `base_url` (or
`section.permalink`) link so feed aggregators know that's the HTML page
that corresponds to the atom feed.
Note: The RSS template doesn't have this issue.
* templates:atom: add support for multiple authors
Atom 1.0 [0] support multiple `<author>` entries in the feed. This commit
modified the template to generate as many `<author>` as the page's
metadata contains.
[0] https://validator.w3.org/feed/docs/atom.html#recommendedEntryElements
* Test we can have multiple authors in ATOM feeds
* sort page.assets by filename
Uses .to_str() to sort files and subfolders.
The .unwrap() may need work or be replaced by unwrap_or_default(). Given
earlier checks in the function it should work however.
* add tests for assets sorting
* fix rustfmt
* use existing loop instead of windows
* also check the non-recursive test
* use .zip() and add assert msg
* Add optional decoding="async" loading="lazy" for img
In theory, they can make the page load faster and show content faster.
There’s one problem: CommonMark allows arbitrary inline elements in alt text.
If I want to get the correct alt text, I need to match every inline event.
I think most people will only use plain text, so I only match Event::Text.
* Add very basic test for img
This is the reason why we should use plain text when lazy_async_image is enabled.
* Explain lazy_async_image in documentation
* Add test with empty alt and special characters
I totaly forgot one can leave the alt text empty.
I thought I need to eliminate the alt attribute in that case,
but actually empty alt text is better than not having an alt attribute at all:
https://www.w3.org/TR/WCAG20-TECHS/H67.htmlhttps://www.boia.org/blog/images-that-dont-need-alternative-text-still-need-alt-attributes
Thus I will leave the empty alt text.
Another test is added to ensure alt text is properly escaped.
I will remove the redundant escaping code after this commit.
* Remove manually escaping alt text
After removing the if-else inside the arm of Event::Text(text),
the alt text is still escaped.
Indeed they are redundant.
* Use insta for snapshot testing
`cargo insta review` looks cool!
I wanted to dedup the cases variable,
but my Rust skill is not good enough to declare a global vector.
* Fix hard link panic and add better error info to std:fs errors
* cargo fmt
* Remove erroneously committed config change
* Remove console import; Use with context to provide additional error info
* improve error wording
Relative links in the entry content do not currently have a base URI, so
will be resolved relative to the feed URI:
Given an entry with the content:
<a href="some-resource.bin">
And URIS of:
* entry: https://example.org/blog/some-entry/
* feed: https://example.org/atom.xml
The link URI will end up as:
https://example.org/some-resource.bin
rather than the URI that ends up resolved in the rendered page:
https://example.org/blog/some-entry/some-resource.bin
The atom and RSS formats allow for an xml:base attribute (itself
specified in [1]) to provide a base URI of a subset of a document. This
change adds xml:base attributes to each entry, using the page permalink.
This gives us something equivalent to:
<entry>
<content xml:base="https://example.org/blog/some-entry/">
<![CDATA[
<a href="some-resource.bin">
]]>
</content>
</entry>
[1]: https://www.w3.org/TR/xmlbase/
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
The W3C feed validator fails to validate RSS 2.0 and Atom 1.0 feed
elements that do not contain a valid author. This change adds an
`authors: Vec<String>` to pages, as well as an `author: Option<String>`
to Config that will act as a default to use in RSS and Atom templates if
no page-level authors are specified.