Commit graph

27 commits

Author SHA1 Message Date
Eugene Lomov
6a2b890545 Implemented bottom footnotes with backreferences (#2480)
* Implemented bottom footnotes with backreferences

Fixes #1285

* Added bottom_footnotes option to configuration.md

* Renamed fix_github_style_footnotes()

* Added tests for convert_footnotes_to_github_style()

* Changed test to plain html instead of Vec<Event>

* Added integration test for footnotes

* Applied suggested changes
2024-06-20 23:15:24 +02:00
Timon Van Overveldt
13682e1342 Update pulldown_cmark dep to v0.10, and add pulldown_cmark_escape dep. (#2432)
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).
2024-06-20 23:15:24 +02:00
Clar Fon
a01e36bd86 Match <!--more--> in addition to <!-- more --> (#2397)
* Match <!-- more --> without spaces

* Add tests for new <!-- more --> handling, with a note on pulldown-cmark bug
2024-06-20 23:15:24 +02:00
Óscar
670b88263c fix: suppress highlight language warnings if highlight_code is false (#2287)
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
2023-12-18 23:24:06 +01:00
TheOnlyMrCat
2532198acb Prevent spans crossing line boundaries in class-based code block formatter (#2237)
* Prevent spans crossing line boundaries in class formatter

* Add snapshot tests for classed highlighting
2023-12-18 23:24:06 +01:00
sinofp
22dc32a589 Add support for lazy loading images (#2211)
* 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.html
https://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.
2023-12-18 23:24:06 +01:00
Vincent Prouillet
f6c0d52d16 Revert "Allow external links to start with "www.*" (#2100)"
This reverts commit 902fd3a9fb.
2023-03-19 20:36:25 +01:00
Katie Watson
902fd3a9fb Allow external links to start with "www.*" (#2100)
* Make www.* URLs considered valid external links

* Tweak description of is_external_link
2023-02-16 20:49:03 +01:00
Kartavya Vashishtha
3e1f5777f1 feat: External URL redirect (#2080) 2023-02-16 20:49:03 +01:00
Sosthène Guédon
76ca540142 markdown: Fix clippy warnings 2023-02-16 20:49:03 +01:00
Sosthène Guédon
0183ea548a Fix clippy::manual_retain 2023-02-16 20:49:03 +01:00
Sosthène Guédon
faf00d1047 Fix clippy::derive_partial_eq_without_eq 2023-02-16 20:49:03 +01:00
Vincent Prouillet
442d6222a6 Fix test 2023-02-16 20:49:03 +01:00
Vincent Prouillet
9e0f4002b3 Handle colocated links to assets
Solves #1993
2023-02-16 20:49:03 +01:00
Joel Montes de Oca
567f103ee3 Imporved is_colocated_asset_links (#1972)
This PR includes the following:

- Added a check for `../` which would check to see if a file is in a
  _sub_ directory
- Wrote test for `is_colocated_asset_links`

This PR is similare to PR #1969
2023-02-16 20:49:03 +01:00
Vincent Prouillet
0d4c2e813f Fix some bugs + cargo fmt 2022-07-12 00:09:38 +02:00
Vincent Prouillet
7208b86d77
Insert anchor as full heading (#1916)
* Add insert_anchor = "heading"

* Update CHANGELOG.md

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2022-07-10 15:02:07 +02:00
Arnaud Grandville
18e8246fbc
fix windows EOL in markdown files (#1911)
* add a test

* CodeBlock text may be split on multiple parts

The CodeBlock text events are now concatenated and processed in a single stream at the end. cf https://github.com/raphlinus/pulldown-cmark/issues/457
2022-06-23 19:36:33 +02:00
Vincent Prouillet
04ee5c85a3 Reenable link rewriting for colocated assets
All credits go to https://github.com/getzola/zola/pull/1779
2022-06-10 20:41:24 +02:00
Michael Clayton
6240ed5469
add link_checker settings for external_level and internal_level (#1848)
* add external_level and internal_level

* remove unnecessary debug derive on LinkDef

* clarify doc comment about link check levels

* simplify link checker logging

* add missing warn prefix

* simplify link level logging, remove "Level" from linklevel variants

* remove link level config from test site

* switch back to using bail! from get_link_domain

* move console's deps to libs

* remove unnecessary reference

* calling console::error/warn directly

* emit one error, or one warning, per link checker run

* various link checker level changes

* add docs about link checker levels

* remove accidentally committed test site

* remove completed TODO
2022-05-11 21:54:34 +02:00
Vincent Prouillet
beb93f2b0a Expose backlinks 2022-05-08 14:10:29 +02:00
Vincent Prouillet
413a68d8b2 Fix tests 2022-05-06 22:55:29 +02:00
Vincent Prouillet
ee8de20a6e Update syntect 2022-05-05 23:41:06 +02:00
Vincent Prouillet
84951d39e3 Allow taxonomies to not be rendered
Closes #1750
2022-04-27 21:11:42 +02:00
Vincent Prouillet
844576e32e Remove unused deps thanks to cargo-machete 2022-04-27 19:49:57 +02:00
Vincent Prouillet
27a200bb4e Some more refactoring 2022-04-26 23:13:27 +02:00
Vincent Prouillet
9ab1bf2e4e
Re-organise content and remove slotmap indirection level (#1827) 2022-04-26 20:51:04 +02:00