mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-01 22:47:25 -04:00
Reflow text in paragraph, strip line-breaks and utilize the available width
This commit is contained in:
@@ -9,7 +9,7 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.10
|
||||
github.com/mattn/go-runewidth v0.0.7
|
||||
github.com/microcosm-cc/bluemonday v1.0.2
|
||||
github.com/muesli/reflow v0.0.0-20191205093112-d357691d258b
|
||||
github.com/muesli/reflow v0.0.0-20191205210016-363f169defe8
|
||||
github.com/olekukonko/tablewriter v0.0.3
|
||||
github.com/rakyll/statik v0.1.6
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
|
||||
@@ -62,6 +62,10 @@ github.com/muesli/reflow v0.0.0-20191128051140-93fa6301a46e h1:9UdJp/6YtIpyJZISK
|
||||
github.com/muesli/reflow v0.0.0-20191128051140-93fa6301a46e/go.mod h1:ElDHwEb2eq5uzeCdCvT9KyrqcAfLcQg7VCL7r7JXdcc=
|
||||
github.com/muesli/reflow v0.0.0-20191205093112-d357691d258b h1:7iJQNEN0GksbYNXZKyaa6zdMIvX89wAeHJ9EnKRFgZg=
|
||||
github.com/muesli/reflow v0.0.0-20191205093112-d357691d258b/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
|
||||
github.com/muesli/reflow v0.0.0-20191205201805-1988755a7973 h1:JoaC7SAmUWU4ktck21kJQyFFCuUtZhoFr7gnC170la4=
|
||||
github.com/muesli/reflow v0.0.0-20191205201805-1988755a7973/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
|
||||
github.com/muesli/reflow v0.0.0-20191205210016-363f169defe8 h1:oxAi+9SI2+btEmUX6WttiY4n5wjH79Jy88SgVrcnlCw=
|
||||
github.com/muesli/reflow v0.0.0-20191205210016-363f169defe8/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
|
||||
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E=
|
||||
github.com/olekukonko/tablewriter v0.0.3 h1:i0LBnzgiChAWHJYTQAZJDOgf8MNxAVYZJ2m63SIDimI=
|
||||
github.com/olekukonko/tablewriter v0.0.3/go.mod h1:YZeBtGzYYEsCHp2LST/u/0NDwGkRoBtmn1cIWCJiS6M=
|
||||
|
||||
@@ -58,7 +58,7 @@ func (e *ListElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer) error
|
||||
},
|
||||
}
|
||||
|
||||
_, err := iw.Write(reflow.ReflowBytes(tr.blockStack.Current().Block.Bytes(), tr.WordWrap-int(tr.blockStack.Indent())-int(tr.blockStack.Margin())*2))
|
||||
_, err := iw.Write(reflow.Bytes(tr.blockStack.Current().Block.Bytes(), tr.WordWrap-int(tr.blockStack.Indent())-int(tr.blockStack.Margin())*2))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+6
-1
@@ -69,7 +69,12 @@ func (e *ParagraphElement) Finish(w io.Writer, node *bf.Node, tr *TermRenderer)
|
||||
}
|
||||
|
||||
if len(strings.TrimSpace(tr.blockStack.Current().Block.String())) > 0 {
|
||||
_, err := iw.Write(reflow.ReflowBytes(tr.blockStack.Current().Block.Bytes(), tr.WordWrap-int(tr.blockStack.Indent())-int(tr.blockStack.Margin())*2))
|
||||
flow := reflow.NewReflow(tr.WordWrap - int(tr.blockStack.Indent()) - int(tr.blockStack.Margin())*2)
|
||||
flow.KeepNewlines = false
|
||||
_, _ = flow.Write(tr.blockStack.Current().Block.Bytes())
|
||||
flow.Close()
|
||||
|
||||
_, err := iw.Write(flow.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user