From 58ec9eed76c6fb7b6d0f5b8480c8b1f1734aff7f Mon Sep 17 00:00:00 2001 From: Offray Date: Tue, 22 Oct 2024 13:35:24 -0500 Subject: [PATCH] Fixing metadata retention between HedgeDoc and Lepiter. --- src/MiniDocs/HedgeDoc.class.st | 5 +++-- src/MiniDocs/Markdown.class.st | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/MiniDocs/HedgeDoc.class.st b/src/MiniDocs/HedgeDoc.class.st index 4efbb71..2f03c29 100644 --- a/src/MiniDocs/HedgeDoc.class.st +++ b/src/MiniDocs/HedgeDoc.class.st @@ -37,7 +37,9 @@ HedgeDoc >> asLePage [ addSnippet: snippet; yourself. newPage incomingLinks. - newPage metadata addAll: self metadata. + newPage options + at: 'originalMetadata' put: self metadata; + at: 'url' put: self url. ^ newPage ] @@ -162,7 +164,6 @@ HedgeDoc >> url: anObject [ (html xpath: '//head/meta[@name="application-name"][@content = "HedgeDoc - Ideas grow better together"]') isEmpty ifTrue: [ self inform: 'Not a hedgedoc url'. url := nil ]. - self metadata at: 'title' put: tempUrl firstPathSegment. server := tempUrl host. url := anObject ] diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index c99a7f2..c155ec9 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -160,7 +160,10 @@ Markdown >> fromFile: aFileReference [ { #category : #'instance creation' } Markdown >> fromString: markdownString [ markdownString yamlMetadata - ifNotNil: [(self metadata) at: 'original' put: markdownString yamlMetadata]. + ifNotNil: [ + self metadata + ifEmpty: [self metadata: markdownString yamlMetadata] + ifNotEmpty: [self metadata at: 'original' put: markdownString yamlMetadata]]. self body: markdownString contentsWithoutYAMLMetadata ] @@ -190,6 +193,7 @@ Markdown >> lines [ Markdown >> metadata [ ^ metadata ifNil: [ metadata := Dictionary new]. + ]