diff --git a/repository/Grafoscopio/GrafoscopioNode.class.st b/repository/Grafoscopio/GrafoscopioNode.class.st index 7f1d8a9..493db87 100644 --- a/repository/Grafoscopio/GrafoscopioNode.class.st +++ b/repository/Grafoscopio/GrafoscopioNode.class.st @@ -80,15 +80,32 @@ GrafoscopioNode >> addNodeAfter [ ] +{ #category : #accessing } +GrafoscopioNode >> ancestorsHeaders [ + "Returns the headers of all the ancestors of the node. Maybe this and 'headers' should be integrated, so both act on a collection of + children instead of having two separate methods" + | currentNode ancestors | + + currentNode := self. + ancestors := OrderedCollection new. + (self level - 1) + timesRepeat: [ + ancestors add: currentNode parent. + currentNode := currentNode parent.]. + ancestors := ancestors reversed. + ^ ancestors collect: [:ancestor | ancestor header ] + + +] + { #category : #exporting } GrafoscopioNode >> asMarkdown [ "Exports children of the curren node as pandoc markdown, using special nodes for config options and bibliography." | markdownOutput | markdownOutput := '' writeStream. - "(self preorderTraversal) do: [ :eachNode | markdownOutput nextPutAll: (eachNode markdownContent) ]." (self preorderTraversal) do: [ :eachNode | - (eachNode level > 0) ifTrue: [(eachNode parent header = '%invisible') not ifTrue: [markdownOutput nextPutAll: (eachNode markdownContent)]]]. + (eachNode level > 0) ifTrue: [(eachNode ancestorsHeaders includes: '%invisible') not ifTrue: [ markdownOutput nextPutAll: (eachNode markdownContent) ]]]. ^markdownOutput contents