parent
5d2c25b8c5
commit
59d3d8a3da
|
@ -13,6 +13,8 @@
|
|||
- Add a `[markdown]` section to `config.toml` to configure rendering
|
||||
- Add `highlight_code` and `highlight_theme` to a `[markdown]` section in `config.toml`
|
||||
- Add `external_links_target_blank`, `external_links_no_follow` and `external_links_no_referrer`
|
||||
- Add a `smart_punctuation` option in the `[markdown]` section in `config.toml` to turn elements like dots and dashes
|
||||
into their typographic forms
|
||||
|
||||
## 0.12.2 (2020-09-28)
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ pub struct Markdown {
|
|||
pub external_links_no_follow: bool,
|
||||
/// Whether to set rel="noreferrer" for all external links
|
||||
pub external_links_no_referrer: bool,
|
||||
/// Whether smart punctuation is enabled (changing quotes, dashes, dots etc in their typographic form)
|
||||
pub smart_punctuation: bool,
|
||||
}
|
||||
|
||||
impl Markdown {
|
||||
|
@ -63,6 +65,7 @@ impl Default for Markdown {
|
|||
external_links_target_blank: false,
|
||||
external_links_no_follow: false,
|
||||
external_links_no_referrer: false,
|
||||
smart_punctuation: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,6 +186,10 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
|
|||
opts.insert(Options::ENABLE_STRIKETHROUGH);
|
||||
opts.insert(Options::ENABLE_TASKLISTS);
|
||||
|
||||
if context.config.markdown.smart_punctuation {
|
||||
opts.insert(Options::ENABLE_SMART_PUNCTUATION);
|
||||
}
|
||||
|
||||
{
|
||||
let mut events = Parser::new_ext(content, opts)
|
||||
.map(|event| {
|
||||
|
|
|
@ -1116,3 +1116,13 @@ fn can_set_all_options_for_external_link() {
|
|||
let res = render_content("<https://google.com>", &context).unwrap();
|
||||
assert_eq!(res.body, "<p><a rel=\"noopener nofollow noreferrer\" target=\"_blank\" href=\"https://google.com\">https://google.com</a></p>\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_use_smart_punctuation() {
|
||||
let permalinks_ctx = HashMap::new();
|
||||
let mut config = Config::default();
|
||||
config.markdown.smart_punctuation = true;
|
||||
let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None);
|
||||
let res = render_content(r#"This -- is "it"..."#, &context).unwrap();
|
||||
assert_eq!(res.body, "<p>This – is “it”…</p>\n");
|
||||
}
|
|
@ -118,6 +118,10 @@ external_links_no_follow = false
|
|||
# Whether to set rel="noreferrer" for all external links
|
||||
external_links_no_referrer = false
|
||||
|
||||
# Whether smart punctuation is enabled (changing quotes, dashes, dots in their typographic form)
|
||||
# For example, `...` into `…`, `"quote"` into `“curly”` etc
|
||||
smart_punctuation = false
|
||||
|
||||
# Configuration of the link checker.
|
||||
[link_checker]
|
||||
# Skip link checking for external URLs that start with these prefixes
|
||||
|
|
Loading…
Reference in a new issue