Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial escape of HTML link from peripheral description #849

Closed
hegza opened this issue Jun 10, 2024 · 6 comments · Fixed by #872
Closed

Partial escape of HTML link from peripheral description #849

hegza opened this issue Jun 10, 2024 · 6 comments · Fixed by #872

Comments

@hegza
Copy link

hegza commented Jun 10, 2024

Given an SVD with an HTML link in a description creates either a correct or a partially escaped link definition depending on where it is generated in the PAC.

E.g., relevant part of input SVD:

<peripheral>
	<name>Google</name>
	<version>1.0</version>
	<description>
		Link to Google: &lt;https://google.com&gt;
	</description>
	<registers>...</registers>
</peripheral>

Relevant parts of output:

#[doc = "Link to Google: &lt;https://google.com>"]
pub mod google;
#[doc = "Link to Google: <https://google.com>"]
pub struct Google {
    _marker: PhantomData<*const ()>,
}

We see the generated link symbols are partially escaped when used in the mod documentation and correctly escaped when used in peripheral struct documentation.

Reproduction

  • Attached, minimal SVD to reproduce issue: test.zip (in Zip due to GitHub file-type restriction)
  • Command to generate: svd2rust --target riscv -i test.svd && form -i lib.rs -o src && rm lib.rs && cargo fmt
  • svd2rust --version

    svd2rust 0.33.3 ( )

@burrbull
Copy link
Member

I've never see links in description. Is this allowed by SVD? I'm not sure.

@hegza
Copy link
Author

hegza commented Jun 15, 2024

I would've assumed that svd2rust does not do transformations of the field contents but it does seem to translate special HTML characters. Surely it's wrong that it sometimes does it and sometimes not.

The behavior is relevant for our use case. I'll try to find time to investigate.

@burrbull
Copy link
Member

PRs are appreciated.

@burrbull
Copy link
Member

I've found that causer is encode_text_minimal.
Looks like removing it fixes your issue. The question is can we remove it entirely? Does it needed yet?

@hegza
Copy link
Author

hegza commented Oct 20, 2024

Sorry, I don't necessarily understand the question. I'm also sorry I didn't get to investigating it myself. It's a low priority issue for us at the end of the day and we re-generate PACs infrequently.

We use peripheral level links to point to the relevant hardware implementation / documentation when working with open-source hardware IP.

Consistency is good enough, i.e. both links generated the same way. We can script the rest if necessary. Does that answer the question?

@burrbull
Copy link
Member

The question is why #711 was introduced. Maybe it is just not actual in newer versions of Rust.

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 a pull request may close this issue.

2 participants