Skip to content

feat: svg#187

Merged
vidhanio merged 37 commits intomainfrom
svg
Mar 22, 2026
Merged

feat: svg#187
vidhanio merged 37 commits intomainfrom
svg

Conversation

@vidhanio
Copy link
Copy Markdown
Owner

@vidhanio vidhanio commented Mar 7, 2026

closes #2

@vidhanio
Copy link
Copy Markdown
Owner Author

@Brocktho @philocalyst, please give this a test if interested and let me know if you hit any snags! :)

@vidhanio vidhanio mentioned this pull request Mar 15, 2026
@vidhanio vidhanio merged commit e40e554 into main Mar 22, 2026
28 of 29 checks passed
@vidhanio vidhanio deleted the svg branch March 22, 2026 18:04
@github-actions github-actions bot mentioned this pull request Mar 22, 2026
@howesteve
Copy link
Copy Markdown

I don't want to be a bummer, but aren't at least fill and stroke missing from the svg tags? I can see fill in a test, but not defined in the tag itself. Is that test passing?

Actually, those attribs seem to be missing:

fill, stroke, stroke-width, opacity, fill-opacity, stroke-opacity, version

@vidhanio
Copy link
Copy Markdown
Owner Author

vidhanio commented Apr 4, 2026

@howesteve They are described in the attribute trait for SVGs which defines base attributes for all SVG elements, do you have an example of some code that isn't working as expected?

@howesteve
Copy link
Copy Markdown

@howesteve They are described in the attribute trait for SVGs which defines base attributes for all SVG elements, do you have an example of some code that isn't working as expected?

Sure. Sorry for the delay in answering this - crazy days here.

use hypertext::prelude::*;

fn main() {
  // test case 1: SVG with fill attribute
  let svg_with_fill = rsx!(
      <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
          <path d="M13 10V3L4 14h7v7l9-11h-7z" />
      </svg>
  );

  // rest case 2: SVG with stroke attribute
  let svg_with_stroke = rsx!(
      <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path d="M13 10V3L4 14h7v7l9-11h-7z" />
      </svg>
  );

  // test case 3: SVG with stroke-width attribute
  let svg_with_stroke_width = rsx!(
      <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
          <path d="M13 10V3L4 14h7v7l9-11h-7z" />
      </svg>
  );

  // Test case 4: SVG with stroke-linecap and stroke-linejoin
  let svg_with_stroke_attrs = rsx!(
      <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M13 10V3L4 14h7v7l9-11h-7z" />
      </svg>
  );
}

Cargo.toml - I'm using rev 9773200 here, latest I see after svg support.

[package]
name = "hypertext_bug_repro"
version = "0.1.0"
edition = "2024"

[workspace]

[dependencies]
hypertext = { git = "https://github.com/vidhanio/hypertext.git", features = ["alloc"], rev="97732000c7916f5d7f39de581436c80c58b80a82" }

cargo check's output (trimmed for brevity):

 --> src/main.rs:6:47
  |
5 |     let svg_with_fill = rsx!(
  |  _______________________-
6 | |       <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
  | |                                              -^^^^ associated function or constant not found in `hypertext::prelude::hypertext_elements::svg`
  | |______________________________________________|
  |

error[E0599]: no associated function or constant named `fill` found for struct `hypertext::prelude::hypertext_elements::svg` in the current scope

error[E0599]: no associated function or constant named `stroke_linecap` found for struct `hypertext::prelude::hypertext_elements::svg` in the current scope
  --> src/main.rs:27:125
   |
26 |   ... = rsx!(
   |  _______-
27 | | ...w.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" stroke-linecap="r...
   | |                                                                                                    -^^^^^^^ associated function or constant not found in `hypertext::prelude::hypertext_elements::svg`
   | |____________________________________________________________________________________________________|
   |

error[E0599]: no associated function or constant named `stroke_linejoin` found for struct `hypertext::prelude::hypertext_elements::svg` in the current scope
  --> src/main.rs:27:141
   |
26 |   ... = rsx!(
   |  _______-
27 | | ...w.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-li...
   | |                                                                                                                    -^^^^^^ associated function or constant not found in `hypertext::prelude::hypertext_elements::svg`
   | |____________________________________________________________________________________________________________________|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add svg support

3 participants