diff --git a/examples/demo-app/src/icons/heroicons.rs b/examples/demo-app/src/icons/heroicons.rs index 964cdb2..0ceddfa 100644 --- a/examples/demo-app/src/icons/heroicons.rs +++ b/examples/demo-app/src/icons/heroicons.rs @@ -1,5 +1,5 @@ /// Auto-generated by dioxus-iconify - DO NOT EDIT -/// Generated: 2025-12-07T18:42:47.101876487+00:00 +/// Generated: 2026-06-05T07:24:35.982501714+00:00 /// Collection: heroicons /// This is a partial import from Iconify /// Browse icons: @@ -22,7 +22,7 @@ use super::IconData; #[allow(non_upper_case_globals)] pub const ArrowLeft: IconData = IconData { name: "heroicons:arrow-left", - body: r#""#, + body: r###""###, view_box: "0 0 24 24", width: "24", height: "24", diff --git a/examples/demo-app/src/icons/mdi.rs b/examples/demo-app/src/icons/mdi.rs index 6584553..b78bca7 100644 --- a/examples/demo-app/src/icons/mdi.rs +++ b/examples/demo-app/src/icons/mdi.rs @@ -1,5 +1,5 @@ /// Auto-generated by dioxus-iconify - DO NOT EDIT -/// Generated: 2025-12-07T18:42:47.102110686+00:00 +/// Generated: 2026-06-05T07:24:35.982624101+00:00 /// Collection: mdi /// This is a partial import from Iconify /// Browse icons: @@ -23,7 +23,7 @@ use super::IconData; #[allow(non_upper_case_globals)] pub const Account: IconData = IconData { name: "mdi:account", - body: r#""#, + body: r###""###, view_box: "0 0 24 24", width: "24", height: "24", @@ -32,7 +32,7 @@ pub const Account: IconData = IconData { #[allow(non_upper_case_globals)] pub const Home: IconData = IconData { name: "mdi:home", - body: r#""#, + body: r###""###, view_box: "0 0 24 24", width: "24", height: "24", diff --git a/src/generator.rs b/src/generator.rs index b3e823d..fad1047 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -80,7 +80,7 @@ impl IconConst { #[allow(non_upper_case_globals)] pub const {}: IconData = IconData {{ name: \"{}\", - body: r#\"{}\"#, + body: r###\"{}\"###, view_box: \"{}\", width: \"{}\", height: \"{}\", @@ -578,35 +578,50 @@ fn extract_string_value(line: &str) -> String { String::new() } -/// Extract a raw string value that might span multiple lines fn extract_raw_string_value(lines: &[&str], index: &mut usize) -> String { let line = lines[*index]; - // Look for r#"..."# - if let Some(start) = line.find("r#\"") { - let start_pos = start + 3; + // Find the start of a raw string literal (e.g. r#"..."#, r###"..."###). + if let Some(raw_string_start) = line.find("r#") + // Count the number of '#' characters by finding the opening quote + // relative to the 'r'. + // r#"..."# => 1 + // r###"..."### => 3 + && let Some(hash_count) = line[raw_string_start + 1..].find('"') + { + // Position immediately after the opening quote. + let content_start = raw_string_start + hash_count + 2; + + // Construct the matching closing delimiter. + // hash_count = 1 => "# + // hash_count = 3 => "### + let closing_delimiter = format!("\"{}", "#".repeat(hash_count)); - // Check if it ends on the same line - if let Some(end) = line[start_pos..].find("\"#") { - return line[start_pos..start_pos + end].to_string(); + // Single-line raw string. + if let Some(closing_offset) = line[content_start..].find(&closing_delimiter) { + return line[content_start..content_start + closing_offset].to_string(); } - // Multi-line: collect until we find "# - let mut result = line[start_pos..].to_string(); + // Multi-line raw string. + let mut content = String::from(&line[content_start..]); *index += 1; while *index < lines.len() { - let next_line = lines[*index]; - if let Some(end) = next_line.find("\"#") { - result.push_str(&next_line[..end]); + let line = lines[*index]; + + // Found the closing delimiter. + if let Some(closing_offset) = line.find(&closing_delimiter) { + content.push('\n'); + content.push_str(&line[..closing_offset]); break; } - result.push_str(next_line); - result.push('\n'); + + content.push('\n'); + content.push_str(line); *index += 1; } - result + content } else { String::new() } diff --git a/tests/cli_integration.rs b/tests/cli_integration.rs index 127eee6..ac51bc3 100644 --- a/tests/cli_integration.rs +++ b/tests/cli_integration.rs @@ -250,6 +250,7 @@ fn test_generated_code_compiles() -> Result<()> { .arg("mdi:home") .arg("heroicons:arrow-left") .arg("lucide:settings") + .arg("logos:chrome") .arg("--output") .arg(&icons_dir) .assert() @@ -273,13 +274,14 @@ mod icons; use dioxus::prelude::*; use icons::Icon; -use icons::{heroicons, lucide, mdi}; +use icons::{heroicons, lucide, logos, mdi}; fn main() { // Use the icons to avoid dead_code warnings let _home = mdi::Home; let _arrow = heroicons::ArrowLeft; let _settings = lucide::Settings; + let _chrome = logos::Chrome; println!("Icons loaded successfully"); } @@ -291,6 +293,7 @@ fn App() -> Element { Icon { data: mdi::Home } Icon { data: heroicons::ArrowLeft } Icon { data: lucide::Settings, width: "32", height: "32" } + Icon { data: logos::Chrome } Icon { data: mdi::Home, size: "24" } Icon { data: heroicons::ArrowLeft, size: 32.to_string() } Icon { data: lucide::Settings, size: "2em" }