From ef2b6e7190ab972c12d099cac4de2979badeac83 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 23 Oct 2022 19:47:02 -0500 Subject: [PATCH] Improving conversion from PubPub footnotes links to Markdeep's. --- src/MiniDocs/Markdeep.class.st | 41 +++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index 03185ad..a7c55d4 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -59,6 +59,21 @@ Markdeep >> bodyReplaceAll: original with: replacement [ self body: (self body copyReplaceAll: original with: replacement) ] +{ #category : #accessing } +Markdeep >> commentPubPubDelimiters [ + | commented openners | + openners := #('::: {.pub-body-component}' '::: {.editor .Prosemirror}' '::: {.pub-notes}'). + commented := self body. + openners do: [:openner | + commented := commented copyReplaceAll: openner with: '' + ]. + commented := commented + copyReplaceAll: '::: +' with: ' +'. + self body: commented +] + { #category : #accessing } Markdeep >> comments [ ^ comments ifNil: [ ^ comments := true ] @@ -290,20 +305,22 @@ Markdeep >> processMarkdownFor: aFileReference [ { #category : #accessing } Markdeep >> pubPubFootnoteMetadataFromString: string [ - | sanitized footnoteData | + | sanitized footnoteData altLine id | (string lines size <= 1) ifTrue: [ ^ nil ]. sanitized := '' writeStream. string lines allButFirstDo: [:line | - (line beginsWith: '>') ifTrue: [ - sanitized - nextPutAll: line allButFirst; - nextPutAll: String lf - ] + (line beginsWith: '>') + ifTrue: [ altLine := line allButFirst ] + ifFalse: [ altLine := line ]. + sanitized + nextPutAll: altLine trimmed; + nextPutAll: String lf ]. - sanitized := sanitized contents copyReplaceAll: '.footnote ' with: ''. + sanitized := sanitized contents copyReplaceAll: '.footnote' with: ''. sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '. sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '. - footnoteData := { 'id' -> string lines first allButFirst } asDictionary. + id := (string lines first) allButFirst trimmed. + footnoteData := { 'id' -> id } asDictionary. footnoteData addAll: (MiniDocs yamlToJson: sanitized). ^ footnoteData ] @@ -348,6 +365,7 @@ Markdeep >> pubPubFootnotesText [ Markdeep >> pubPubFootnotesToMarkdeep [ | footnotes sanitized cleanedFootnotesText | footnotes := OrderedDictionary new. + self pubPubFootnoteRawLinks ifEmpty: [ ^self ]. self pubPubFootnoteRawLinks do: [:link | | footnote| footnote := self pubPubFootnoteMetadataFromString: link second. footnote ifNotNil: [ | toReplace | @@ -366,6 +384,13 @@ Markdeep >> pubPubFootnotesToMarkdeep [ self body: (sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents) ] +{ #category : #accessing } +Markdeep >> replaceBackslashBreaklines [ + self bodyReplaceAll: '\ +' with: '
+' +] + { #category : #accessing } Markdeep >> tail [ "I enable the document tail, which, in turn, enables a Markdeep document"