Minor fixes
This commit is contained in:
parent
972aab1ac4
commit
7130616f63
|
@ -54,8 +54,6 @@ fn fix_link(link: &str, context: &RenderContext) -> Result<String> {
|
||||||
// - it could be a relative link (starting with `./`)
|
// - it could be a relative link (starting with `./`)
|
||||||
// - it could be a link to a co-located asset
|
// - it could be a link to a co-located asset
|
||||||
// - it could be a normal link
|
// - it could be a normal link
|
||||||
// - any of those can be in a header or not: if it's in a header
|
|
||||||
// we need to append to a string
|
|
||||||
let result = if link.starts_with("./") {
|
let result = if link.starts_with("./") {
|
||||||
match resolve_internal_link(&link, context.permalinks) {
|
match resolve_internal_link(&link, context.permalinks) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
|
@ -82,18 +80,18 @@ fn fix_link(link: &str, context: &RenderContext) -> Result<String> {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_tag(temp_header: &mut TempHeader, tag: &Tag) -> bool {
|
fn push_start_tag(temp_header: &mut TempHeader, tag: &Tag) -> bool {
|
||||||
match tag {
|
match tag {
|
||||||
Tag::Emphasis => temp_header.add_html("<em>"),
|
Tag::Emphasis => temp_header.add_html("<em>"),
|
||||||
Tag::Strong => temp_header.add_html("<strong>"),
|
Tag::Strong => temp_header.add_html("<strong>"),
|
||||||
Tag::Code => temp_header.add_html("<code>"),
|
Tag::Code => temp_header.add_html("<code>"),
|
||||||
// Tag::Link is handled elsewhere
|
// Tag::Link is handled in `markdown_to_html`
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_tag(temp_header: &mut TempHeader, tag: &Tag) -> bool {
|
fn push_end_tag(temp_header: &mut TempHeader, tag: &Tag) -> bool {
|
||||||
match tag {
|
match tag {
|
||||||
Tag::Emphasis => temp_header.add_html("</em>"),
|
Tag::Emphasis => temp_header.add_html("</em>"),
|
||||||
Tag::Strong => temp_header.add_html("</strong>"),
|
Tag::Strong => temp_header.add_html("</strong>"),
|
||||||
|
@ -107,8 +105,8 @@ fn end_tag(temp_header: &mut TempHeader, tag: &Tag) -> bool {
|
||||||
/// returns true if event have been processed
|
/// returns true if event have been processed
|
||||||
fn push_to_temp_header(event: &Event, temp_header: &mut TempHeader) -> bool {
|
fn push_to_temp_header(event: &Event, temp_header: &mut TempHeader) -> bool {
|
||||||
match event {
|
match event {
|
||||||
Event::Start(tag) => start_tag(temp_header, tag),
|
Event::Start(tag) => push_start_tag(temp_header, tag),
|
||||||
Event::End(tag) => end_tag(temp_header, tag),
|
Event::End(tag) => push_end_tag(temp_header, tag),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +138,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
|
||||||
|
|
||||||
{
|
{
|
||||||
let parser = Parser::new_ext(content, opts).map(|event| {
|
let parser = Parser::new_ext(content, opts).map(|event| {
|
||||||
// Trivial markup generation
|
// if in header, just do the parse ourselves
|
||||||
if in_header && push_to_temp_header(&event, &mut temp_header) {
|
if in_header && push_to_temp_header(&event, &mut temp_header) {
|
||||||
return Event::Html(Borrowed(""));
|
return Event::Html(Borrowed(""));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue