Closed mtsknn closed 1 year ago
If you have pandoc, you can already do this kind of reformatting by using the custom lua reader/writer supplied in this repository.
$ pandoc -f djot-reader.lua -t djot-writer.lua
1. This is a
list item.
> This is a block
quote.
```js
const
foo =
'bar' ;
Result:
This is a block quote.
const
foo =
'bar' ;
Note: you defiintely don't want line breaks to be changed in a code block, as in your example, since that changes the semantics.
That said, it would be nice to have a native djot renderer built in.
Oh I see, I suppose the prettier formatter will pass javascript code through a javascript code formatter? Well, that can certainly be done with djot using filters. More documentation on that coming later.
If you have pandoc, you can already do this kind of reformatting by using the custom lua reader/writer supplied in this repository.
Nice. Is there a way to preserve line breaks (in prose)? I like Semantic Line Breaks, but the example you provided breaks that.
Oh I see, I suppose the prettier formatter will pass javascript code through a javascript code formatter?
Exactly. Looks like I failed to articulate that.
Well, that can certainly be done with djot using filters. More documentation on that coming later.
Nice. I'll repeat one point from my previous comment now that we are on the same page regarding code formatting:
It could be nice if one could configure what code formatters the Djot formatter should use. E.g. Go code blocks could be configured to be formatted with gofmt, and JavaScript code blocks with Prettier or
deno fmt
. This would be better than Prettier + Markdown as Prettier supports only a few languages.
Nice. Is there a way to preserve line breaks (in prose)?
I suppose #108 (i.e. supporting a concrete syntax tree) might be able to address this use case.
We already have softbreak elements in the AST, so we have everything we need to preserve the original line breaks.
Closing this in favor of #135
Not sure if this is in the scope of this project/repo, but here goes:
Prettier is essential for me when authoring Markdown, so I'd very much like a Djot formatter. Maybe not yet, considering that Djot is still evolving, but eventually.
Benefits:
Some things to format off the top of my head:
>
's to quote blocksdeno fmt
. This would be better than Prettier + Markdown as Prettier supports only a few languages.Example:
Before:
After: