diff --git a/crates/rari-doc/src/templ/parser.rs b/crates/rari-doc/src/templ/parser.rs
index 3c9e239c..2f173eae 100644
--- a/crates/rari-doc/src/templ/parser.rs
+++ b/crates/rari-doc/src/templ/parser.rs
@@ -76,6 +76,7 @@ fn to_arg(pair: Pair<'_, Rule>) -> Option {
Rule::single_quoted_string => pair.into_inner().next().and_then(to_arg),
Rule::double_quoted_string => pair.into_inner().next().and_then(to_arg),
Rule::backquoted_quoted_string => pair.into_inner().next().and_then(to_arg),
+ Rule::empty_string => None,
Rule::sq_string => {
let s = pair.as_span().as_str();
Some(Arg::String(
@@ -177,4 +178,13 @@ mod test {
let p = parse(r#"dasd \\{{foo}} 200 {{bar}}"#);
println!("{:#?}", p);
}
+
+ #[test]
+ fn with_empty_string_arg() {
+ let p = parse(r#"{{foo("")}}"#);
+ assert!(matches!(
+ p.unwrap().first(),
+ Some(Token::Macro(macro_token)) if macro_token.args.first() == Some(&None)
+ ));
+ }
}
diff --git a/crates/rari-doc/src/templ/rari-templ.pest b/crates/rari-doc/src/templ/rari-templ.pest
index 0f95c84c..611fad58 100644
--- a/crates/rari-doc/src/templ/rari-templ.pest
+++ b/crates/rari-doc/src/templ/rari-templ.pest
@@ -39,6 +39,7 @@ string = _{
boolean = { "true" | "false" }
none = { "" }
+empty_string = { "\"\"" | "''" | "``" }
all_chars = _{'a'..'z' | 'A'..'Z' | "_" | "-" | '0'..'9'}
@@ -47,7 +48,7 @@ ident = ${
all_chars*
}
-arg = _{ string | float | int | boolean | none }
+arg = _{ empty_string | string | float | int | boolean | none }
kwargs = !{ arg ~ ("," ~ arg )* ~ ","? }
fn_call = !{ ident ~ "(" ~ kwargs? ~ ")" }
diff --git a/crates/rari-doc/src/templ/templs/embeds/embed_gh_live_sample.rs b/crates/rari-doc/src/templ/templs/embeds/embed_gh_live_sample.rs
index fa69dd98..5d0932d6 100644
--- a/crates/rari-doc/src/templ/templs/embeds/embed_gh_live_sample.rs
+++ b/crates/rari-doc/src/templ/templs/embeds/embed_gh_live_sample.rs
@@ -14,14 +14,10 @@ pub fn embed_gh_live_sample(
let mut out = String::new();
out.push_str("
"#,
]);
diff --git a/crates/rari-doc/src/templ/templs/links/domxref.rs b/crates/rari-doc/src/templ/templs/links/domxref.rs
index da56ca27..b35b63aa 100644
--- a/crates/rari-doc/src/templ/templs/links/domxref.rs
+++ b/crates/rari-doc/src/templ/templs/links/domxref.rs
@@ -34,15 +34,13 @@ pub fn domxref(
&api[first_char_index..],
);
if let Some(anchor) = anchor {
- if !anchor.is_empty() {
- if !anchor.starts_with('#') {
- url.push('#');
- display_with_fallback = Cow::Owned(format!("{}.{}", display_with_fallback, anchor));
- }
- url.push_str(&anchor);
- if let Some(anchor) = anchor.strip_prefix('#') {
- display_with_fallback = Cow::Owned(format!("{}.{}", display_with_fallback, anchor));
- }
+ if !anchor.starts_with('#') {
+ url.push('#');
+ display_with_fallback = Cow::Owned(format!("{}.{}", display_with_fallback, anchor));
+ }
+ url.push_str(&anchor);
+ if let Some(anchor) = anchor.strip_prefix('#') {
+ display_with_fallback = Cow::Owned(format!("{}.{}", display_with_fallback, anchor));
}
}
diff --git a/crates/rari-doc/src/templ/templs/links/rfc.rs b/crates/rari-doc/src/templ/templs/links/rfc.rs
index 4999ce3b..7009c3ab 100644
--- a/crates/rari-doc/src/templ/templs/links/rfc.rs
+++ b/crates/rari-doc/src/templ/templs/links/rfc.rs
@@ -10,9 +10,7 @@ pub fn rfc(
content: Option,
anchor: Option,
) -> Result {
- let content = content.and_then(|c| if c.is_empty() { None } else { Some(c) });
- let anchor_str = anchor.and_then(|a| if a.is_empty() { None } else { Some(a) });
- let (content, anchor): (String, String) = match (content, anchor_str) {
+ let (content, anchor): (String, String) = match (content, anchor) {
(None, None) => Default::default(),
(None, Some(anchor)) => (
format!(
diff --git a/crates/rari-types/src/lib.rs b/crates/rari-types/src/lib.rs
index 3fe6d0b6..e19ac401 100644
--- a/crates/rari-types/src/lib.rs
+++ b/crates/rari-types/src/lib.rs
@@ -47,13 +47,6 @@ pub struct AnyArg {
}
impl AnyArg {
- pub fn is_empty(&self) -> bool {
- if let Arg::String(s, _) = &self.value {
- s.is_empty()
- } else {
- false
- }
- }
pub fn as_int(&self) -> i64 {
match &self.value {
Arg::String(s, _) => s