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

Implement functional styled markup interpreter #43

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

tecosaur
Copy link
Collaborator

Introduces styled("{markup...}") as a complement to styled"{markup...}". In my opinion, this is a rather valuable addition, unlocking new use cases (such as the ability to handle untrusted markup without @eval), making StyledStrings more easily fuzz-able, and improving the modularity/design of the codebase.

Instead of having a monolithic ~600 line macro, we create a submodule
"StyledMarkup" and extract all of the inner functions of the macro into
top-level function of the submodule, creating a State type along the
way.

In my eyes, this is equivalent in terms of code organisation, but should
allow for a "functional" form of the styled"" macro with minimal
changes.
Now that we have reorganised the styled"" macro, we can take a shot at
implementing a functional variant of the macro.

This allows for annotation markup in plain strings (e.g. sourced from a
user), to be converted into styled AnnotatedStrings without the use of
`eval`, opening up new use cases.
@tecosaur tecosaur force-pushed the functional-styled-markup branch from e17130b to 10f6839 Compare March 13, 2024 15:56
@tecosaur
Copy link
Collaborator Author

If there are no objections/concerns raised, I intend to merge this early next week.

@tecosaur tecosaur merged commit 10f6839 into main Mar 18, 2024
6 checks passed
@tecosaur tecosaur deleted the functional-styled-markup branch March 18, 2024 04:19
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.

1 participant