3 ms·
> Which is fine if the file is something that's only ever meant to be parsed by scripts, but the whole point of markdown is that people read it! Nobody is runn
by bastawhiz 2y ago
> Which is fine if the file is something that's only ever meant to be parsed by scripts, but the whole point of markdown is that people read it!
Nobody is running prettier on their code or markup for the benefit of the computer. If it's not readable, it's just a bad formatting tool (or wasn't configured properly). The whole point of a formatter is to make it easier to read.
- Shog9 2y agoPretty much the only benefit I've seen of running prettier on Markdown is to highlight mistakes in formatting that otherwise wouldn't be apparent without viewing rendered output (which it highlights mostly by trashing the file in some fairly obvious way). The stated philosophy behind Prettier is to end arguments within a team about how to format code, which... Given Markdown is already heavily constrained, barely applies; unlike other languages supported by Prettier, there are precious few adjustments made to Markdown that are clearly intentionally made in pursuit of consistent readability - indeed, if I recall correctly the Prettier Markdown engine is mostly just a round-trip through the remark.js parser and stringifier, and the results reflect this - the results look mechanical, and it is just as likely to eliminate whitespace that lends clarity as it is to add it (if not, as the GP suggests, more likely). Sadly, there are remark.js plugins that could have been used to e.g. enforce consistent use of whitespace without stripping everything down to the bare minimum, but last I looked the Prettier folk were pretty hostile toward any suggestions that their (default, bare-minimum-effort) "style" was at all problematic.
- fenomas 2y agoPrettier disagrees, as I understand it. Its authors know it's "wrong" to take this: const matrix = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, ] and collapse it onto one line. But their view is that reformatting everything from scratch is more important that such things, and that it's reasonable to add /* ignore */ comments to every single place where you want anything preserved.