Fixing %embed keyword for nesting them inside %idea headers (see <http://mutabit.com/repos.fossil/grafoscopio/info/e53747ad09457dce>).

There is explicit replicated code inside GrafoscopioNode>>markdownContent that needs code refactoring and testing.
This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-02-14 17:57:39 +00:00 committed by SantiagoBragagnolo
parent 04253b70d5
commit 9a7ebeea0e
1 changed files with 7 additions and 6 deletions

View File

@ -264,7 +264,7 @@ GrafoscopioNode >> bodyAsCode [
nextPutAll: ('~~~'); lf; nextPutAll: ('~~~'); lf;
nextPutAll: (self body contents asString withInternetLineEndings); lf; nextPutAll: (self body contents asString withInternetLineEndings); lf;
nextPutAll: ('~~~'); lf. nextPutAll: ('~~~'); lf.
^codeBody contents ^ codeBody contents
] ]
{ #category : #accessing } { #category : #accessing }
@ -565,15 +565,16 @@ GrafoscopioNode >> markdownContent [
embedNodes do: [ :each | embedNodes do: [ :each |
temporalBody := temporalBody copyReplaceAll: '%embed-all' with: (each body, (String with: Character cr), temporalBody := temporalBody copyReplaceAll: '%embed-all' with: (each body, (String with: Character cr),
'%embed-all')]. '%embed-all')].
temporalBody := temporalBody copyReplaceAll: '%embed-all' with: '' temporalBody := temporalBody copyReplaceAll: '%embed-all' with: '']].
]
].
markdown nextPutAll: (temporalBody contents withInternetLineEndings ); crlf; crlf]. markdown nextPutAll: (temporalBody contents withInternetLineEndings ); crlf; crlf].
(self headerStartsWith: '%idea') (self headerStartsWith: '%idea')
ifTrue: [ ifTrue: [
embedNodes := self children select: [:each | each headerStartsWith: '%embed']. embedNodes := self children select: [:each | each headerStartsWith: '%embed'].
temporalBody := self body. temporalBody := self body string.
embedNodes ifNotNil: [ embedNodes do: [ :each | temporalBody := temporalBody copyReplaceAll: (each header) with: each body]]. embedNodes ifNotNil: [ embedNodes do: [ :each |
each tags = 'código'
ifFalse: [temporalBody := temporalBody copyReplaceAll: (each header) with: each body]
ifTrue: [temporalBody := temporalBody copyReplaceAll: (each header) with: each bodyAsCode]]].
markdown nextPutAll: (temporalBody contents withUnixLineEndings); lf; lf. markdown nextPutAll: (temporalBody contents withUnixLineEndings); lf; lf.
]. ].
(self headerStartsWith: '%footnote') (self headerStartsWith: '%footnote')