rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
696 stars 150 forks source link

Partial escape of HTML link from peripheral description #849

Open hegza opened 3 months ago

hegza commented 3 months ago

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

burrbull commented 3 months ago

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

hegza commented 3 months ago

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 commented 3 months ago

PRs are appreciated.