Impleting find and replace.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-09-09 17:54:25 +00:00
parent 973d6c2c76
commit 9b91900dda
2 changed files with 16 additions and 0 deletions

View File

@ -420,6 +420,12 @@ GrafoscopioNode >> exportPreambleTo: aStream [
aStream nextPutAll: 'abstract: ', '|'; lf; nextPutAll: (configDict at: 'abstract'); lf] aStream nextPutAll: 'abstract: ', '|'; lf; nextPutAll: (configDict at: 'abstract'); lf]
] ]
{ #category : #utility }
GrafoscopioNode >> find: aString andReplaceWith: anotherString [
anotherString ifNil: [ ^ self ].
self body: ((self body) copyReplaceAll: aString with: anotherString)
]
{ #category : #exporting } { #category : #exporting }
GrafoscopioNode >> flatten [ GrafoscopioNode >> flatten [
"I traverse the tree looking for node bodies containing 'Text' objects and transform them to "I traverse the tree looking for node bodies containing 'Text' objects and transform them to

View File

@ -33,6 +33,16 @@ GrafoscopioNodeTest >> testDemoteNode [
] ]
{ #category : #tests }
GrafoscopioNodeTest >> testFindAndReplace [
| tree |
tree := GrafoscopioNode new.
tree body: 'I''m only a test node.'.
tree find: 'only' andReplaceWith: 'JUST'.
self assert: (tree body findString: 'JUST') > 0.
]
{ #category : #tests } { #category : #tests }
GrafoscopioNodeTest >> testHasMarkdownSubtreesToExport [ GrafoscopioNodeTest >> testHasMarkdownSubtreesToExport [
"Because becomeDefaultTestTree contains at least one non empty 'links' object that "Because becomeDefaultTestTree contains at least one non empty 'links' object that