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

Fill out more formatting functionality #147

Merged
merged 22 commits into from
Jun 13, 2023
Merged

Conversation

KodrAus
Copy link
Collaborator

@KodrAus KodrAus commented May 31, 2023

Current PR:

This PR adds more functionality to our sval_fmt::TokenWrite trait so that it gives more fidelity for customizing formatting. There are some examples in the tests that may make their way into first-class adapters at some point that do compact formatting and indented formatting.

In the end I wasn't really satisfied with how tagging for text fragments came out, so I reverted it and just kept the improvements to TokenWrite and testing that came along with it.


Original PR:

This PR implements two new methods for working with text:

  • tagged_text_fragment(tag: &Tag, fragment: &'sval str)
  • tagged_text_fragment_computed(tag: &Tag, fragment: &str)

These make it possible to use tags for tokenizing text without changing the representation. Since each fragment can only have a single tag it's a fairly limited system, but capable enough to support things like syntax highlighting or optional formatting.

@KodrAus
Copy link
Collaborator Author

KodrAus commented May 31, 2023

I've also made the Computed stream adapter public, since it's a useful way to get yourself a Stream<'b> from any Stream<'a> to avoid duplicating logic when you may or may not have data satisfying 'a.

@KodrAus KodrAus marked this pull request as ready for review June 12, 2023 22:10
@KodrAus KodrAus changed the title Support tagging text fragments Fill out more formatting functionality Jun 12, 2023
@KodrAus KodrAus merged commit 6416f61 into main Jun 13, 2023
50 checks passed
@KodrAus KodrAus deleted the feat/tagged-text-fragments branch June 13, 2023 05:22
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.

None yet

1 participant