Footnotes replacement done (minor bugs with last footnote still to be fixed).

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-14 11:59:09 -05:00
parent e46329d9e1
commit dc218111e6
1 changed files with 39 additions and 20 deletions

View File

@ -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 }