diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index c8540a7..185ee30 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -288,6 +288,74 @@ Markdeep >> processMarkdownFor: aFileReference [ self metadata: markdownContent yamlMetadata ] +{ #category : #accessing } +Markdeep >> pubPubFootnoteLinks [ + | footnotes sanitized footnotesText | + footnotes := OrderedDictionary new. + self pubPubFootnoteRawLinks do: [:link | | footnote| + footnote := self pubPubFootnoteMetadataFromString: link second. + footnote ifNotNil: [ | toReplace | + footnotes at: link first put: footnote. + toReplace := '[', link first, ']', '{', link second, '}'. + sanitized := self body copyReplaceAll: toReplace with: '[^', link first, ']' + ] + ]. + footnotesText := '' writeStream. + footnotes keysAndValuesDo: [:k :v | + footnotesText + nextPutAll: '[^', k, ']: '; + nextPutAll: (v at: 'data-value') + ]. + self pubPubFootnotesText. + ^ {footnotes . sanitized . footnotesText contents } third +] + +{ #category : #accessing } +Markdeep >> pubPubFootnoteMetadataFromString: string [ + | sanitized footnoteData | + (string lines size <= 1) ifTrue: [ ^ nil ]. + sanitized := '' writeStream. + string lines allButFirstDo: [:line | + (line beginsWith: '>') ifTrue: [ + sanitized + nextPutAll: line allButFirst; + nextPutAll: String lf + ] + ]. + sanitized := sanitized contents copyReplaceAll: '.footnote ' with: ''. + sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '. + sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '. + footnoteData := { 'id' -> string lines first } asDictionary. + footnoteData addAll: (MiniDocs yamlToJson: sanitized). + ^ footnoteData +] + +{ #category : #accessing } +Markdeep >> pubPubFootnoteRawLinks [ + | parser | + parser := PubPubGrammar new linkSea star. + ^ parser parse: self body +] + +{ #category : #accessing } +Markdeep >> pubPubFootnotesLinesRange [ + | beginningLine endingLine | + beginningLine := self body lines size + 1. + self body lines doWithIndex: [:line :i | + (line beginsWith: '::: {.pub-notes}') ifTrue: [ beginningLine := i ]. + (i > beginningLine and: [ line beginsWith: ':::' ]) + ifTrue: [ + endingLine := i. + ^ {beginningLine . endingLine} + ] + ] +] + +{ #category : #accessing } +Markdeep >> pubPubFootnotesText [ + ^ self pubPubFootnotesLinesRange +] + { #category : #accessing } Markdeep >> tail [ "I enable the document tail, which, in turn, enables a Markdeep document"