Extension { #name : #LePictureSnippet } { #category : #'*MiniDocs' } LePictureSnippet >> asMarkdeep [ | output curatedCaption captionLines | captionLines := self caption lines. (captionLines size <= 1) ifTrue: [ curatedCaption := caption ] ifFalse: [ curatedCaption := WriteStream on: ''. curatedCaption nextPutAll: captionLines first. captionLines allButFirstDo: [:line | curatedCaption nextPutAll: ' ', line. curatedCaption := curatedCaption contents. ] ]. output := WriteStream on: ''. output nextPutAll: self metadataDiv; nextPutAll: '![ ', curatedCaption ,' ](', self urlString, ')'; nextPut: Character lf; nextPutAll: ''; nextPut: Character lf; nextPut: Character lf. ^ output contents ] { #category : #'*MiniDocs' } LePictureSnippet >> asMarkdown [ ^ self asMarkdeep ] { #category : #'*MiniDocs' } LePictureSnippet >> contentFrom: markdeepDiv [ | caption width | caption := markdeepDiv contentString. width := (markdeepDiv // 'img' @ 'width') stringValue. self optionAt: 'caption' put: caption; optionAt: 'width' put: width. self urlString: (markdeepDiv // 'img' @ 'src') stringValue. ] { #category : #'*MiniDocs' } LePictureSnippet >> fromMarkdeep: markdeepDiv [ ^ markdeepDiv asSnippetDictionary asLepiterSnippet ] { #category : #'*MiniDocs' } LePictureSnippet >> fromString: aString [ "aString should be a valid Markdown/Markdeep image string" | args captionTemp urlTemp | args := aString splitOn: ']('. captionTemp := args first. captionTemp := captionTemp copyFrom: 3 to: captionTemp size. urlTemp := args second. urlTemp := urlTemp copyFrom: 1 to: urlTemp size - 1. self caption: captionTemp. self urlString: urlTemp. ^ self ] { #category : #'*MiniDocs' } LePictureSnippet >> metadata [ ^ self metadataInit ] { #category : #'*MiniDocs' } LePictureSnippet >> metadataDiv [ | output | output := WriteStream on: ''. output nextPutAll: '