Skip to content

Unquoted text on stable #5

@vldm

Description

@vldm

Currently RawText uses unstable Span::join https://github.com/rs-tml/rstml/blob/v0.10.1/src/node/raw_text.rs#L52
to provide source text with spaces. Because of its unstability it is not availabe on stable rust.
I found that in test https://github.com/rs-tml/rstml/blob/v0.10.1/tests/test.rs#L110 unquoted text is working even on stable, because fallback implementation of proc_macro2::TokenStream can handle Span::join.

Because Unquoted text is important feature in HTML/XML context, we can try to reuse proc_macro2::Span::join.

Proposal:
Implement temporary workaround that will use proc_macro2 fallback implementation directly.

Parse two times:
One with regular TokenStream, and with correct unjoined Span.
And second time with fallback::TokenStream created from Span::call_site().source_text().

Both parse phases should return same Node tree, but with different Spans.
Use second Node tree to recover source_text of RawText.

Cons:

  • Parse two time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions