diff --git a/src/Grafoscopio/GrafoscopioNode.class.st b/src/Grafoscopio/GrafoscopioNode.class.st
index bfadf2c..21a9a5f 100644
--- a/src/Grafoscopio/GrafoscopioNode.class.st
+++ b/src/Grafoscopio/GrafoscopioNode.class.st
@@ -203,58 +203,6 @@ GrafoscopioNode >> asStonFromRoot [
]
-{ #category : #initialization }
-GrafoscopioNode >> becomeDefaultTestTree [
- | node1 node2 node3 node4 |
- self
- created: DateAndTime now printString;
- header: 'Arbol principal'.
- node1 := self class new
- created: DateAndTime now printString;
- header: 'Markup';
- body: 'I am just a node with markup';
- tagAs: 'text';
- links: 'temp.md'.
- node2 := self class new
- created: DateAndTime now printString;
- header: '%output Code';
- tagAs: 'código';
- body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'.
- node3 := self class new
- created: DateAndTime now printString;
- header: '%invisible';
- tagAs: 'text';
- body: 'Just testing'.
- node1 addNode: node3.
- node4 := self class new
- created: DateAndTime now printString;
- header: 'Something';
- tagAs: 'text';
- body: '
else
'.
- node1 addNode: node4.
- node1 addNode: node2.
- self
- addNode: node1.
-]
-
-{ #category : #initialization }
-GrafoscopioNode >> becomeDefaultTree [
- "I create a starting tree for all Grafoscopio notebooks with just one textual node as child."
- | node1 |
- self class new.
- self
- created: DateAndTime now printString;
- header: 'Arbol principal';
- tagAs: 'código'.
- node1 := self class new
- created: DateAndTime now printString;
- header: 'Node 1';
- body: '';
- tagAs: 'text'.
- self addNode: node1.
- ^ self
-]
-
{ #category : #accessing }
GrafoscopioNode >> body [
"Returns the receivers body"
@@ -1271,15 +1219,25 @@ GrafoscopioNode >> visitedGoTo: aCollection [
{ #category : #'as yet unclassified' }
GrafoscopioNode >> wrapBodyLines [
- "I convert the node body from HTML format to Pandoc's Markdown."
- | bodyFile |
- (self isTaggedAs: 'código' ) ifTrue: [ ^self ].
- bodyFile := FileLocator temp asFileReference / 'body.txt'.
- bodyFile ensureCreateFile.
- bodyFile writeStreamDo: [:out | out nextPutAll: self body ].
- Smalltalk platformName = 'unix'
- ifTrue: [ self body: (self wrapBodyLinesFor: bodyFile) ].
- Smalltalk platformName = 'Win32'
- ifTrue: [ self shouldBeImplemented ].
- bodyFile ensureDelete.
+ "I convert the node body from HTML format to Pandoc's Markdown."
+
+ self wrapBodyLines: 80
+]
+
+{ #category : #'as yet unclassified' }
+GrafoscopioNode >> wrapBodyLines: aWidth [
+ "I convert the node body from HTML format to Pandoc's Markdown."
+
+ | bodyReader chunck |
+ (self isTaggedAs: 'código')
+ ifTrue: [ ^ self ].
+ bodyReader := body readStream.
+ body := String
+ streamContents: [ :bodyWriter |
+ [ bodyReader atEnd ]
+ whileFalse: [
+ chunck := bodyReader next: aWidth - 1.
+ bodyWriter nextPutAll: chunck.
+ bodyReader atEnd
+ ifFalse: [ bodyWriter nextPut: Character lf ] ] ]
]
diff --git a/src/Grafoscopio/GrafoscopioNodeTest.class.st b/src/Grafoscopio/GrafoscopioNodeTest.class.st
index 7c6ff65..63dca0b 100644
--- a/src/Grafoscopio/GrafoscopioNodeTest.class.st
+++ b/src/Grafoscopio/GrafoscopioNodeTest.class.st
@@ -16,10 +16,44 @@ GrafoscopioNodeTest >> dummyHtml [
^ txt
]
+{ #category : #tests }
+GrafoscopioNodeTest >> newTestTree [
+ | node0 node1 node2 node3 node4 |
+ node0 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: 'Arbol principal'.
+ node1 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: 'Markup';
+ body: 'I am just a node with markup';
+ tagAs: 'text';
+ links: 'temp.md'.
+ node2 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: '%output Code';
+ tagAs: 'código';
+ body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'.
+ node3 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: '%invisible';
+ tagAs: 'text';
+ body: 'Just testing'.
+ node1 addNode: node3.
+ node4 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: 'Something';
+ tagAs: 'text';
+ body: 'else
'.
+ node1 addNode: node4.
+ node1 addNode: node2.
+ node0 addNode: node1.
+ ^ node0
+]
+
{ #category : #tests }
GrafoscopioNodeTest >> testAddingChildren [
| tree nnode orig |
- tree := GrafoscopioNode new becomeDefaultTestTree.
+ tree := self newTestTree.
nnode := GrafoscopioNode new.
orig := tree children size.
tree addNode: nnode.
@@ -59,7 +93,7 @@ GrafoscopioNodeTest >> testHasMarkdownSubtreesToExport [
result of this test is true.
Please see look #becomeDefaultTestTree message to see the details that makes this test true."
| tree |
- tree := GrafoscopioNode new becomeDefaultTestTree.
+ tree := self newTestTree.
self assert: tree selectMarkupSubtreesToExport isNotEmpty equals: true.
]
@@ -72,7 +106,7 @@ GrafoscopioNodeTest >> testInitializeIsOk [
{ #category : #tests }
GrafoscopioNodeTest >> testNodeSelection [
| tree child1 |
- tree := GrafoscopioNode new becomeDefaultTestTree.
+ tree := self newTestTree..
child1 := tree preorderTraversalRootChildren at: 1.
child1 selected: true.
self assert: tree detectSelectionIndex equals: 1
@@ -130,7 +164,7 @@ var links = tree.links(nodes);
{ #category : #tests }
GrafoscopioNodeTest >> testRemovingChildren [
| tree orig |
- tree := GrafoscopioNode new becomeDefaultTestTree.
+ tree := self newTestTree..
orig := tree children size.
orig > 0 ifTrue: [ tree removeNode: (tree children at: 1) ].
self assert: tree children size equals: orig - 1.
@@ -152,7 +186,7 @@ GrafoscopioNodeTest >> testToggleNodeSelection [
"I verify that a selected node can be unchosen once a new selection has been done."
| tree testNode1 testNode2 |
- tree := GrafoscopioNode new becomeDefaultTestTree.
+ tree := self newTestTree..
testNode1 := (tree preorderTraversalRootChildren at: 1) selected: true.
self assert: tree detectSelectionIndex equals: testNode1 preorderTraversalIndex.
testNode2 := (tree preorderTraversalRootChildren at: 2).
diff --git a/src/Grafoscopio/GrafoscopioNotebook.class.st b/src/Grafoscopio/GrafoscopioNotebook.class.st
index edfa7b9..9a597a8 100644
--- a/src/Grafoscopio/GrafoscopioNotebook.class.st
+++ b/src/Grafoscopio/GrafoscopioNotebook.class.st
@@ -154,6 +154,22 @@ GrafoscopioNotebook >> copyNodeToClipboard [
self notebookContent: notebook.
]
+{ #category : #persistence }
+GrafoscopioNotebook >> createNewExample [
+ | node0 node1 |
+ node0 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: 'Arbol principal';
+ tagAs: 'código'.
+ node1 := GrafoscopioNode new
+ created: DateAndTime now printString;
+ header: 'Node 1';
+ body: '';
+ tagAs: 'text'.
+ node0 addNode: node1.
+ ^ node0
+]
+
{ #category : #operation }
GrafoscopioNotebook >> currentNode [
| currentNode |
@@ -468,22 +484,12 @@ GrafoscopioNotebook >> importLinkContent [
GrafoscopioNotebook >> initialize [
super initialize.
self
- notebook: (GrafoscopioNode new becomeDefaultTree);
+ notebook: (self createNewExample );
title: ' New | Grafoscopio notebook'.
self notebookContent: self notebook.
]
-{ #category : #initialization }
-GrafoscopioNotebook >> initializeDefaultTest [
- super initialize.
- self
- notebook: (GrafoscopioNode new becomeDefaultTestTree);
- title: ' New test | Grafoscopio notebook'.
- self notebookContent: self notebook.
-
-]
-
{ #category : #initialization }
GrafoscopioNotebook >> initializePresenter [
tree whenHighlightedItemChanged: [ :item |