parent
b2adfae4bc
commit
fecc3cf148
|
@ -1,6 +1,6 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## unreleased
|
## 0.14.0 (unreleased)
|
||||||
|
|
||||||
### Breaking
|
### Breaking
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@
|
||||||
- Add `path` to the taxonomy terms to be on par with pages and sections
|
- Add `path` to the taxonomy terms to be on par with pages and sections
|
||||||
- Add the `base16-aterlierdune-light` syntax highlight theme
|
- Add the `base16-aterlierdune-light` syntax highlight theme
|
||||||
- Improve link checking: less concurrency and try to not overload the servers
|
- Improve link checking: less concurrency and try to not overload the servers
|
||||||
- Allow using POST for `load_data`, along with a body to POST
|
- Allow using POST for `load_data`, along with a body to POST and allow it to fail
|
||||||
|
- Add Zig syntax highlighting
|
||||||
|
- Footnotes links are now stripped from summaries - they were not linking to anything.
|
||||||
|
|
||||||
## 0.13.0 (2021-01-09)
|
## 0.13.0 (2021-01-09)
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,14 @@ pub use page::PageFrontMatter;
|
||||||
pub use section::SectionFrontMatter;
|
pub use section::SectionFrontMatter;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref TOML_RE: Regex =
|
static ref TOML_RE: Regex = Regex::new(
|
||||||
Regex::new(r"^[[:space:]]*\+\+\+(\r?\n(?s).*?(?-s))\+\+\+[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))")
|
r"^[[:space:]]*\+\+\+(\r?\n(?s).*?(?-s))\+\+\+[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))"
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
static ref YAML_RE: Regex = Regex::new(
|
||||||
|
r"^[[:space:]]*---(\r?\n(?s).*?(?-s))---[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))"
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
static ref YAML_RE: Regex =
|
|
||||||
Regex::new(r"^[[:space:]]*---(\r?\n(?s).*?(?-s))---[[:space:]]*(?:$|(?:\r?\n((?s).*(?-s))$))").unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum RawFrontMatter<'a> {
|
pub enum RawFrontMatter<'a> {
|
||||||
|
|
|
@ -27,6 +27,8 @@ lazy_static! {
|
||||||
static ref RFC3339_DATE: Regex = Regex::new(
|
static ref RFC3339_DATE: Regex = Regex::new(
|
||||||
r"^(?P<datetime>(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9])))?)\s?(_|-)(?P<slug>.+$)"
|
r"^(?P<datetime>(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9])))?)\s?(_|-)(?P<slug>.+$)"
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
|
static ref FOOTNOTES_RE: Regex = Regex::new(r"<sup\s*.*?>\s*.*?</sup>").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
|
@ -263,7 +265,11 @@ impl Page {
|
||||||
Error::chain(format!("Failed to render content of {}", self.file.path.display()), e)
|
Error::chain(format!("Failed to render content of {}", self.file.path.display()), e)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.summary = res.summary_len.map(|l| res.body[0..l].to_owned());
|
self.summary = if let Some(s) = res.summary_len.map(|l| &res.body[0..l]) {
|
||||||
|
Some(FOOTNOTES_RE.replace(s, "").into_owned())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
self.content = res.body;
|
self.content = res.body;
|
||||||
self.toc = res.toc;
|
self.toc = res.toc;
|
||||||
self.external_links = res.external_links;
|
self.external_links = res.external_links;
|
||||||
|
@ -530,6 +536,33 @@ Hello world
|
||||||
assert_eq!(page.summary, Some("<p>Hello world</p>\n".to_string()));
|
assert_eq!(page.summary, Some("<p>Hello world</p>\n".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn strips_footnotes_in_summary() {
|
||||||
|
let config = Config::default();
|
||||||
|
let content = r#"
|
||||||
|
+++
|
||||||
|
+++
|
||||||
|
This page has footnotes, here's one. [^1]
|
||||||
|
|
||||||
|
<!-- more -->
|
||||||
|
|
||||||
|
And here's another. [^2]
|
||||||
|
|
||||||
|
[^1]: This is the first footnote.
|
||||||
|
|
||||||
|
[^2]: This is the second footnote."#
|
||||||
|
.to_string();
|
||||||
|
let res = Page::parse(Path::new("hello.md"), &content, &config, &PathBuf::new());
|
||||||
|
assert!(res.is_ok());
|
||||||
|
let mut page = res.unwrap();
|
||||||
|
page.render_markdown(&HashMap::default(), &Tera::default(), &config, InsertAnchor::None)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
page.summary,
|
||||||
|
Some("<p>This page has footnotes, here\'s one. </p>\n".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn page_with_assets_gets_right_info() {
|
fn page_with_assets_gets_right_info() {
|
||||||
let tmp_dir = tempdir().expect("create temp dir");
|
let tmp_dir = tempdir().expect("create temp dir");
|
||||||
|
|
Loading…
Reference in a new issue