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

View File

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