From fb64d5c1aefbbaee2f9ef562254757d5c52adf00 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 2 Aug 2024 12:35:21 -0500 Subject: [PATCH] Improving management of empty YAML metadata. --- src/MiniDocs/Markdown.class.st | 3 ++- src/MiniDocs/String.extension.st | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index cf759c4..1696097 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -159,7 +159,8 @@ Markdown >> fromFile: aFileReference [ { #category : #'instance creation' } Markdown >> fromString: markdownString [ - (self metadata) at: 'original' put: markdownString yamlMetadata. + markdownString yamlMetadata + ifNotNil: [(self metadata) at: 'original' put: markdownString yamlMetadata]. self body: markdownString contentsWithoutYAMLMetadata ] diff --git a/src/MiniDocs/String.extension.st b/src/MiniDocs/String.extension.st index 7ec24cb..a619ac6 100644 --- a/src/MiniDocs/String.extension.st +++ b/src/MiniDocs/String.extension.st @@ -118,6 +118,7 @@ String >> withoutXMLTagDelimiters [ { #category : #'*MiniDocs' } String >> yamlMetadata [ + self yamlMetadataString ifNil: [^ nil ]. ^ (YAML2JSON fromString: self yamlMetadataString) ]