2023-10-20 14:22:06 +00:00
|
|
|
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'.
|
2023-10-31 19:03:39 +00:00
|
|
|
((className = 'LeTextSnippet') or: [className = 'LePictureSnippet'])
|
|
|
|
ifTrue: [
|
|
|
|
sanitizedText := self contentString.
|
|
|
|
sanitizedText := sanitizedText allButFirst.
|
|
|
|
sanitizedText := sanitizedText allButLast.
|
|
|
|
].
|
2023-10-20 14:22:06 +00:00
|
|
|
(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
|
|
|
|
|
|
|
|
]
|