Skip to content

feat: add printer.preprocess#5041

Merged
ikatyang merged 9 commits intoprettier:masterfrom
ikatyang:feat/printer-preprocess
Sep 3, 2018
Merged

feat: add printer.preprocess#5041
ikatyang merged 9 commits intoprettier:masterfrom
ikatyang:feat/printer-preprocess

Conversation

@ikatyang
Copy link
Copy Markdown
Member

@ikatyang ikatyang commented Sep 1, 2018

Sometimes we need to transform the ast to make it easier to print, but it's currently done in the parser (markdown and yaml), which leads the output ast harder to use for external users (custom parser), adding printer.preprocess can solve this issue.

And also this way we could move the trailing newline for json from ast-to-doc.js to language-js.


  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.

@suchipi
Copy link
Copy Markdown
Member

suchipi commented Sep 1, 2018

When a user uses a custom parser function, do we call preprocess before or after their function?

@ikatyang
Copy link
Copy Markdown
Member Author

ikatyang commented Sep 1, 2018

text -> parser.preprocess -> parser (custom parser) -> printer.preprocess -> printer

@ikatyang ikatyang merged commit 50c9115 into prettier:master Sep 3, 2018
@ikatyang ikatyang deleted the feat/printer-preprocess branch September 3, 2018 15:27
@ikatyang ikatyang added this to the 1.15 milestone Oct 25, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants