92 lines
2.5 KiB
Smalltalk
92 lines
2.5 KiB
Smalltalk
Extension { #name : #LeTextualSnippet }
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> asMarkdeep [
|
|
"Inspired by Alpine.js and Assembler CSS 'x-' properties, we are going to use
|
|
'st-' properties as a way to extend divs metadata regarding its contents."
|
|
|
|
| output |
|
|
output := WriteStream on: ''.
|
|
output
|
|
nextPutAll: '<div st-class="' , self class greaseString , '"';
|
|
nextPut: Character lf;
|
|
nextPutAll: ' st-data="' , (STON toString: self metadata) , '">';
|
|
nextPut: Character lf;
|
|
nextPutAll: self markdeepCustomOpener;
|
|
nextPutAll: self contentAsString;
|
|
nextPut: Character lf;
|
|
nextPutAll: self markdeepCustomCloser;
|
|
nextPutAll: '</div>';
|
|
nextPut: Character lf;
|
|
nextPut: Character lf.
|
|
^ output contents
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> asMarkdown [
|
|
"Inspired by Alpine.js and Assembler CSS 'x-' properties, we are going to use
|
|
'st-' properties as a way to extend divs metadata regarding its contents."
|
|
| output |
|
|
output := '' writeStream.
|
|
output
|
|
nextPutAll: '<div st-class="', self class asString, '"'; lf;
|
|
nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf;
|
|
nextPutAll: self markdownCustomOpener;
|
|
nextPutAll: self contentAsStringCustomized; lf;
|
|
nextPutAll: self markdownCustomCloser;
|
|
nextPutAll: '</div>'; lf; lf.
|
|
^ output contents
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> contentAsStringCustomized [
|
|
^ self contentAsString
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> markdeepCustomCloser [
|
|
^ ''
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> markdeepCustomOpener [
|
|
^ ''
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> markdownCustomCloser [
|
|
^ self markdeepCustomCloser
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> markdownCustomOpener [
|
|
^ self markdeepCustomOpener
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> metadata [
|
|
|
|
^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ]
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> metadataInit [
|
|
| surrogate |
|
|
self parent
|
|
ifNil: [ surrogate := nil]
|
|
ifNotNil: [ surrogate := self parent uidString ].
|
|
^ OrderedDictionary new
|
|
at: 'id' put: self uidString;
|
|
at: 'parent' put: surrogate;
|
|
at: 'created' put: self createTime asString;
|
|
at: 'modified' put: self latestEditTime asString;
|
|
at: 'creator' put: self createEmail asString;
|
|
at: 'modifier' put: self editEmail asString;
|
|
yourself
|
|
]
|
|
|
|
{ #category : #'*MiniDocs' }
|
|
LeTextualSnippet >> tags [
|
|
^ self metadata at: 'tags' ifAbsentPut: [ Set new ]
|
|
]
|