Fixing footnotes conversion for several footnotes.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-23 22:33:26 -05:00
parent a53cb5823e
commit dc7a4b93d1

View File

@ -323,7 +323,7 @@ node-type= '.
sanitized := sanitized contents. sanitized := sanitized contents.
sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '. sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '.
sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '. sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '.
id := (string lines first) allButFirst trimmed. id := (altString lines first) allButFirst trimmed.
footnoteData := { 'id' -> id } asDictionary. footnoteData := { 'id' -> id } asDictionary.
footnoteData addAll: (MiniDocs yamlToJson: sanitized trimmed). footnoteData addAll: (MiniDocs yamlToJson: sanitized trimmed).
^ footnoteData ^ footnoteData
@ -367,24 +367,30 @@ Markdeep >> pubPubFootnotesText [
{ #category : #accessing } { #category : #accessing }
Markdeep >> pubPubFootnotesToMarkdeep [ Markdeep >> pubPubFootnotesToMarkdeep [
| footnotes sanitized cleanedFootnotesText | | footnotes sanitized cleanedFootnotesText parsedLinks |
footnotes := OrderedDictionary new. footnotes := OrderedDictionary new.
self pubPubFootnoteRawLinks ifEmpty: [ ^self ]. parsedLinks := self pubPubFootnoteRawLinks.
self pubPubFootnoteRawLinks do: [:link | | footnote| parsedLinks ifEmpty: [ ^self ].
sanitized := self body.
parsedLinks do: [:link | | footnote |
footnote := self pubPubFootnoteMetadataFromString: link second. footnote := self pubPubFootnoteMetadataFromString: link second.
footnote ifNotNil: [ | toReplace | footnote ifNotNil: [ | toReplace |
footnotes at: (footnote at: 'id') put: footnote. footnotes at: (footnote at: 'id') put: footnote.
toReplace := '[', link first, ']', '{', link second, '}'. toReplace := '[', link first, ']{', link second, '}'.
sanitized := self body copyReplaceAll: toReplace with: '[^', (footnote at: 'id'), ']' sanitized := sanitized copyReplaceAll: toReplace with: '[^', (footnote at: 'id'), ']'
] ]
]. ].
cleanedFootnotesText := '' writeStream. cleanedFootnotesText := '' writeStream.
footnotes keysAndValuesDo: [:k :v | footnotes keysAndValuesDo: [:k :v |
cleanedFootnotesText cleanedFootnotesText
nextPutAll: '[^', k, ']: '; 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) self body: (sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents)
] ]