diff options
Diffstat (limited to 'cnmfmt')
-rw-r--r-- | cnmfmt/cnmfmt.go | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/cnmfmt/cnmfmt.go b/cnmfmt/cnmfmt.go index cb8dc64..fa2ec65 100644 --- a/cnmfmt/cnmfmt.go +++ b/cnmfmt/cnmfmt.go @@ -199,7 +199,7 @@ func (t Text) WriteIndent(w io.Writer, n int) error { si = cleanupTags(state[:], order, span.Format) format = span.Format } - return writeIndent(w, strings.Join(line, ""), n) + return cnm.WriteIndent(w, strings.Join(line, ""), n) } func tagOrder(state []byte, old, new Format) []byte { @@ -430,7 +430,7 @@ func NewTextFmtBlock(paragraphs []Text) *cnm.TextBlock { func (tf TextFmtContents) WriteIndent(w io.Writer, n int) error { for i, p := range tf.Paragraphs { if i != 0 { - if err := writeIndent(w, "", 0); err != nil { + if err := cnm.WriteIndent(w, "", 0); err != nil { return err } } @@ -469,29 +469,6 @@ func Parse(paragraphs string) []Text { return txt } -func writeIndent(w io.Writer, s string, depth int) error { - const tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" - - if s == "" { - _, err := w.Write([]byte{'\n'}) - return err - } - if depth == 0 { - _, err := w.Write([]byte(s + "\n")) - return err - } - - var ind string - if depth <= len(tabs) { - ind = tabs[:depth] - } else { - ind = strings.Repeat("\t", depth) - } - _, err := w.Write([]byte(ind + s + "\n")) - return err - -} - func parseTextFmt(p *cnm.Parser, block *cnm.TokenBlock) (cnm.TextContents, error) { txt := TextFmtContents{} var paragraph []string |