From 61c84131386baaacc1bfa5ddc85dcdf5fe5b2314 Mon Sep 17 00:00:00 2001 From: Gilles Rasigade Date: Fri, 1 May 2020 07:47:50 +0200 Subject: [PATCH 1/5] Allow to define own HTML attributes Create a `index.hbs` template file to render additional HTML attributes --- src/renderer/html_handlebars/hbs_renderer.rs | 3 + src/theme/head.hbs | 1 + src/theme/index.hbs | 500 ++++++++++--------- src/theme/mod.rs | 6 + 4 files changed, 273 insertions(+), 237 deletions(-) create mode 100644 src/theme/head.hbs diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 14012c12..cea3a9fd 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -327,6 +327,9 @@ impl Renderer for HtmlHandlebars { debug!("Register the index handlebars template"); handlebars.register_template_string("index", String::from_utf8(theme.index.clone())?)?; + debug!("Register the head handlebars template"); + handlebars.register_partial("head", String::from_utf8(theme.head.clone())?)?; + debug!("Register the header handlebars template"); handlebars.register_partial("header", String::from_utf8(theme.header.clone())?)?; diff --git a/src/theme/head.hbs b/src/theme/head.hbs new file mode 100644 index 00000000..cb1be187 --- /dev/null +++ b/src/theme/head.hbs @@ -0,0 +1 @@ +{{!-- Put your head HTML text here --}} diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 291e2796..9a0951a6 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -1,289 +1,315 @@ - - - - {{ title }} - {{#if is_print }} - - {{/if}} - - - - + + + + {{ title }} + {{#if is_print }} + + {{/if}} - - - - - + + {{> head}} - - - - + + + + - - - - + + + + + - - {{#each additional_css}} - - {{/each}} + + + + - {{#if mathjax_support}} - - - {{/if}} - - - - + + + + - - + {{/if}} + - if (sidebar.startsWith('"') && sidebar.endsWith('"')) { - localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); - } - } catch (e) { } - + + + - - + + - + if (sidebar.startsWith('"') && sidebar.endsWith('"')) { + localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); + } + } catch (e) { } + -
+ + -
- {{> header}} - -