From 738697bc631c2686d6b4b0c9a1409277419b5c70 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sat, 14 Dec 2024 17:07:55 -0500 Subject: [PATCH] Using other YAML prepackaged parsers. --- src/MiniDocs/Markdown.class.st | 14 ++++++++++---- src/MiniDocs/OrderedDictionary.extension.st | 10 ++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index 804ed0d..40d5a73 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -159,12 +159,18 @@ Markdown >> fromFile: aFileReference [ { #category : #'instance creation' } Markdown >> fromString: markdownString [ - markdownString yamlMetadata + | yamlMetadataRaw bodyTemp | + yamlMetadataRaw := (YamlHeaderParser parse: markdownString). + bodyTemp := '' writeStream. + (yamlMetadataRaw removeKey: 'body') do: [:paragraph | + bodyTemp nextPutAll: paragraph; cr; cr + ]. + self body: bodyTemp contents withInternetLineEndings. + yamlMetadataRaw ifNotNil: [ self metadata - ifEmpty: [self metadata: markdownString yamlMetadata] - ifNotEmpty: [self metadata at: 'original' put: markdownString yamlMetadata]]. - self body: markdownString contentsWithoutYAMLMetadata + ifEmpty: [ self metadata: yamlMetadataRaw ] + ifNotEmpty: [ self metadata at: 'hedgeDoc' put: yamlMetadataRaw ]]. ] { #category : #accessing } diff --git a/src/MiniDocs/OrderedDictionary.extension.st b/src/MiniDocs/OrderedDictionary.extension.st index 28f7956..0ece656 100644 --- a/src/MiniDocs/OrderedDictionary.extension.st +++ b/src/MiniDocs/OrderedDictionary.extension.st @@ -62,6 +62,16 @@ OrderedDictionary >> replaceWithUniqueNilsAndBooleansStartingAt: anInteger [ ] ] +{ #category : #'*MiniDocs' } +OrderedDictionary >> sanitizeMultilineValuesWith: aString [ + | toSanitize | + toSanitize := OrderedCollection new. + self keysAndValuesDo: [:k :v | + (v isString and: [v lines size > 1]) ifTrue: [ toSanitize add: k ] + ]. + ^ toSanitize +] + { #category : #'*MiniDocs' } OrderedDictionary >> treeView [ | view |