diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index e8e7a80..9cbb507 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -399,6 +399,32 @@ Markdeep >> pubPubRawLinks [ ^ (parser parse: self body) ] +{ #category : #accessing } +Markdeep >> reformatPubPubFootnotes [ + | footnotesLines footnotesIDs toReplace response | + footnotesLines := self contents lines + copyFrom: self pubPubFootnotesLinesRangeForContents first + to: self pubPubFootnotesLinesRangeForContents second. + footnotesIDs := self replacePubPubFootnotesIdentifiers. + toReplace := footnotesLines select: [:line | + (line includesSubstring: ' [[]{.pub-note-content-component}]{#fn-') + ]. + toReplace doWithIndex: [:replacement :i | | index | + index := footnotesLines indexOf: replacement. + footnotesLines at: index put: '[^', (footnotesIDs at: i),']: ' + ]. + response := '' writeStream. + footnotesIDs allButLast doWithIndex: [:footnote :i | + response + nextPutAll: + (self + converPubPubFootnoteBetween: footnote + and: (footnotesIDs at: i + 1) + in: footnotesLines) + ]. + ^ response contents +] + { #category : #accessing } Markdeep >> removeAlternativeImagesArray [ | replacements | @@ -437,28 +463,21 @@ Markdeep >> removeCCByLicenseDiv [ { #category : #accessing } Markdeep >> renamePubPubFootnotes [ - | footnotesLines footnotesIDs toReplace response | - footnotesLines := self contents lines - copyFrom: self pubPubFootnotesLinesRangeForContents first - to: self pubPubFootnotesLinesRangeForContents second. - footnotesIDs := self replacePubPubFootnotesIdentifiers. - toReplace := footnotesLines select: [:line | - (line includesSubstring: ' [[]{.pub-note-content-component}]{#fn-') - ]. - toReplace doWithIndex: [:replacement :i | | index | - index := footnotesLines indexOf: replacement. - footnotesLines at: index put: '[^', (footnotesIDs at: i),']: ' - ]. + | reformated bodyLines beforeFootnotes afterFootnotes newBodyLines response | + reformated := self reformatPubPubFootnotes. + bodyLines := self body lines. + beforeFootnotes := bodyLines copyFrom: 1 to: self pubPubFootnotesLinesRangeForBody first . + afterFootnotes := bodyLines copyFrom: self pubPubFootnotesLinesRangeForBody second to: bodyLines size. + newBodyLines := + (beforeFootnotes copyWithAll: + (#('# Footnotes' '') + copyWithAll:(reformated lines + copyWithAll: afterFootnotes))). response := '' writeStream. - footnotesIDs allButLast doWithIndex: [:footnote :i | - response - nextPutAll: - (self - converPubPubFootnoteBetween: footnote - and: (footnotesIDs at: i + 1) - in: footnotesLines) + newBodyLines do: [:line | + response nextPutAll: line, String lf ]. - ^ response contents + self body: response contents. ] { #category : #accessing }