Improving conversion from PubPub footnotes links to Markdeep's.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-10-23 19:47:02 -05:00
parent 1770fc89cc
commit ef2b6e7190
1 changed files with 33 additions and 8 deletions

View File

@ -59,6 +59,21 @@ Markdeep >> bodyReplaceAll: original with: replacement [
self body: (self body copyReplaceAll: original with: replacement) self body: (self body copyReplaceAll: original with: replacement)
] ]
{ #category : #accessing }
Markdeep >> commentPubPubDelimiters [
| commented openners |
openners := #('::: {.pub-body-component}' '::: {.editor .Prosemirror}' '::: {.pub-notes}').
commented := self body.
openners do: [:openner |
commented := commented copyReplaceAll: openner with: '<!--@div-open ', openner, '-->'
].
commented := commented
copyReplaceAll: ':::
' with: '<!--@div-close ::: -->
'.
self body: commented
]
{ #category : #accessing } { #category : #accessing }
Markdeep >> comments [ Markdeep >> comments [
^ comments ifNil: [ ^ comments := true ] ^ comments ifNil: [ ^ comments := true ]
@ -290,20 +305,22 @@ Markdeep >> processMarkdownFor: aFileReference [
{ #category : #accessing } { #category : #accessing }
Markdeep >> pubPubFootnoteMetadataFromString: string [ Markdeep >> pubPubFootnoteMetadataFromString: string [
| sanitized footnoteData | | sanitized footnoteData altLine id |
(string lines size <= 1) ifTrue: [ ^ nil ]. (string lines size <= 1) ifTrue: [ ^ nil ].
sanitized := '' writeStream. sanitized := '' writeStream.
string lines allButFirstDo: [:line | string lines allButFirstDo: [:line |
(line beginsWith: '>') ifTrue: [ (line beginsWith: '>')
ifTrue: [ altLine := line allButFirst ]
ifFalse: [ altLine := line ].
sanitized sanitized
nextPutAll: line allButFirst; nextPutAll: altLine trimmed;
nextPutAll: String lf nextPutAll: String lf
]
]. ].
sanitized := sanitized contents copyReplaceAll: '.footnote' with: ''. sanitized := sanitized contents copyReplaceAll: '.footnote' with: ''.
sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '. sanitized := sanitized copyReplaceAll: 'type=' with: 'type: '.
sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '. sanitized := sanitized copyReplaceAll: 'value=' with: 'value: '.
footnoteData := { 'id' -> string lines first allButFirst } asDictionary. id := (string lines first) allButFirst trimmed.
footnoteData := { 'id' -> id } asDictionary.
footnoteData addAll: (MiniDocs yamlToJson: sanitized). footnoteData addAll: (MiniDocs yamlToJson: sanitized).
^ footnoteData ^ footnoteData
] ]
@ -348,6 +365,7 @@ Markdeep >> pubPubFootnotesText [
Markdeep >> pubPubFootnotesToMarkdeep [ Markdeep >> pubPubFootnotesToMarkdeep [
| footnotes sanitized cleanedFootnotesText | | footnotes sanitized cleanedFootnotesText |
footnotes := OrderedDictionary new. footnotes := OrderedDictionary new.
self pubPubFootnoteRawLinks ifEmpty: [ ^self ].
self pubPubFootnoteRawLinks do: [:link | | footnote| self pubPubFootnoteRawLinks do: [:link | | footnote|
footnote := self pubPubFootnoteMetadataFromString: link second. footnote := self pubPubFootnoteMetadataFromString: link second.
footnote ifNotNil: [ | toReplace | footnote ifNotNil: [ | toReplace |
@ -366,6 +384,13 @@ Markdeep >> pubPubFootnotesToMarkdeep [
self body: (sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents) self body: (sanitized copyReplaceAll: self pubPubFootnotesText with: cleanedFootnotesText contents)
] ]
{ #category : #accessing }
Markdeep >> replaceBackslashBreaklines [
self bodyReplaceAll: '\
' with: '<br>
'
]
{ #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"