Fork me on GitHub
#off-topic
<
2023-02-09
>
skylize17:02:01

For "Snippets" saved in the Sources panel of Chromium-based Dev Tools, running the snippet prints the (synchronous) evaluation of the final expression of the snippet onto the console. Cool. If this output is a string it easily distinguished from console.logs because it prints colorized and wrapped in a pair of single-quotes. (In dark mode its a nice cyan/teal. In light mode, a less helpful slightly-darkened red that is hard to distinguish from error logs.) Cool. Seems this uses a non-standard string printer that fails to parse newline escape-seqs into newline chars. A string with \n prints that as \n. Same with \r\n. Same problem with this sorta-sketchy play at hand-typing a literal-newline.

// Leading semi here because I don't use trailing semis.
//  Breaks the backtick from code on previous line which
//  could otherwise be incorrectly interpreted.

;`
`
// => '\n'
Not cool. Anyone have any ideas on how to coerce this special string printer for Dev Tools Snippets into printing an actual newline char?