From dc7a4b93d1ce8510a8ec73c6e3cb1a87f2f82c99 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 23 Oct 2022 22:33:26 -0500 Subject: [PATCH] Fixing footnotes conversion for several footnotes. --- src/MiniDocs/Markdeep.class.st | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index a86afd9..6d31c9e 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -323,7 +323,7 @@ node-type= '. sanitized := sanitized contents. sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '. sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '. - id := (string lines first) allButFirst trimmed. + id := (altString lines first) allButFirst trimmed. footnoteData := { 'id' -> id } asDictionary. footnoteData addAll: (MiniDocs yamlToJson: sanitized trimmed). ^ footnoteData @@ -367,24 +367,30 @@ Markdeep >> pubPubFootnotesText [ { #category : #accessing } Markdeep >> pubPubFootnotesToMarkdeep [ - | footnotes sanitized cleanedFootnotesText | + | footnotes sanitized cleanedFootnotesText parsedLinks | footnotes := OrderedDictionary new. - self pubPubFootnoteRawLinks ifEmpty: [ ^self ]. - self pubPubFootnoteRawLinks do: [:link | | footnote| + parsedLinks := self pubPubFootnoteRawLinks. + parsedLinks ifEmpty: [ ^self ]. + sanitized := self body. + parsedLinks do: [:link | | footnote | footnote := self pubPubFootnoteMetadataFromString: link second. footnote ifNotNil: [ | toReplace | footnotes at: (footnote at: 'id') put: footnote. - toReplace := '[', link first, ']', '{', link second, '}'. - sanitized := self body copyReplaceAll: toReplace with: '[^', (footnote at: 'id'), ']' + toReplace := '[', link first, ']{', link second, '}'. + sanitized := sanitized copyReplaceAll: toReplace with: '[^', (footnote at: 'id'), ']' ] ]. cleanedFootnotesText := '' writeStream. - footnotes keysAndValuesDo: [:k :v | + footnotes keysAndValuesDo: [:k :v | cleanedFootnotesText nextPutAll: '[^', k, ']: '; - nextPutAll: (v at: 'data-value') + nextPutAll: (v at: 'data-value'), String lf, String lf. ]. - "^ {footnotes . sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents }." + "^ { 'links' -> parsedLinks . + 'footnotes' -> footnotes . + 'sanitized' -> sanitized . + 'footnotesRaw' -> self pubPubFootnotesText . + 'footnotesNew' -> cleanedFootnotesText contents } asDictionary." self body: (sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents) ]