prettier-browser-extension icon indicating copy to clipboard operation
prettier-browser-extension copied to clipboard

Generic text box support

Open nickserv opened this issue 6 years ago • 5 comments

Other extensions like prettier-js-extension allow any text box to be used for formatting, which would help make this extension more useful with less code changes. I still think some of the functionality and UI specific to GitHub and Stack Overflow could be useful though.

nickserv avatar Oct 11 '19 00:10 nickserv

Yes, when you clicking on the Prettier button from the toolbar, and if the focus is inside a textarea it should probably format it.

lipis avatar Oct 11 '19 15:10 lipis

Out of curiosity, how do we want to handle detecting the parser? Just naively assume it's Markdown? I wonder if the we could have a dropdown list when clicking the Prettier button in the toolbar that says Format as... and then has a list of langs we're supporting?

kaicataldo avatar Oct 15 '19 02:10 kaicataldo

Good question, maybe we could use a language detection library and fall back to Markdown when it's unknown or looks like snippets from multiple languages.

nickserv avatar Oct 15 '19 03:10 nickserv

Ohhh I like that idea :)

kaicataldo avatar Oct 15 '19 04:10 kaicataldo

Some resources for language detection:

  • https://prettier.io/docs/en/api.html#prettiergetsupportinfo-version
  • https://highlightjs.readthedocs.io/en/latest/api.html#highlightauto-value-languagesubset
  • https://www.npmjs.com/package/language-map
  • https://www.npmjs.com/package/language-detect

nickserv avatar Nov 17 '19 04:11 nickserv