MiniDocs/src/MiniDocs/LePharoSnippet.extension.st

65 lines
2.0 KiB
Smalltalk

Extension { #name : #LePharoSnippet }
{ #category : #'*MiniDocs' }
LePharoSnippet >> contentAsStringCustomized [
| thisObject |
(self tags includes: 'output') ifFalse: [ ^ self contentAsString ].
thisObject := ((self page sharedVariablesBindings) at: self detectObject) value.
^ thisObject perform: self detectMessage trimmed asSymbol.
]
{ #category : #'*MiniDocs' }
LePharoSnippet >> contentFrom: markdeepDiv [
| sanitizedStringText metadata joinedText |
metadata := STON fromString: (markdeepDiv attributes at: 'st-data').
sanitizedStringText := markdeepDiv contentString lines.
sanitizedStringText := sanitizedStringText copyFrom: 4 to: sanitizedStringText size -2.
joinedText := '' writeStream.
sanitizedStringText do: [ :line | joinedText nextPutAll: line; nextPut: Character lf ].
self code: joinedText contents allButLast;
uid: (LeUID new uidString: (metadata at: 'id'));
parent: (metadata at: 'parent');
createTime: (LeTime new time: ((metadata at: 'created')asDateAndTime));
editTime: (LeTime new time: ((metadata at: 'modified') asDateAndTime));
editEmail: (metadata at: 'modifier');
createEmail: (metadata at: 'creator')
]
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdeepCustomCloser [
^ String streamContents: [ :stream |
stream
nextPutAll: '~~~'; lf;
nextPutAll: '</script>'; lf.
]
]
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdeepCustomOpener [
^ String streamContents: [ :stream |
stream
nextPutAll: '<script type="preformatted">'; lf;
nextPutAll: '~~~ Smalltalk'; lf
]
]
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdownCustomCloser [
(self tags includes: 'output') ifTrue: [^ String with: Character lf].
^ String streamContents: [:stream |
stream
nextPutAll: '~~~'; lf
]
]
{ #category : #'*MiniDocs' }
LePharoSnippet >> markdownCustomOpener [
(self tags includes: 'output') ifTrue: [ ^ String with: Character lf ].
^ String
streamContents: [ :stream |
stream
nextPutAll: '~~~ Smalltalk';
lf ]
]