From d2959856b9ca4b3a7e428819504898906c35e981 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 12 Nov 2024 18:03:32 -0500 Subject: [PATCH] Preserving HedgeDoc importation metadata when converted to Markdeep. --- src/MiniDocs/HedgeDoc.class.st | 4 ++-- src/MiniDocs/LePage.extension.st | 12 ++++++++++++ src/MiniDocs/LeTextSnippet.extension.st | 4 +++- src/MiniDocs/LeTextualSnippet.extension.st | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/MiniDocs/HedgeDoc.class.st b/src/MiniDocs/HedgeDoc.class.st index cb8fafa..df61d95 100644 --- a/src/MiniDocs/HedgeDoc.class.st +++ b/src/MiniDocs/HedgeDoc.class.st @@ -57,8 +57,8 @@ HedgeDoc >> asLePage [ splitAdmonitionSnippets. newPage editTime: DateAndTime now. newPage options - at: 'originalMetadata' put: self metadata; - at: 'url' put: self url. + at: 'HedgeDoc' at: 'yamlFrontmatter' put: self metadata; + at: 'HedgeDoc' at: 'url' put: self url. ^ newPage ] diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index eaf0713..97e9527 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -21,6 +21,7 @@ LePage >> asHtmlFile [ LePage >> asMarkdeep [ | bodyStream markdeep | bodyStream := '' writeStream. + bodyStream nextPutAll: self notebookMetadataSnippet asMarkdeep. self preorderTraversal do: [ :snippet | bodyStream nextPutAll: snippet asMarkdeep ]. markdeep := Markdeep new @@ -231,6 +232,17 @@ LePage >> navTop [ ifTrue: [ ^ topNavFile contents ] ] +{ #category : #'*MiniDocs' } +LePage >> notebookMetadataSnippet [ + | response | + response := LeTextSnippet new fromString: ''. + response parent: self. + (self optionAt: 'HedgeDoc') ifNil: [ ^ response ]. + (response extra) + at: 'HedgeDoc' put: (self optionAt: 'HedgeDoc'). + ^ response +] + { #category : #'*MiniDocs' } LePage >> olderChild [ "I provide the last edited child node. diff --git a/src/MiniDocs/LeTextSnippet.extension.st b/src/MiniDocs/LeTextSnippet.extension.st index 0286a8b..9beb7c3 100644 --- a/src/MiniDocs/LeTextSnippet.extension.st +++ b/src/MiniDocs/LeTextSnippet.extension.st @@ -38,7 +38,9 @@ LeTextSnippet >> fromMarkdeep: markdeepDiv [ { #category : #'*MiniDocs' } LeTextSnippet >> fromString: aString [ -self string: aString +self + string: aString; + uid: LeUID new. ] { #category : #'*MiniDocs' } diff --git a/src/MiniDocs/LeTextualSnippet.extension.st b/src/MiniDocs/LeTextualSnippet.extension.st index 734fe39..dcd75d5 100644 --- a/src/MiniDocs/LeTextualSnippet.extension.st +++ b/src/MiniDocs/LeTextualSnippet.extension.st @@ -109,7 +109,7 @@ LeTextualSnippet >> metadataUpdate [ editEmailSanitized := self editEmail asString withoutXMLTagDelimiters. ^ OrderedDictionary new at: 'id' put: self uidString; - at: 'parent' put: self parent uidString; + at: 'parent' put: (self parent ifNotNil: [self parent uidString]); at: 'created' put: self createTime asString; at: 'modified' put: self latestEditTime asString; at: 'creator' put: createEmailSanitized;