MiniDocs/src/MiniDocs/XMLElement.extension.st

31 lines
990 B
Smalltalk

Extension { #name : #XMLElement }
{ #category : #'*MiniDocs' }
XMLElement >> asSnippetDictionary [
| response |
response := STON fromString: (self attributes at: 'st-data').
response at: 'className' put: (self attributes at: 'st-class').
response at: 'content' put: self sanitizedContent.
^ response
]
{ #category : #'*MiniDocs' }
XMLElement >> sanitizedContent [
| className sanitizedText |
className := self attributes at: 'st-class'.
(className = 'LeTextSnippet') ifTrue: [
sanitizedText := self contentString.
sanitizedText := sanitizedText allButFirst.
sanitizedText := sanitizedText allButLast.
].
(className = 'LePharoSnippet') ifTrue: [ | joinedText |
sanitizedText := self contentString lines.
sanitizedText := sanitizedText copyFrom: 4 to: sanitizedText size -2.
joinedText := '' writeStream.
sanitizedText do: [ :line | joinedText nextPutAll: line; nextPut: Character lf ].
sanitizedText := joinedText contents allButLast.
].
^ sanitizedText
]