Skip to content

Commit

Permalink
Fixes go-yaml#166 - ability to disable multi line string outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Dragomir committed Dec 11, 2018
1 parent 51d6538 commit a3a9b42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,7 @@ func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_
e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style))
e.emit()
}

func (e *encoder) setWidth(width int) {
yaml_emitter_set_width(&e.emitter, width)
}
7 changes: 7 additions & 0 deletions yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ func NewEncoder(w io.Writer) *Encoder {
}
}

// SetLineWidth sets the preferred line width.
// To disable long line breaks set width lower than zero.
// By default, line width is set to 80.
func (e *Encoder) SetLineWidth(width int) {
e.encoder.setWidth(width)
}

// Encode writes the YAML encoding of v to the stream.
// If multiple items are encoded to the stream, the
// second and subsequent document will be preceded
Expand Down

0 comments on commit a3a9b42

Please sign in to comment.