@@ -1638,11 +1638,12 @@ dependencies = [ | |||||
[[package]] | [[package]] | ||||
name = "pulldown-cmark" | name = "pulldown-cmark" | ||||
version = "0.3.0" | |||||
version = "0.4.0" | |||||
source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
dependencies = [ | dependencies = [ | ||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", | "getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
] | ] | ||||
@@ -1872,7 +1873,7 @@ dependencies = [ | |||||
"link_checker 0.1.0", | "link_checker 0.1.0", | ||||
"pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"pulldown-cmark 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"pulldown-cmark 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | |||||
"regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", | "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
"serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", | "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
@@ -3219,7 +3220,7 @@ dependencies = [ | |||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" | "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" | ||||
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" | "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" | ||||
"checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15" | "checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15" | ||||
"checksum pulldown-cmark 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "426175701ce727edeeef0a56535d88cc62afbdd977933e82be610044d645c4ec" | |||||
"checksum pulldown-cmark 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa4987312f985c300f4d68d208a9e4b646268140b6dbe83388c09652cc19ed3f" | |||||
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" | "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" | ||||
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" | "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" | ||||
"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" | "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" | ||||
@@ -6,7 +6,7 @@ authors = ["Vincent Prouillet <prouillet.vincent@gmail.com>"] | |||||
[dependencies] | [dependencies] | ||||
tera = { version = "1.0.0-alpha.3", features = ["preserve_order"] } | tera = { version = "1.0.0-alpha.3", features = ["preserve_order"] } | ||||
syntect = "3" | syntect = "3" | ||||
pulldown-cmark = "0.3" | |||||
pulldown-cmark = "0.4" | |||||
slug = "0.1" | slug = "0.1" | ||||
serde = "1" | serde = "1" | ||||
serde_derive = "1" | serde_derive = "1" | ||||
@@ -58,7 +58,7 @@ fn parse_shortcode_call(pair: Pair<Rule>) -> (String, Map<String, Value>) { | |||||
for p in pair.into_inner() { | for p in pair.into_inner() { | ||||
match p.as_rule() { | match p.as_rule() { | ||||
Rule::ident => { | Rule::ident => { | ||||
name = Some(p.into_span().as_str().to_string()); | |||||
name = Some(p.as_span().as_str().to_string()); | |||||
} | } | ||||
Rule::kwarg => { | Rule::kwarg => { | ||||
let mut arg_name = None; | let mut arg_name = None; | ||||
@@ -66,7 +66,7 @@ fn parse_shortcode_call(pair: Pair<Rule>) -> (String, Map<String, Value>) { | |||||
for p2 in p.into_inner() { | for p2 in p.into_inner() { | ||||
match p2.as_rule() { | match p2.as_rule() { | ||||
Rule::ident => { | Rule::ident => { | ||||
arg_name = Some(p2.into_span().as_str().to_string()); | |||||
arg_name = Some(p2.as_span().as_str().to_string()); | |||||
} | } | ||||
Rule::literal => { | Rule::literal => { | ||||
arg_val = Some(parse_literal(p2)); | arg_val = Some(parse_literal(p2)); | ||||
@@ -169,7 +169,7 @@ pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result<Strin | |||||
// We have at least a `page` pair | // We have at least a `page` pair | ||||
for p in pairs.next().unwrap().into_inner() { | for p in pairs.next().unwrap().into_inner() { | ||||
match p.as_rule() { | match p.as_rule() { | ||||
Rule::text => res.push_str(p.into_span().as_str()), | |||||
Rule::text => res.push_str(p.as_span().as_str()), | |||||
Rule::inline_shortcode => { | Rule::inline_shortcode => { | ||||
let (name, args) = parse_shortcode_call(p); | let (name, args) = parse_shortcode_call(p); | ||||
res.push_str(&render_shortcode(&name, &args, context, None)?); | res.push_str(&render_shortcode(&name, &args, context, None)?); | ||||
@@ -179,12 +179,12 @@ pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result<Strin | |||||
// 3 items in inner: call, body, end | // 3 items in inner: call, body, end | ||||
// we don't care about the closing tag | // we don't care about the closing tag | ||||
let (name, args) = parse_shortcode_call(inner.next().unwrap()); | let (name, args) = parse_shortcode_call(inner.next().unwrap()); | ||||
let body = inner.next().unwrap().into_span().as_str(); | |||||
let body = inner.next().unwrap().as_span().as_str(); | |||||
res.push_str(&render_shortcode(&name, &args, context, Some(body))?); | res.push_str(&render_shortcode(&name, &args, context, Some(body))?); | ||||
} | } | ||||
Rule::ignored_inline_shortcode => { | Rule::ignored_inline_shortcode => { | ||||
res.push_str( | res.push_str( | ||||
&p.into_span().as_str().replacen("{{/*", "{{", 1).replacen("*/}}", "}}", 1), | |||||
&p.as_span().as_str().replacen("{{/*", "{{", 1).replacen("*/}}", "}}", 1), | |||||
); | ); | ||||
} | } | ||||
Rule::ignored_shortcode_with_body => { | Rule::ignored_shortcode_with_body => { | ||||
@@ -192,13 +192,13 @@ pub fn render_shortcodes(content: &str, context: &RenderContext) -> Result<Strin | |||||
match p2.as_rule() { | match p2.as_rule() { | ||||
Rule::ignored_sc_body_start | Rule::ignored_sc_body_end => { | Rule::ignored_sc_body_start | Rule::ignored_sc_body_end => { | ||||
res.push_str( | res.push_str( | ||||
&p2.into_span() | |||||
&p2.as_span() | |||||
.as_str() | .as_str() | ||||
.replacen("{%/*", "{%", 1) | .replacen("{%/*", "{%", 1) | ||||
.replacen("*/%}", "%}", 1), | .replacen("*/%}", "%}", 1), | ||||
); | ); | ||||
} | } | ||||
Rule::text_in_ignored_body_sc => res.push_str(p2.into_span().as_str()), | |||||
Rule::text_in_ignored_body_sc => res.push_str(p2.as_span().as_str()), | |||||
_ => unreachable!("Got something weird in an ignored shortcode: {:?}", p2), | _ => unreachable!("Got something weird in an ignored shortcode: {:?}", p2), | ||||
} | } | ||||
} | } | ||||
@@ -230,7 +230,7 @@ mod tests { | |||||
panic!(); | panic!(); | ||||
} | } | ||||
assert!(res.is_ok()); | assert!(res.is_ok()); | ||||
assert_eq!(res.unwrap().last().unwrap().into_span().end(), $input.len()); | |||||
assert_eq!(res.unwrap().last().unwrap().as_span().end(), $input.len()); | |||||
}; | }; | ||||
} | } | ||||