First version of %embed nodes support. They allow to replace text in their parents with the content of that nodes.
This commit is contained in:
parent
c8afd87f54
commit
6f9f6285d5
@ -423,8 +423,8 @@ GrafoscopioBrowser >> updateSystem [
|
|||||||
(ConfigurationOfCitezen project latestVersion: #development) load.
|
(ConfigurationOfCitezen project latestVersion: #development) load.
|
||||||
|
|
||||||
Gofer new
|
Gofer new
|
||||||
smalltalkhubUser: 'Offray' project: 'Ubakye';
|
smalltalkhubUser: 'Offray' project: 'Grafoscopio';
|
||||||
package: 'Ubakye';
|
package: 'Grafoscopio';
|
||||||
load.
|
load.
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -80,7 +80,7 @@ GrafoscopioNode >> addNodeAfter [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #exporting }
|
||||||
GrafoscopioNode >> asMarkdown [
|
GrafoscopioNode >> asMarkdown [
|
||||||
"Exports children of the curren node as pandoc markdown, using special nodes for config options and
|
"Exports children of the curren node as pandoc markdown, using special nodes for config options and
|
||||||
bibliography."
|
bibliography."
|
||||||
@ -93,7 +93,7 @@ GrafoscopioNode >> asMarkdown [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #exporting }
|
||||||
GrafoscopioNode >> asSton [
|
GrafoscopioNode >> asSton [
|
||||||
"Exports current tree as STON format"
|
"Exports current tree as STON format"
|
||||||
| stonOutput |
|
| stonOutput |
|
||||||
@ -104,7 +104,7 @@ GrafoscopioNode >> asSton [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #initialization }
|
||||||
GrafoscopioNode >> becomeDefaultTree [
|
GrafoscopioNode >> becomeDefaultTree [
|
||||||
| node1 node2 node3 |
|
| node1 node2 node3 |
|
||||||
self level: 0.
|
self level: 0.
|
||||||
@ -247,24 +247,24 @@ GrafoscopioNode >> level: anInteger [
|
|||||||
level := anInteger
|
level := anInteger
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #exporting }
|
||||||
GrafoscopioNode >> markdownContent [
|
GrafoscopioNode >> markdownContent [
|
||||||
"Extracts the markdown of a node using body as content, header as title and level as hierarchical level of the title.
|
"Extracts the markdown of a node using body as content, header as title and level as hierarchical level of the title.
|
||||||
If special nodes types are present, converts them into proper markup to be embedded inside markdown"
|
If special nodes types are present, converts them into proper markup to be embedded inside markdown"
|
||||||
| markdown configDict specialWords embedNodes temporalBody |
|
| markdown configDict specialWords embedNodes temporalBody |
|
||||||
markdown := '' writeStream.
|
markdown := '' writeStream.
|
||||||
specialWords := #('#config' '#abstract' '#invisible' '#idea' '#footnote' 'nuevoNodo' '%embed').
|
specialWords := #('%config' '%abstract' '%invisible' '%idea' '%footnote' 'nuevoNodo' '%embed').
|
||||||
(self level > 0) & (specialWords includes: self header) not & (specialWords includes: ((self header findTokens: $ ) at: 1)) not
|
(self level > 0) & (specialWords includes: self header) not & (specialWords includes: ((self header findTokens: $ ) at: 1)) not
|
||||||
ifTrue: [
|
ifTrue: [
|
||||||
self level timesRepeat: [ markdown nextPutAll: '#' ].
|
self level timesRepeat: [ markdown nextPutAll: '#' ].
|
||||||
markdown nextPutAll: ' '.
|
markdown nextPutAll: ' '.
|
||||||
markdown nextPutAll: (self header copyReplaceTokens: #cr with: #lf); lf; lf.
|
markdown nextPutAll: (self header copyReplaceTokens: #cr with: #lf); lf; lf.
|
||||||
embedNodes := self headers select: [:each | ((each findTokens: $ ) at: 1) = '%embed'].
|
embedNodes := self children select: [:each | ((each header findTokens: $ ) at: 1) = '%embed'].
|
||||||
temporalBody := self body.
|
temporalBody := self body.
|
||||||
embedNodes ifNotNil: [ ].
|
embedNodes ifNotNil: [ embedNodes do: [ :each | temporalBody := temporalBody copyReplaceAll: (each header) with: each body]].
|
||||||
markdown nextPutAll: (self body contents withUnixLineEndings); lf; lf].
|
markdown nextPutAll: (temporalBody contents withUnixLineEndings); lf; lf].
|
||||||
|
|
||||||
(self header = '#config')
|
(self header = '%config')
|
||||||
ifTrue: [
|
ifTrue: [
|
||||||
configDict := STON fromString: (self body).
|
configDict := STON fromString: (self body).
|
||||||
markdown nextPutAll: '---'; lf.
|
markdown nextPutAll: '---'; lf.
|
||||||
@ -273,15 +273,19 @@ GrafoscopioNode >> markdownContent [
|
|||||||
markdown nextPutAll: 'bibliography: ', (configDict at: 'bibliography'); lf.
|
markdown nextPutAll: 'bibliography: ', (configDict at: 'bibliography'); lf.
|
||||||
markdown nextPutAll: 'abstract: ', '|'; lf; nextPutAll: (configDict at: 'abstract'); lf.
|
markdown nextPutAll: 'abstract: ', '|'; lf; nextPutAll: (configDict at: 'abstract'); lf.
|
||||||
markdown nextPutAll: '---'; lf. ].
|
markdown nextPutAll: '---'; lf. ].
|
||||||
((self header findString: '#idea') = 1)
|
((self header findString: '%idea') = 1)
|
||||||
ifTrue: [markdown nextPutAll: (self body contents withInternetLineEndings); lf; lf. ].
|
ifTrue: ["markdown nextPutAll: (self body contents withInternetLineEndings); lf; lf."
|
||||||
((self header findString: '#footnote') = 1)
|
embedNodes := self children select: [:each | ((each header findTokens: $ ) at: 1) = '%embed'].
|
||||||
|
temporalBody := self body.
|
||||||
|
embedNodes ifNotNil: [ embedNodes do: [ :each | temporalBody := temporalBody copyReplaceAll: (each header) with: each body]].
|
||||||
|
markdown nextPutAll: (temporalBody contents withUnixLineEndings); lf; lf.
|
||||||
|
].
|
||||||
|
((self header findString: '%footnote') = 1)
|
||||||
ifTrue: [
|
ifTrue: [
|
||||||
markdown nextPutAll: ('[^',(self header copyReplaceAll: '#footnote ' with: ''),']: ' ); lf.
|
markdown nextPutAll: ('[^',(self header copyReplaceAll: '#footnote ' with: ''),']: ' ); lf.
|
||||||
markdown nextPutAll: (self body contents withInternetLineEndings); lf; lf. ].
|
markdown nextPutAll: (self body contents withInternetLineEndings); lf; lf. ].
|
||||||
((self header findString: '%embed') = 1)
|
((self header findString: '%embed') = 1)
|
||||||
ifTrue: "[markdown nextPutAll: (self body contents withInternetLineEndings); lf; lf. ]."
|
ifTrue: [ ].
|
||||||
[markdown nextPutAll: (((self parent body) copyReplaceAll: (self header) with: (self body)) contents withInternetLineEndings); lf; lf. ].
|
|
||||||
^markdown contents
|
^markdown contents
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user