mirror of
https://github.com/lise-henry/crowbook
synced 2024-05-26 16:16:11 +02:00
Change the way Footnotes are handled internally
This commit is contained in:
parent
5925086da0
commit
316970175e
|
@ -232,7 +232,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "comrak"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+http://github.com/lise-henry/comrak#8dfdd5e0f9fa4b4251073c4fa3385fc9f0b4126b"
|
||||
dependencies = [
|
||||
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"entities 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -371,7 +371,7 @@ version = "0.15.0-unreleased"
|
|||
dependencies = [
|
||||
"caribon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"comrak 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"comrak 0.4.4 (git+http://github.com/lise-henry/comrak)",
|
||||
"console 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crowbook-intl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crowbook-intl-runtime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2283,7 +2283,7 @@ dependencies = [
|
|||
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
|
||||
"checksum clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum comrak 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6c6a70fb894be1bf51ca939f9e9008d93679908541793a6bf752bd313640a1d8"
|
||||
"checksum comrak 0.4.4 (git+http://github.com/lise-henry/comrak)" = "<none>"
|
||||
"checksum console 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2bf3720d3f3fc30b721ef1ae54e13af3264af4af39dc476a8de56a6ee1e2184b"
|
||||
"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
|
||||
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
|
||||
|
|
|
@ -47,7 +47,7 @@ crowbook-intl = "0.2"
|
|||
|
||||
[dependencies]
|
||||
mime_guess = "1"
|
||||
comrak = "0.4"
|
||||
comrak = {git = "http://github.com/lise-henry/comrak"}
|
||||
yaml-rust = "0.4"
|
||||
mustache = "0.9"
|
||||
uuid = { version = "0.7", features = ["v4"] }
|
||||
|
|
|
@ -6,7 +6,7 @@ unreleased
|
|||
* Moved from `pulldown-cmark` to `comrak` for parsing Markdown. This may have some
|
||||
performances drawbacks but allows for a few more features:
|
||||
* Description lists
|
||||
|
||||
* Strikethrough
|
||||
* New option:
|
||||
* `crowbook.files_mean_chapters` allow to enforce that each files
|
||||
means a chapter break or to make sure that it doesn't (by default,
|
||||
|
|
4
build.rs
4
build.rs
|
@ -6,8 +6,8 @@ use std::env;
|
|||
|
||||
|
||||
fn main() {
|
||||
// println!("cargo:rerun-if-changed=build.rs");
|
||||
// println!("cargo:rerun-if-changed=lang/fr.po");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=lang/fr.po");
|
||||
// Extract and localize src/lib
|
||||
let mut extractor = Extractor::new();
|
||||
extractor.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/lib")).unwrap();
|
||||
|
|
|
@ -480,7 +480,21 @@ impl<'a> EpubRenderer<'a> {
|
|||
}
|
||||
HtmlRenderer::static_render_token(this, token)
|
||||
}
|
||||
Token::Footnote(ref vec) => {
|
||||
Token::FootnoteReference(ref reference) => {
|
||||
let epub3 = (this.as_ref() as &HtmlRenderer)
|
||||
.book
|
||||
.options
|
||||
.get_i32("epub.version")
|
||||
.unwrap() == 3;
|
||||
|
||||
Ok(format!("<a {} href = \"#note-dest-{}\"><sup id = \
|
||||
\"note-source-{}\">[{}]</sup></a>",
|
||||
if epub3 { "epub:type = \"noteref\"" } else { "" },
|
||||
reference,
|
||||
reference,
|
||||
reference))
|
||||
}
|
||||
Token::FootnoteDefinition(ref reference, ref vec) => {
|
||||
let epub3 = (this.as_ref() as &HtmlRenderer)
|
||||
.book
|
||||
.options
|
||||
|
@ -488,28 +502,21 @@ impl<'a> EpubRenderer<'a> {
|
|||
.unwrap() == 3;
|
||||
let inner_content = this.render_vec(vec)?;
|
||||
let html: &mut HtmlRenderer = this.as_mut();
|
||||
html.footnote_number += 1;
|
||||
let number = html.footnote_number;
|
||||
let note_number = format!("<p class = \"note-number\">
|
||||
<a href = \"#note-source-{}\">[{}]</a>
|
||||
</p>\n",
|
||||
number,
|
||||
number);
|
||||
reference,
|
||||
reference);
|
||||
let inner = if epub3 {
|
||||
format!("<aside epub:type = \"footnote\" id = \"note-dest-{}\">{}</aside>",
|
||||
number,
|
||||
reference,
|
||||
inner_content)
|
||||
} else {
|
||||
format!("<a id = \"note-dest-{}\" />{}", number, inner_content)
|
||||
format!("<a id = \"note-dest-{}\" />{}", reference, inner_content)
|
||||
};
|
||||
html.add_footnote(note_number, inner);
|
||||
|
||||
Ok(format!("<a {} href = \"#note-dest-{}\"><sup id = \
|
||||
\"note-source-{}\">[{}]</sup></a>",
|
||||
if epub3 { "epub:type = \"noteref\"" } else { "" },
|
||||
number,
|
||||
number,
|
||||
number))
|
||||
Ok(String::new())
|
||||
}
|
||||
_ => HtmlRenderer::static_render_token(this, token),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue