Preparing footnotes replacement.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-12 19:21:04 -05:00
parent 7855e9e0c3
commit e46329d9e1

View File

@ -152,6 +152,7 @@ Markdeep >> converPubPubFootnoteBetween: footnote and: nextFootnote in: footnote
ifNotEmpty: [ response nextPutAll: line, String lf ] ifNotEmpty: [ response nextPutAll: line, String lf ]
"ifEmpty: [ response nextPutAll: ' ' ]?" "ifEmpty: [ response nextPutAll: ' ' ]?"
]. ].
response nextPutAll: String lf.
^ response contents ^ response contents
] ]
@ -335,10 +336,10 @@ Markdeep >> pubPubFootnoteRawLinks [
] ]
{ #category : #accessing } { #category : #accessing }
Markdeep >> pubPubFootnotesLinesRange [ Markdeep >> pubPubFootnotesLinesRangeFor: contentSection [
| beginningLine endingLine | | beginningLine endingLine |
beginningLine := self contents lines size + 1. beginningLine := contentSection lines size + 1.
self contents lines doWithIndex: [:line :i | contentSection lines doWithIndex: [:line :i |
(line includesSubstring: '::: {.pub-notes}') ifTrue: [ beginningLine := i ]. (line includesSubstring: '::: {.pub-notes}') ifTrue: [ beginningLine := i ].
(i > beginningLine and: [ line beginsWith: ':::' ]) (i > beginningLine and: [ line beginsWith: ':::' ])
ifTrue: [ ifTrue: [
@ -348,12 +349,22 @@ Markdeep >> pubPubFootnotesLinesRange [
] ]
] ]
{ #category : #accessing }
Markdeep >> pubPubFootnotesLinesRangeForBody [
^ self pubPubFootnotesLinesRangeFor: self body
]
{ #category : #accessing }
Markdeep >> pubPubFootnotesLinesRangeForContents [
^ self pubPubFootnotesLinesRangeFor: self contents
]
{ #category : #accessing } { #category : #accessing }
Markdeep >> pubPubFootnotesText [ Markdeep >> pubPubFootnotesText [
| footnotesLines output | | footnotesLines output |
footnotesLines := self contents lines footnotesLines := self contents lines
copyFrom: self pubPubFootnotesLinesRange first + 3 copyFrom: self pubPubFootnotesLinesRangeForContents first + 3
to: self pubPubFootnotesLinesRange second - 1. to: self pubPubFootnotesLinesRangeForContents second - 1.
output := '' writeStream. output := '' writeStream.
footnotesLines do: [:line | footnotesLines do: [:line |
output output
@ -428,8 +439,8 @@ Markdeep >> removeCCByLicenseDiv [
Markdeep >> renamePubPubFootnotes [ Markdeep >> renamePubPubFootnotes [
| footnotesLines footnotesIDs toReplace response | | footnotesLines footnotesIDs toReplace response |
footnotesLines := self contents lines footnotesLines := self contents lines
copyFrom: self pubPubFootnotesLinesRange first copyFrom: self pubPubFootnotesLinesRangeForContents first
to: self pubPubFootnotesLinesRange second. to: self pubPubFootnotesLinesRangeForContents second.
footnotesIDs := self replacePubPubFootnotesIdentifiers. footnotesIDs := self replacePubPubFootnotesIdentifiers.
toReplace := footnotesLines select: [:line | toReplace := footnotesLines select: [:line |
(line includesSubstring: ' [[]{.pub-note-content-component}]{#fn-') (line includesSubstring: ' [[]{.pub-note-content-component}]{#fn-')
@ -438,8 +449,7 @@ Markdeep >> renamePubPubFootnotes [
index := footnotesLines indexOf: replacement. index := footnotesLines indexOf: replacement.
footnotesLines at: index put: '[^', (footnotesIDs at: i),']: ' footnotesLines at: index put: '[^', (footnotesIDs at: i),']: '
]. ].
^ footnotesLines response := '' writeStream.
"response := '' writeStream.
footnotesIDs allButLast doWithIndex: [:footnote :i | footnotesIDs allButLast doWithIndex: [:footnote :i |
response response
nextPutAll: nextPutAll:
@ -448,7 +458,7 @@ Markdeep >> renamePubPubFootnotes [
and: (footnotesIDs at: i + 1) and: (footnotesIDs at: i + 1)
in: footnotesLines) in: footnotesLines)
]. ].
^ response" ^ response contents
] ]
{ #category : #accessing } { #category : #accessing }