Flatten nodes at least!!! Now we have small files for grafoscopio notebooks. The start of a DVCS friendly grafoscopio notebook format :-). This should be reflected in the grafoscopio Docs folder of the fossil repo at http://mutabit.com/repos.fossil/grafoscopio/ after commit [6440630201]

This commit is contained in:
Offray Vladimir Luna Cárdenas 2016-03-23 21:20:35 +00:00
parent a6bf43ab04
commit 4d835b3f58
2 changed files with 27 additions and 12 deletions

View File

@ -204,7 +204,7 @@ GrafoscopioBrowser class >> openFromRecentlyUsed [
] ]
{ #category : #'as yet unclassified' } { #category : #'graphical interface' }
GrafoscopioBrowser class >> openHelpInHtml [ GrafoscopioBrowser class >> openHelpInHtml [
"Launches the help manual in PDF format in an external viewer." "Launches the help manual in PDF format in an external viewer."
@ -219,7 +219,7 @@ GrafoscopioBrowser class >> openHelpInHtml [
] ]
{ #category : #'as yet unclassified' } { #category : #'graphical interface' }
GrafoscopioBrowser class >> openHelpInPdf [ GrafoscopioBrowser class >> openHelpInPdf [
"Launches the help manual in PDF format in an external viewer." "Launches the help manual in PDF format in an external viewer."
@ -233,7 +233,7 @@ GrafoscopioBrowser class >> openHelpInPdf [
ifTrue: [OSProcess command: 'open ', pdfHelpFileLocation]. ifTrue: [OSProcess command: 'open ', pdfHelpFileLocation].
] ]
{ #category : #'as yet unclassified' } { #category : #configuration }
GrafoscopioBrowser class >> showSettings [ GrafoscopioBrowser class >> showSettings [
"Shows the settings in a Transcript. This should return a dictionary for better management of the settings. For the moment "Shows the settings in a Transcript. This should return a dictionary for better management of the settings. For the moment
is a quick a dirty hack" is a quick a dirty hack"
@ -745,7 +745,6 @@ GrafoscopioBrowser >> exportAsHtml [
{ #category : #persistence } { #category : #persistence }
GrafoscopioBrowser >> exportAsMarkdown: aTree on: locator [ GrafoscopioBrowser >> exportAsMarkdown: aTree on: locator [
locator writeStreamDo: [:stream | stream nextPutAll: aTree asMarkdown] locator writeStreamDo: [:stream | stream nextPutAll: aTree asMarkdown]
] ]
@ -774,7 +773,7 @@ GrafoscopioBrowser >> exportAsPdf [
{ #category : #persistence } { #category : #persistence }
GrafoscopioBrowser >> exportAsSton: aTree on: locator [ GrafoscopioBrowser >> exportAsSton: aTree on: locator [
aTree flatten.
locator nextPutAll: (STON toStringPretty: aTree children) locator nextPutAll: (STON toStringPretty: aTree children)
] ]
@ -1007,6 +1006,7 @@ GrafoscopioBrowser >> saveToFile: aFileReference [
writeStream := file writeStream. writeStream := file writeStream.
workingFile := writeStream name asFileReference. workingFile := writeStream name asFileReference.
markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown'). markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown').
markdownFile ensureCreateFile.
[ self exportAsSton: mainTree on: writeStream. [ self exportAsSton: mainTree on: writeStream.
self exportAsMarkdown: mainTree on: markdownFile ] self exportAsMarkdown: mainTree on: markdownFile ]
ensure: [ writeStream ifNotNil: #close ]. ensure: [ writeStream ifNotNil: #close ].
@ -1036,13 +1036,15 @@ GrafoscopioBrowser >> saveToFileUI [
GrafoscopioBrowser >> saveWorkingTree [ GrafoscopioBrowser >> saveWorkingTree [
"Saves the current tree to the user predefined file location used when he/she opened it." "Saves the current tree to the user predefined file location used when he/she opened it."
| fileStream markdownFile | | markdownFile |
fileStream := workingFile writeStream.
markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown'). markdownFile := (workingFile parent) / (workingFile basenameWithoutExtension, '.markdown').
[ self exportAsSton: mainTree on: fileStream. markdownFile exists ifTrue: [ markdownFile delete ].
self exportAsMarkdown: mainTree on: markdownFile ] markdownFile ensureCreateFile.
ensure: [ fileStream ifNotNil: #close.]. workingFile exists ifTrue: [ workingFile delete ].
"self customKeys." workingFile ensureCreateFile.
[ self exportAsSton: mainTree on: (workingFile writeStream).
self exportAsMarkdown: mainTree on: markdownFile
] ensure: [ (workingFile writeStream) ifNotNil: #close.].
self inform: 'Archivo guardado como: ', workingFile asString. self inform: 'Archivo guardado como: ', workingFile asString.
] ]

View File

@ -121,7 +121,8 @@ GrafoscopioNode >> ancestorsHeaders [
{ #category : #exporting } { #category : #exporting }
GrafoscopioNode >> asMarkdown [ GrafoscopioNode >> asMarkdown [
"Exports children of the current node as pandoc markdown, using special nodes accoding to tags" "I export children of the current node as pandoc markdown, using special nodes accoding to tags.
Early version... tags processing should be vastly improved"
| markdownOutput | | markdownOutput |
markdownOutput := '' writeStream. markdownOutput := '' writeStream.
@ -140,6 +141,7 @@ GrafoscopioNode >> asSton [
| stonOutput | | stonOutput |
stonOutput := '' writeStream. stonOutput := '' writeStream.
self flatten.
stonOutput nextPutAll: (STON toStringPretty: self children). stonOutput nextPutAll: (STON toStringPretty: self children).
^stonOutput contents ^stonOutput contents
@ -233,6 +235,17 @@ GrafoscopioNode >> demote [
] ]
{ #category : #exporting }
GrafoscopioNode >> flatten [
"I traverse the tree looking for node bodies containing 'Text' objects and transform them to
their string content, so space is saved and storage format is DVCS friendly while serializing them to STON"
(self preorderTraversal) do: [ :eachNode |
(eachNode body class = Text)
ifTrue: [eachNode body: (eachNode body asString)]
]
]
{ #category : #exporting } { #category : #exporting }
GrafoscopioNode >> hasAncestorHeaderWith: aSpecialWord [ GrafoscopioNode >> hasAncestorHeaderWith: aSpecialWord [
"Looks if the receptor node has an ancestor with a header with 'aSpecialWord' as the only or the first word" "Looks if the receptor node has an ancestor with a header with 'aSpecialWord' as the only or the first word"