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
parent 40a8a58e70
commit c03e827e50
2 changed files with 30 additions and 8 deletions

View File

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

View File

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