mdox
mdox copied to clipboard
Formatting creates 'white noise' in some cases
I have noticed this in the Thanos repository, take a look at this file's diff for example (the old version is formatted with mdox, the new version removes extra white noise based on an additional script):
https://github.com/thanos-io/thanos/pull/4662/files#diff-59764a4da653d4464eac20465390033ab8abbd8b54688979727065cb389e848d
mdox fmt seem to actually add white spaces where they are not necessary, such as some end of lines. Is this an issue or is this something that is dictated by the GFM or other convention?
Seems like the whitespaces are in code blocks. This might be due to how we process the command output here.
I tried to replicate this with the code below and this output also has the same whitespaces as in docs/components/compact.md in Thanos,
package main
import (
"bytes"
"os"
"os/exec"
)
func main() {
b := bytes.Buffer{}
c := exec.Command("thanos", "compact", "--help")
c.Stdout = &b
c.Stderr = &b
c.Run()
f, _ := os.OpenFile("output.md", os.O_RDWR|os.O_CREATE, 0755)
f.Write(b.Bytes())
}
This possibly isn't due to markdown processing or GFM spec, but how we handle command output. Need to look into this more. 🤔
Just FYI, noticed today this happens in code blocks with lines, which are 'overflowing' into the parameter description column. See this screenshot from compact.md as an example:

Compare line 305 with other lines, where the parameter name is too long. This causes the description to be moved to the next line and there are 2 extra spaces added at the end of the line.