Fixing preliminary support for outputs of code nodes inside the notebook. For the moment output is not stored in the notebook also, just invoked on demand using a %keyword.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-04-20 17:39:48 +00:00 committed by SantiagoBragagnolo
parent 82f2305881
commit e8824cf120
2 changed files with 30 additions and 8 deletions

View File

@ -380,7 +380,26 @@ GrafoscopioNode >> exportCodeBlockTo: aStream [
]
{ #category : #exporting }
GrafoscopioNode >> exportDecoratedCodeBlockTo: aStream [
GrafoscopioNode >> exportCodeNodeTo: aStream [
"I convert the content of a node taged as 'código' (code) as pandoc markdown and put it
into aStream."
(self headerStartsWith: '%output')
ifTrue: [ self exportCodeOutputTo: aStream ]
ifFalse: [ self exportCodeBlockTo: aStream ]
]
{ #category : #exporting }
GrafoscopioNode >> exportCodeOutputTo: aStream [
"I convert the output of a node taged as 'código' (code) as pandoc markdown and put it
into aStream."
aStream nextPutAll: ('~~~{.numberLines}'); lf.
aStream nextPutAll: ((Compiler evaluate: self body) asString withInternetLineEndings); lf.
aStream nextPutAll: ('~~~'); lf;lf.
^aStream contents
]
{ #category : #exporting }
GrafoscopioNode >> exportLaTeXCodeBlockTo: aStream [
"I convert the content of a node taged as 'código' (code) as pandoc markdown and put it
into aStream.
The code block is decorated with LaTeX commands for proper syntax highlighting using pygments.
@ -421,7 +440,8 @@ GrafoscopioNode >> footnoteAsMarkdownInto: aStream [
and replace all line endings to make them Internet friendly.
Maybe I should include the condition about my own header, instead of leaving it to markdownCotent..."
aStream nextPutAll: ('[^',(self header copyReplaceAll: '%footnote ' with: ''),']: ' ); lf.
self body contents withInternetLineEndings linesDo: [ :line | aStream nextPutAll: ' ', line; lf ].
self body contents withInternetLineEndings
linesDo: [ :line | aStream nextPutAll: ' ', line; lf ].
aStream nextPutAll: String lf.
]
@ -611,7 +631,7 @@ GrafoscopioNode >> markdownContent [
(self headerStartsWith: '%footnote')
ifTrue: [ self footnoteAsMarkdownInto: markdownStream ].
((self tags = 'código') and: [(self hasAncestorHeaderWith: '%invisible') not & (self headerStartsWith: '%embed') not ])
ifTrue: [ self exportCodeBlockTo: markdownStream ].
ifTrue: [ self exportCodeNodeTo: markdownStream ].
^ markdownStream contents
]
@ -702,10 +722,11 @@ GrafoscopioNode >> preorderTraversal [
^ nodesInPreorder.
]
{ #category : #'as yet unclassified' }
{ #category : #accessing }
GrafoscopioNode >> processOutput [
(self headerStartsWith: '%output')
ifTrue: [ self output: (Compiler evaluate: self body) ]
ifFalse: [ ^ self ].
^ self output: (Compiler evaluate: self body)
]
{ #category : #movement }

View File

@ -64,9 +64,9 @@ GrafoscopioNotebook >> autoSaveBodyOf: aNode [
playground := body body glmPres.
playground
onChangeOfPort: #text
act: [ :x | aNode body: x entity value content ];
act: [ :x | aNode body: x entity value content ]";
onChangeOfPort: #activePresentation
act: [ aNode output: aNode processOutput ]
act: [ aNode output: aNode processOutput ]"
]
{ #category : #accessing }
@ -173,7 +173,8 @@ GrafoscopioNotebook >> exportNode: aGrafoscopioNode asMarkdownIn: aFile [
aFile exists ifTrue: [ aFile delete ].
aFile
ensureCreateFile;
writeStreamDo: [:stream | stream nextPutAll: aGrafoscopioNode asMarkdown]
writeStreamDo: [:stream | stream nextPutAll: aGrafoscopioNode asMarkdown].
self inform: 'Exported as: ', String cr, aFile fullName
]
{ #category : #api }