Closed nicholasmordecai closed 1 year ago
Im not the developer but I wouldn't recommend implmenting a feature like this as there are many scenarios whereby this would incorrectly split, for example
var a =1; var b = 2;
), which is ugly, but possibly how it appears in the codebase;
.. fmt.Println(hello; how; are; you;
There would be other edge cases too
Just my 2 cents
I agree with @geerew. I think that code formatting is beyond the scope of this library.
I would recommend looking at Prettier to format code, which can run in both Node and the browser.
Note that using Prettier in the browser will increase the JS bundle size by a significant amount; I wrote a Svelte preprocessor that both formats and highlights code in Node.js to avoid the runtime costs of shipping both highlight.js
and prettier
.
Not sure if this is even possible with highlight.js, but is there any way to automatically format code? For example:
Produces:
Produces:
But I have a unique use case where it would be advantageous for it to look like this:
I was able to achieve this by using a new line string:
But it's a little clunky.
Maybe I'm asking for the earth and this is far out of the scope of highlight.js / svelte-highlight but was wondering if you knew if this was possible?
Cheers