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

Range rewrite #47

Open
Enter-tainer opened this issue Apr 6, 2024 · 3 comments
Open

Range rewrite #47

Enter-tainer opened this issue Apr 6, 2024 · 3 comments

Comments

@Enter-tainer
Copy link
Owner

Enter-tainer commented Apr 6, 2024

Add an optional arg to current interface to perform certain action on source code ranges.

fn pretty_print(content: &str, width: usize, actions: Vec<(start, end, RewriteAction)>)

, where action is an enum defined in typstyle. It can be ToMultiline, ToSingleLine, ToBlockEquation, ToInlineEquation, NoFormat...

typstyle will find the first ast node(in order traversal) which is contained by the provided range.

When certain action is not applicable, it will be sliently ignored

@Myriad-Dreamin
Copy link
Collaborator

a builder/worker style may be more flexible, like std::process::Command.

@Enter-tainer
Copy link
Owner Author

Enter-tainer commented Apr 7, 2024

a builder/worker style may be more flexible, like std::process::Command.

Do you mean a PrettyPrinterBuilder? It's Ok for me. Like

PrettyPrinterBuilder::new()
  .with_column_width(..)
  .with_content(...)
  .with_actions(...)
  .format()

@Myriad-Dreamin
Copy link
Collaborator

It could be less flexible:

PrettyPrinterBuilder::new(column_width or config)
  .with_actions(...)
  .format(content)

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

No branches or pull requests

2 participants