Add markdown-[before|after]-content options
This commit is contained in:
parent
70198a0a44
commit
95a94e3d3d
2 changed files with 23 additions and 2 deletions
|
@ -13,6 +13,7 @@ use std::io::prelude::*;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
use html::markdown::{Markdown, RenderType};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ExternalHtml{
|
pub struct ExternalHtml{
|
||||||
|
@ -28,17 +29,26 @@ pub struct ExternalHtml{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExternalHtml {
|
impl ExternalHtml {
|
||||||
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
|
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
|
||||||
|
md_before_content: &[String], md_after_content: &[String], render: RenderType)
|
||||||
-> Option<ExternalHtml> {
|
-> Option<ExternalHtml> {
|
||||||
load_external_files(in_header)
|
load_external_files(in_header)
|
||||||
.and_then(|ih|
|
.and_then(|ih|
|
||||||
load_external_files(before_content)
|
load_external_files(before_content)
|
||||||
.map(|bc| (ih, bc))
|
.map(|bc| (ih, bc))
|
||||||
)
|
)
|
||||||
|
.and_then(|(ih, bc)|
|
||||||
|
load_external_files(md_before_content)
|
||||||
|
.map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
|
||||||
|
)
|
||||||
.and_then(|(ih, bc)|
|
.and_then(|(ih, bc)|
|
||||||
load_external_files(after_content)
|
load_external_files(after_content)
|
||||||
.map(|ac| (ih, bc, ac))
|
.map(|ac| (ih, bc, ac))
|
||||||
)
|
)
|
||||||
|
.and_then(|(ih, bc, ac)|
|
||||||
|
load_external_files(md_after_content)
|
||||||
|
.map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
|
||||||
|
)
|
||||||
.map(|(ih, bc, ac)|
|
.map(|(ih, bc, ac)|
|
||||||
ExternalHtml {
|
ExternalHtml {
|
||||||
in_header: ih,
|
in_header: ih,
|
||||||
|
|
|
@ -159,6 +159,14 @@ pub fn opts() -> Vec<RustcOptGroup> {
|
||||||
"files to include inline between the content and </body> of a rendered \
|
"files to include inline between the content and </body> of a rendered \
|
||||||
Markdown file or generated documentation",
|
Markdown file or generated documentation",
|
||||||
"FILES")),
|
"FILES")),
|
||||||
|
unstable(optmulti("", "markdown-before-content",
|
||||||
|
"files to include inline between <body> and the content of a rendered \
|
||||||
|
Markdown file or generated documentation",
|
||||||
|
"FILES")),
|
||||||
|
unstable(optmulti("", "markdown-after-content",
|
||||||
|
"files to include inline between the content and </body> of a rendered \
|
||||||
|
Markdown file or generated documentation",
|
||||||
|
"FILES")),
|
||||||
stable(optopt("", "markdown-playground-url",
|
stable(optopt("", "markdown-playground-url",
|
||||||
"URL to send code snippets to", "URL")),
|
"URL to send code snippets to", "URL")),
|
||||||
stable(optflag("", "markdown-no-toc", "don't include table of contents")),
|
stable(optflag("", "markdown-no-toc", "don't include table of contents")),
|
||||||
|
@ -274,7 +282,10 @@ pub fn main_args(args: &[String]) -> isize {
|
||||||
let external_html = match ExternalHtml::load(
|
let external_html = match ExternalHtml::load(
|
||||||
&matches.opt_strs("html-in-header"),
|
&matches.opt_strs("html-in-header"),
|
||||||
&matches.opt_strs("html-before-content"),
|
&matches.opt_strs("html-before-content"),
|
||||||
&matches.opt_strs("html-after-content")) {
|
&matches.opt_strs("html-after-content"),
|
||||||
|
&matches.opt_strs("markdown-before-content"),
|
||||||
|
&matches.opt_strs("markdown-after-content"),
|
||||||
|
render_type) {
|
||||||
Some(eh) => eh,
|
Some(eh) => eh,
|
||||||
None => return 3,
|
None => return 3,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue