Minimal conversion of PubPub footnotes links to Markdeep's.
This commit is contained in:
parent
162d126aeb
commit
0a6dccba99
@ -288,6 +288,74 @@ Markdeep >> processMarkdownFor: aFileReference [
|
|||||||
self metadata: markdownContent yamlMetadata
|
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 |
|
||||||
|
(string lines size <= 1) ifTrue: [ ^ nil ].
|
||||||
|
sanitized := '' writeStream.
|
||||||
|
string lines allButFirstDo: [:line |
|
||||||
|
(line beginsWith: '>') ifTrue: [
|
||||||
|
sanitized
|
||||||
|
nextPutAll: line allButFirst;
|
||||||
|
nextPutAll: String lf
|
||||||
|
]
|
||||||
|
].
|
||||||
|
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 addAll: (MiniDocs yamlToJson: sanitized).
|
||||||
|
^ footnoteData
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Markdeep >> pubPubFootnoteRawLinks [
|
||||||
|
| parser |
|
||||||
|
parser := PubPubGrammar new linkSea star.
|
||||||
|
^ parser parse: self body
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Markdeep >> pubPubFootnotesLinesRange [
|
||||||
|
| beginningLine endingLine |
|
||||||
|
beginningLine := self body lines size + 1.
|
||||||
|
self body lines doWithIndex: [:line :i |
|
||||||
|
(line beginsWith: '::: {.pub-notes}') ifTrue: [ beginningLine := i ].
|
||||||
|
(i > beginningLine and: [ line beginsWith: ':::' ])
|
||||||
|
ifTrue: [
|
||||||
|
endingLine := i.
|
||||||
|
^ {beginningLine . endingLine}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
Markdeep >> pubPubFootnotesText [
|
||||||
|
^ self pubPubFootnotesLinesRange
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
Markdeep >> tail [
|
Markdeep >> tail [
|
||||||
"I enable the document tail, which, in turn, enables a Markdeep document"
|
"I enable the document tail, which, in turn, enables a Markdeep document"
|
||||||
|
Loading…
Reference in New Issue
Block a user