diff options
author | Jan-Erik Rediger <janerik@fnordig.de> | 2020-04-03 14:15:58 +0200 |
---|---|---|
committer | Jan-Erik Rediger <janerik@fnordig.de> | 2020-04-03 14:15:58 +0200 |
commit | 5f8d98fc4206895f326e356e953da2d261d42d4f (patch) | |
tree | 855957a24593a7c738f18d1dea2a3b7695b66465 | |
parent | 2efb2f35265fef9da3718a1e4897844a4b63846d (diff) |
Skip footer creation if it already exists
-rw-r--r-- | src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -52,6 +52,11 @@ impl Preprocessor for OpenOn { fn open_on(git_root: &Path, src_root: &Path, base_url: &str, chapter: &mut Chapter) -> Result<String> { let content = &chapter.content; + + let footer_start = "<footer id=\"open-on-gh\">"; + if content.contains(footer_start) { + return Ok(content.into()) + } let path = match src_root.join(&chapter.path).canonicalize() { Ok(path) => path, Err(_) => return Ok(content.into()), @@ -64,7 +69,7 @@ fn open_on(git_root: &Path, src_root: &Path, base_url: &str, chapter: &mut Chapt log::trace!("URL: {}", url); let link = format!("<a href=\"{}\">Edit this file on GitHub.</a>", url); - let content = format!("{}\n<footer id=\"open-on-gh\">Found a bug? {}</footer>", content, link); + let content = format!("{}\n{}Found a bug? {}</footer>", content, footer_start, link); Ok(content) } |