mirror of
https://github.com/getzola/zola
synced 2024-09-20 14:21:56 +00:00
commit
24007b2559
11 changed files with 93 additions and 27 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## 0.15.1 (unreleased)
|
||||
|
||||
- Fix markdown shortcodes not being rendered correctly
|
||||
- Fix config data not getting to the templates
|
||||
|
||||
## 0.15.0 (2021-12-05)
|
||||
|
||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3575,7 +3575,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zola"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zola"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
authors = ["Vincent Prouillet <hello@vincentprouillet.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
|
|
@ -14,7 +14,7 @@ stages:
|
|||
imageName: 'vs2017-win2016'
|
||||
rustup_toolchain: stable
|
||||
mac-stable:
|
||||
imageName: 'macos-10.15'
|
||||
imageName: 'macos-11'
|
||||
rustup_toolchain: stable
|
||||
linux-stable:
|
||||
imageName: 'ubuntu-20.04'
|
||||
|
|
|
@ -332,7 +332,7 @@ pub fn merge(into: &mut Toml, from: &Toml) -> Result<()> {
|
|||
|
||||
impl Default for Config {
|
||||
fn default() -> Config {
|
||||
let mut conf = Config {
|
||||
Config {
|
||||
base_url: DEFAULT_BASE_URL.to_string(),
|
||||
title: None,
|
||||
description: None,
|
||||
|
@ -357,9 +357,7 @@ impl Default for Config {
|
|||
search: search::Search::default(),
|
||||
markdown: markup::Markdown::default(),
|
||||
extra: HashMap::new(),
|
||||
};
|
||||
conf.add_default_language();
|
||||
conf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -707,4 +705,17 @@ highlight_themes_css = [
|
|||
let config = Config::parse(config);
|
||||
assert_eq!(config.is_err(), true);
|
||||
}
|
||||
|
||||
// https://github.com/getzola/zola/issues/1687
|
||||
#[test]
|
||||
fn regression_config_default_lang_data() {
|
||||
let config = r#"
|
||||
base_url = "https://www.getzola.org/"
|
||||
title = "Zola"
|
||||
"#;
|
||||
|
||||
let config = Config::parse(config).unwrap();
|
||||
let serialised = config.serialize(&config.default_language);
|
||||
assert_eq!(serialised.title, &config.title);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn insert_md_shortcodes(
|
|||
for (md_sc_span, rendered_length) in &transforms {
|
||||
sc.update_range(md_sc_span, *rendered_length);
|
||||
}
|
||||
// It has been checked before that this exist
|
||||
|
||||
if sc.file_type() == ShortcodeFileType::Html {
|
||||
html_shortcodes.push(sc);
|
||||
continue;
|
||||
|
|
|
@ -50,18 +50,21 @@ impl Shortcode {
|
|||
}
|
||||
|
||||
pub fn update_range(&mut self, sc_span: &Range<usize>, rendered_length: usize) {
|
||||
if self.span.start > sc_span.start {
|
||||
let delta = if sc_span.end < rendered_length {
|
||||
rendered_length - sc_span.end
|
||||
} else {
|
||||
sc_span.end - rendered_length
|
||||
};
|
||||
if self.span.start < sc_span.start {
|
||||
return;
|
||||
}
|
||||
|
||||
if sc_span.end < rendered_length {
|
||||
self.span = (self.span.start + delta)..(self.span.end + delta);
|
||||
} else {
|
||||
self.span = (self.span.start - delta)..(self.span.end - delta);
|
||||
}
|
||||
let rendered_end = sc_span.start + rendered_length;
|
||||
let delta = if sc_span.end < rendered_end {
|
||||
rendered_end - sc_span.end
|
||||
} else {
|
||||
sc_span.end - rendered_end
|
||||
};
|
||||
|
||||
if sc_span.end < rendered_end {
|
||||
self.span = (self.span.start + delta)..(self.span.end + delta);
|
||||
} else {
|
||||
self.span = (self.span.start - delta)..(self.span.end - delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,12 +376,27 @@ mod tests {
|
|||
nth: 0,
|
||||
tera_name: String::new(),
|
||||
};
|
||||
// 6 -> 10 in length so +4 on both sides of the range
|
||||
sc.update_range(&(2..8), 10);
|
||||
assert_eq!(sc.span, 12..22);
|
||||
sc.update_range(&(24..30), 30);
|
||||
assert_eq!(sc.span, 12..22);
|
||||
sc.update_range(&(5..11), 6);
|
||||
assert_eq!(sc.span, 7..17);
|
||||
assert_eq!(sc.span, 14..24);
|
||||
// After the shortcode so no impact
|
||||
sc.update_range(&(25..30), 30);
|
||||
assert_eq!(sc.span, 14..24);
|
||||
// +4 again
|
||||
sc.update_range(&(5..11), 10);
|
||||
assert_eq!(sc.span, 18..28);
|
||||
|
||||
// buggy case from https://zola.discourse.group/t/zola-0-15-md-shortcode-stopped-working/1099/3
|
||||
let mut sc = Shortcode {
|
||||
name: "a".to_string(),
|
||||
args: Value::Null,
|
||||
span: 42..65,
|
||||
body: None,
|
||||
nth: 0,
|
||||
tera_name: String::new(),
|
||||
};
|
||||
sc.update_range(&(9..32), 3);
|
||||
assert_eq!(sc.span, 22..45);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1625,3 +1625,34 @@ fn can_use_smart_punctuation() {
|
|||
let res = render_content(r#"This -- is "it"..."#, &context).unwrap();
|
||||
assert_eq!(res.body, "<p>This – is “it”…</p>\n");
|
||||
}
|
||||
|
||||
// https://zola.discourse.group/t/zola-0-15-md-shortcode-stopped-working/1099/2
|
||||
#[test]
|
||||
fn md_shortcode_regression() {
|
||||
let permalinks_ctx = HashMap::new();
|
||||
let mut tera = Tera::default();
|
||||
tera.extend(&ZOLA_TERA).unwrap();
|
||||
tera.add_raw_template("shortcodes/code.md", "123").unwrap();
|
||||
let config = Config::default_for_test();
|
||||
let mut context = RenderContext::new(
|
||||
&tera,
|
||||
&config,
|
||||
&config.default_language,
|
||||
"",
|
||||
&permalinks_ctx,
|
||||
InsertAnchor::None,
|
||||
);
|
||||
let shortcode_def = utils::templates::get_shortcodes(&tera);
|
||||
context.set_shortcode_definitions(&shortcode_def);
|
||||
|
||||
let markdown_string = r#"
|
||||
ttest1
|
||||
|
||||
{{ code(path = "content/software/supercollider/pakt-februari/pakt29.scd", syntax = "supercollider") }}
|
||||
|
||||
ttest2
|
||||
|
||||
{{ code(path = "content/software/supercollider/pakt-februari/pakt29.scd", syntax = "supercollider") }}"#;
|
||||
let res = render_content(markdown_string, &context).unwrap();
|
||||
assert_eq!(res.body, "<p>ttest1</p>\n<p>123</p>\n<p>ttest2</p>\n<p>123</p>\n");
|
||||
}
|
||||
|
|
|
@ -111,6 +111,8 @@ fn can_build_site_without_live_reload() {
|
|||
assert!(file_exists!(public, "sitemap.xml"));
|
||||
assert!(file_exists!(public, "robots.txt"));
|
||||
assert!(file_exists!(public, "a-fixed-url/index.html"));
|
||||
// the config.title is there
|
||||
assert!(file_contains!(public, "index.html", "My Integration Testing site"));
|
||||
|
||||
assert!(file_exists!(public, "posts/python/index.html"));
|
||||
// Shortcodes work
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: zola
|
||||
version: 0.15.0
|
||||
version: 0.15.1
|
||||
summary: A fast static site generator in a single binary with everything built-in.
|
||||
description: |
|
||||
A fast static site generator in a single binary with everything built-in.
|
||||
|
@ -21,7 +21,7 @@ parts:
|
|||
zola:
|
||||
source-type: git
|
||||
source: https://github.com/getzola/zola.git
|
||||
source-tag: v0.15.0
|
||||
source-tag: v0.15.1
|
||||
plugin: rust
|
||||
rust-channel: stable
|
||||
build-packages:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
title = "My site"
|
||||
title = "My Integration Testing site"
|
||||
base_url = "https://replace-this-with-your-url.com"
|
||||
compile_sass = true
|
||||
generate_feed = true
|
||||
|
|
Loading…
Reference in a new issue