Skip to content

Commit

Permalink
writing line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Jun 9, 2020
1 parent 6e3e4ae commit 8a2c8a9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions repository/OP-XMI/OPXMIWriterVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Class {
#instVars : [
'writer'
],
#category : 'OP-XMI-Writer'
#category : #'OP-XMI-Writer'
}

{ #category : #accessing }
Expand All @@ -16,7 +16,8 @@ OPXMIWriterVisitor >> contents [
OPXMIWriterVisitor >> initialize [
super initialize.
writer := XMLWriter new.
writer enablePrettyPrinting.
writer formatter: OPXMLPrettyPrintingWriterFormatter new.
writer lineBreak: '
'.
writer xml encoding: 'UTF-8'
]

Expand Down
27 changes: 27 additions & 0 deletions repository/OP-XMI/OPXMLPrettyPrintingWriterFormatter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Class {
#name : #OPXMLPrettyPrintingWriterFormatter,
#superclass : #XMLPrettyPrintingWriterFormatter,
#instVars : [
'lineBreak'
],
#category : #'OP-XMI-Writer'
}

{ #category : #writing }
OPXMLPrettyPrintingWriterFormatter >> lineBreak: aCharacterOrString [
lineBreak := aCharacterOrString asString
]

{ #category : #writing }
OPXMLPrettyPrintingWriterFormatter >> writeLineBreak [
self writer atBeginning
ifFalse: [ self writer nextPutAll: lineBreak.
(self currentIndentLevel > 0 and: [ self indentString size > 0 ])
ifTrue: [ self writeIndent ] ]
]

{ #category : #writing }
OPXMLPrettyPrintingWriterFormatter >> writer: aWriter [
super writer: aWriter.
lineBreak ifNil: [ lineBreak := aWriter lineBreak ]
]

0 comments on commit 8a2c8a9

Please sign in to comment.