Fixing conversion from PubPub footnotes links to Markdeep's.
This commit is contained in:
parent
0a6dccba99
commit
1770fc89cc
@ -132,7 +132,7 @@ Markdeep >> exportAsFile [
|
||||
| newFile |
|
||||
self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ].
|
||||
newFile := (self markdownFile file fullName, '.html') asFileReference.
|
||||
self exportAsFileOn: newFile.
|
||||
^ self exportAsFileOn: newFile.
|
||||
]
|
||||
|
||||
{ #category : #persistence }
|
||||
@ -288,28 +288,6 @@ Markdeep >> processMarkdownFor: aFileReference [
|
||||
self metadata: markdownContent yamlMetadata
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> pubPubFootnoteLinks [
|
||||
| footnotes sanitized footnotesText |
|
||||
footnotes := OrderedDictionary new.
|
||||
self pubPubFootnoteRawLinks do: [:link | | footnote|
|
||||
footnote := self pubPubFootnoteMetadataFromString: link second.
|
||||
footnote ifNotNil: [ | toReplace |
|
||||
footnotes at: link first put: footnote.
|
||||
toReplace := '[', link first, ']', '{', link second, '}'.
|
||||
sanitized := self body copyReplaceAll: toReplace with: '[^', link first, ']'
|
||||
]
|
||||
].
|
||||
footnotesText := '' writeStream.
|
||||
footnotes keysAndValuesDo: [:k :v |
|
||||
footnotesText
|
||||
nextPutAll: '[^', k, ']: ';
|
||||
nextPutAll: (v at: 'data-value')
|
||||
].
|
||||
self pubPubFootnotesText.
|
||||
^ {footnotes . sanitized . footnotesText contents } third
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> pubPubFootnoteMetadataFromString: string [
|
||||
| sanitized footnoteData |
|
||||
@ -325,7 +303,7 @@ Markdeep >> pubPubFootnoteMetadataFromString: string [
|
||||
sanitized := sanitized contents copyReplaceAll: '.footnote ' with: ''.
|
||||
sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '.
|
||||
sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '.
|
||||
footnoteData := { 'id' -> string lines first } asDictionary.
|
||||
footnoteData := { 'id' -> string lines first allButFirst } asDictionary.
|
||||
footnoteData addAll: (MiniDocs yamlToJson: sanitized).
|
||||
^ footnoteData
|
||||
]
|
||||
@ -340,8 +318,8 @@ Markdeep >> pubPubFootnoteRawLinks [
|
||||
{ #category : #accessing }
|
||||
Markdeep >> pubPubFootnotesLinesRange [
|
||||
| beginningLine endingLine |
|
||||
beginningLine := self body lines size + 1.
|
||||
self body lines doWithIndex: [:line :i |
|
||||
beginningLine := self contents lines size + 1.
|
||||
self contents lines doWithIndex: [:line :i |
|
||||
(line beginsWith: '::: {.pub-notes}') ifTrue: [ beginningLine := i ].
|
||||
(i > beginningLine and: [ line beginsWith: ':::' ])
|
||||
ifTrue: [
|
||||
@ -353,7 +331,39 @@ Markdeep >> pubPubFootnotesLinesRange [
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> pubPubFootnotesText [
|
||||
^ self pubPubFootnotesLinesRange
|
||||
| footnotesLines output |
|
||||
footnotesLines := self contents lines
|
||||
copyFrom: self pubPubFootnotesLinesRange first + 3
|
||||
to: self pubPubFootnotesLinesRange second - 1.
|
||||
output := '' writeStream.
|
||||
footnotesLines do: [:line |
|
||||
output
|
||||
nextPutAll: line;
|
||||
nextPutAll: String crlf.
|
||||
].
|
||||
^ output contents allButLast
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdeep >> pubPubFootnotesToMarkdeep [
|
||||
| footnotes sanitized cleanedFootnotesText |
|
||||
footnotes := OrderedDictionary new.
|
||||
self pubPubFootnoteRawLinks do: [:link | | footnote|
|
||||
footnote := self pubPubFootnoteMetadataFromString: link second.
|
||||
footnote ifNotNil: [ | toReplace |
|
||||
footnotes at: (footnote at: 'id') put: footnote.
|
||||
toReplace := '[', link first, ']', '{', link second, '}'.
|
||||
sanitized := self body copyReplaceAll: toReplace with: '[^', (footnote at: 'id'), ']'
|
||||
]
|
||||
].
|
||||
cleanedFootnotesText := '' writeStream.
|
||||
footnotes keysAndValuesDo: [:k :v |
|
||||
cleanedFootnotesText
|
||||
nextPutAll: '[^', k, ']: ';
|
||||
nextPutAll: (v at: 'data-value')
|
||||
].
|
||||
"^ {footnotes . sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents }."
|
||||
self body: (sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents)
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Loading…
Reference in New Issue
Block a user