Skip to content

Conversation

@GuillaumeGomez
Copy link
Contributor

First commit comes from #261.

For triagebot "enhanced" log pages, it makes a HUGE difference to not have all these tags rendered (takes me more than one minute to load a page with anstyle before this PR).

Comment on lines 102 to 93
/// Whether or not to generate HTML5 compatible tags.
pub const fn use_html5(mut self, use_html5: bool) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the prevelance of html5 for whether we should just make this non-configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML5 is basically used everywhere nowadays. I'm not sure if formats like epub are fully-compliant though. So if you want to keep this crate useable by a maximum number of users, I'd say keep the possibility to disable HTML5. We can however discuss about whether or not it should be enabled or disabled by default.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I think I'd prefer we switch over to HTML 5 and we can add an opt-out if someone has a need.

Based on usage, HTML 5 seems like the right choice. At that point, rather than speculatively have an opt-out, I'd prefer doing it when requested.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason use_html5 hasn't been removed?

@GuillaumeGomez GuillaumeGomez force-pushed the improve-internals branch 2 times, most recently from e865e6f to e125d1b Compare July 28, 2025 22:19
@GuillaumeGomez
Copy link
Contributor Author

Made atomic commits, moved function as suggested and created a new enum for span kinds (named SpanKind).

@coveralls
Copy link

coveralls commented Jul 28, 2025

Pull Request Test Coverage Report for Build 16598275897

Details

  • 43 of 46 (93.48%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 53.717%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/anstyle-svg/src/lib.rs 43 46 93.48%
Files with Coverage Reduction New Missed Lines %
crates/anstyle/src/effect.rs 1 41.94%
Totals Coverage Status
Change from base Build 16581052420: 0.2%
Covered Lines: 1409
Relevant Lines: 2623

💛 - Coveralls

@GuillaumeGomez GuillaumeGomez force-pushed the improve-internals branch 3 times, most recently from f9eb36c to e5c93d9 Compare July 29, 2025 12:49
@GuillaumeGomez
Copy link
Contributor Author

Applied suggestions and merge tests updates within the relevant commits.

write_bg_span(buffer, "span", &element.style, &element.text);
}
writeln!(buffer, r#"<br />"#).unwrap();
buffer.write_str(br).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore the use of writeln! as that is not relevant to this commit (overlooked it until I could see how the tests changed

Comment on lines 102 to 93
/// Whether or not to generate HTML5 compatible tags.
pub const fn use_html5(mut self, use_html5: bool) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason use_html5 hasn't been removed?

Comment on lines 507 to 513
if span != SpanKind::Tspan && classes.is_empty() && element.url.is_none() {
// No need to create an element if there is no class or href.
write!(buffer, "{fragment}").unwrap();
}
let mut need_closing_a = false;

write!(buffer, r#"<{span}"#).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are writing out the fragment with and without a span in this commit

// No need to create an element if there is no class or href.
write!(buffer, "{fragment}").unwrap();
}
let mut need_closing_a = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If already splitting everything, why not have this in the match?


let br = if self.use_html5 { "<br>" } else { "<br />" };
writeln!(buffer, r#" <div class="container {FG}">"#).unwrap();
write!(buffer, r#"<div class="container {FG}">"#).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this commit

I doubt this makes enough of a difference to be worth it and part of the intent for ansstyle-svg is to be usable for tests which involves diffing the content

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.

3 participants