diff --git a/repository/Grafoscopio-Utils/Markdown.class.st b/repository/Grafoscopio-Utils/Markdown.class.st index fc85dad..752091a 100644 --- a/repository/Grafoscopio-Utils/Markdown.class.st +++ b/repository/Grafoscopio-Utils/Markdown.class.st @@ -31,8 +31,7 @@ Markdown >> commentYAMLMetadata [ self detectYAMLMetadata ifFalse: [ ^ self ]. newContents := '' writeStream. newContents nextPutAll: ''; crlf. (self lines copyFrom: self locateYAMLMetadataClosing + 2 to: self lines size) do: [ :line | @@ -97,8 +96,15 @@ Markdown >> exportMetadataAsYaml [ { #category : #operation } Markdown >> extractYAMLMetadata [ + | output yamlLines | self detectYAMLMetadata ifFalse: [ ^ nil ]. - ^ self lines copyFrom: 2 to: (self locateYAMLMetadataClosing) + yamlLines := self lines copyFrom: 2 to: (self locateYAMLMetadataClosing). + output := '' writeStream. + yamlLines do: [ :line | + output + nextPutAll: line; + nextPut: Character cr. ]. + ^ output contents ] { #category : #accessing } @@ -138,7 +144,7 @@ Markdown >> locateYAMLMetadataClosing [ { #category : #accessing } Markdown >> metadata [ - ^ NeoJSONReader fromString: self exportMetadataAsJson. + ^ PPYAMLGrammar new parse: self extractYAMLMetadata. ] { #category : #utilities } @@ -153,9 +159,7 @@ Markdown >> yamlMetadataAsString [ self extractYAMLMetadata ifNil: [ ^ nil ]. output := String new writeStream. output nextPutAll: self class yamlMetadataDelimiter; cr. - self extractYAMLMetadata do: [ :line | - output nextPutAll: line; cr. - ]. + output nextPutAll: self extractYAMLMetadata. output nextPutAll: self class yamlMetadataDelimiter; cr. ^ output contents. ]