Format conversion before metadata extraction.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-23 20:42:26 -05:00
parent ef2b6e7190
commit a53cb5823e

View File

@ -305,23 +305,27 @@ Markdeep >> processMarkdownFor: aFileReference [
{ #category : #accessing }
Markdeep >> pubPubFootnoteMetadataFromString: string [
| sanitized footnoteData altLine id |
| sanitized footnoteData altLine altString id |
(string lines size <= 1) ifTrue: [ ^ nil ].
sanitized := '' writeStream.
string lines allButFirstDo: [:line |
altString := string copyReplaceAll: '.footnote' with: ''.
altString := altString copyReplaceAll: ' node-type='
with: '
node-type= '.
altString lines allButFirstDo: [:line |
(line beginsWith: '>')
ifTrue: [ altLine := line allButFirst ]
ifFalse: [ altLine := line ].
sanitized
nextPutAll: altLine trimmed;
nextPutAll: altLine trimBoth;
nextPutAll: String lf
].
sanitized := sanitized contents copyReplaceAll: '.footnote' with: ''.
sanitized := sanitized contents.
sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '.
sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '.
id := (string lines first) allButFirst trimmed.
footnoteData := { 'id' -> id } asDictionary.
footnoteData addAll: (MiniDocs yamlToJson: sanitized).
footnoteData addAll: (MiniDocs yamlToJson: sanitized trimmed).
^ footnoteData
]