Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/demo-app/src/icons/heroicons.rs
Original file line number Diff line number Diff line change
@@ -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: <https://icon-sets.iconify.design/heroicons/>
Expand All @@ -22,7 +22,7 @@ use super::IconData;
#[allow(non_upper_case_globals)]
pub const ArrowLeft: IconData = IconData {
name: "heroicons:arrow-left",
body: r#"<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"/>"#,
body: r###"<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"/>"###,
view_box: "0 0 24 24",
width: "24",
height: "24",
Expand Down
6 changes: 3 additions & 3 deletions examples/demo-app/src/icons/mdi.rs
Original file line number Diff line number Diff line change
@@ -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: <https://icon-sets.iconify.design/mdi/>
Expand All @@ -23,7 +23,7 @@ use super::IconData;
#[allow(non_upper_case_globals)]
pub const Account: IconData = IconData {
name: "mdi:account",
body: r#"<path fill="currentColor" d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4"/>"#,
body: r###"<path fill="currentColor" d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4"/>"###,
view_box: "0 0 24 24",
width: "24",
height: "24",
Expand All @@ -32,7 +32,7 @@ pub const Account: IconData = IconData {
#[allow(non_upper_case_globals)]
pub const Home: IconData = IconData {
name: "mdi:home",
body: r#"<path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8z"/>"#,
body: r###"<path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8z"/>"###,
view_box: "0 0 24 24",
width: "24",
height: "24",
Expand Down
47 changes: 31 additions & 16 deletions src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl IconConst {
#[allow(non_upper_case_globals)]
pub const {}: IconData = IconData {{
name: \"{}\",
body: r#\"{}\"#,
body: r###\"{}\"###,
Comment thread
sonicjhon1 marked this conversation as resolved.
view_box: \"{}\",
width: \"{}\",
height: \"{}\",
Expand Down Expand Up @@ -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()
}
Expand Down
5 changes: 4 additions & 1 deletion tests/cli_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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");
}
Expand All @@ -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" }
Expand Down