Conversation
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
bwplotka
left a comment
There was a problem hiding this comment.
Nice, some nits only, otherwise LGTM!
main.go
Outdated
| write = flag.Bool("w", false, "write result to (source) file instead of stdout") | ||
| doDiff = flag.Bool("d", false, "display diffs instead of rewriting files") | ||
| underlineHeadings = flag.Bool("u", false, "write underline headings instead of hashes for levels 1 and 2") | ||
| hardWraps = flag.Bool("h", false, "hard wrap lines even on soft line breaks") |
There was a problem hiding this comment.
I would not add as h - it's usually used for help. Let's use just hard-wraps? ;p
| _, _ = r.w.Write(spaceChar) | ||
| char := spaceChar | ||
| if r.mr.hardWraps { | ||
| char = newLineChar |
main.go
Outdated
| opts = append(opts, markdown.WithUnderlineHeadings()) | ||
| } | ||
| if *hardWraps { | ||
| opts = append(opts, markdown.WithHardWraps()) |
There was a problem hiding this comment.
I think another 3rd option here would be to automatically change it to X chars wide. We can add that later, but wonder if this option would conflict. e.g if someone will use WithHardWraps and WithMaxLineWidth(80)
There was a problem hiding this comment.
Yes, it can be added later! I think a check might be needed for the conflict between them. Also, word wrapping needs to be implemented for this in a way(something like this) so that there are no formatting surprises! 🙂
markdown/renderer.go
Outdated
| } | ||
| } | ||
|
|
||
| func WithHardWraps() Option { |
There was a problem hiding this comment.
Can we add comment?
Also ... technically we talk about soft wraps, no?
| func WithHardWraps() Option { | |
| func WithSoftWraps() Option { |
There was a problem hiding this comment.
Sure! Will add a comment and rename it! So everything hardWrap -> softWrap.
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
This PR adds
WithHardWrapoption, which when enabled preserves soft line breaks. Addresses #29.Feedback is needed on whether this could be done via line widths, in which case some sort of word wrapping is needed and which might lead to further issues as it would override both hard and soft line breaks.
cc: @bwplotka