diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index a23e0c0..6c7ec4e 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -327,6 +327,41 @@ GrafoscopioNode >> demote [ ] +{ #category : #'custom markup' } +GrafoscopioNode >> embedAll [ + "This is just a previous part of the messy markDownContent. The %embed-all keyword should be revaluated. + By default a node embeds all its children. Any non-embedable content should be under a %invisible node" + "(temporalBody includesSubstring: '%embed-all') + ifFalse: [ ] + ifTrue: [ + self embeddedNodes do: [ :each | + temporalBody := temporalBody copyReplaceAll: '%embed-all' with: (each body, (String with: Character cr), + '%embed-all')]. + temporalBody := temporalBody copyReplaceAll: '%embed-all' with: '']" + +] + +{ #category : #'custom markup' } +GrafoscopioNode >> embedNodes [ + "I find any ocurrence of '%embed a node header' in the body of a node and replace it + by the children which have such header. + Using embedded node is useful to change the order in which children appear into parents body, + while exporting" + + | temporalBody | + temporalBody := self body. + self embeddedNodes ifNotNil: [ self embeddedNodes do: [ :each | + each tags = 'código' + ifFalse: [temporalBody := temporalBody copyReplaceAll: (each header) with: each body] + ifTrue: [temporalBody := temporalBody copyReplaceAll: (each header) with: each bodyAsCode]]]. + ^ temporalBody +] + +{ #category : #'custom markup' } +GrafoscopioNode >> embeddedNodes [ + ^ self children select: [:each | each headerStartsWith: '%embed'] +] + { #category : #exporting } GrafoscopioNode >> exportCodeBlockTo: aStream [ "I convert the content of a node taged as 'código' (code) as pandoc markdown and put it @@ -543,7 +578,7 @@ GrafoscopioNode >> margins [ GrafoscopioNode >> markdownContent [ "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" - | markdown embedNodes temporalBody | + | markdown temporalBody | markdown := '' writeStream. (self class specialWords includes: self header) not & (self class specialWords includes: ((self header findTokens: $ ) at: 1)) not & (self tags ~= 'código') & @@ -552,26 +587,21 @@ GrafoscopioNode >> markdownContent [ self level timesRepeat: [ markdown nextPutAll: '#' ]. markdown nextPutAll: ' '. markdown nextPutAll: (self header copyReplaceTokens: #cr with: #lf); crlf; crlf. - embedNodes := self children select: [:each | each headerStartsWith: '%embed']. temporalBody := self body asString. - embedNodes ifNotNil: [ + self embeddedNodes ifNotNil: [ (temporalBody includesSubstring: '%embed-all') - ifFalse: [ - 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]]] + ifFalse: [temporalBody := self embedNodes ] ifTrue: [ - embedNodes do: [ :each | + self embeddedNodes do: [ :each | temporalBody := temporalBody copyReplaceAll: '%embed-all' with: (each body, (String with: Character cr), '%embed-all')]. temporalBody := temporalBody copyReplaceAll: '%embed-all' with: '']]. markdown nextPutAll: (temporalBody contents withInternetLineEndings ); crlf; crlf]. (self headerStartsWith: '%idea') ifTrue: [ - embedNodes := self children select: [:each | each headerStartsWith: '%embed']. temporalBody := self body string. - embedNodes ifNotNil: [ embedNodes do: [ :each | + self embeddedNodes ifNotNil: [ + self embeddedNodes do: [ :each | each tags = 'código' ifFalse: [temporalBody := temporalBody copyReplaceAll: (each header) with: each body] ifTrue: [temporalBody := temporalBody copyReplaceAll: (each header) with: each bodyAsCode]]]. diff --git a/repository/Grafoscopio/ManifestGrafoscopio.class.st b/repository/Grafoscopio/ManifestGrafoscopio.class.st index e7645c6..33a62ac 100644 --- a/repository/Grafoscopio/ManifestGrafoscopio.class.st +++ b/repository/Grafoscopio/ManifestGrafoscopio.class.st @@ -7,6 +7,11 @@ Class { #category : #Grafoscopio } +{ #category : #'code-critics' } +ManifestGrafoscopio class >> ruleRBAssignmentInIfTrueRuleV1FalsePositive [ + ^ #(#(#(#RGMethodDefinition #(#GrafoscopioNode #embedNodes #false)) #'2017-02-16T20:07:02.600781-05:00') ) +] + { #category : #'code-critics' } ManifestGrafoscopio class >> ruleRBClassNameInSelectorRuleV1FalsePositive [ ^ #(#(#(#RGMethodDefinition #(#'Documentation class' #current #true)) #'2016-10-07T19:39:23.013722-05:00') )