diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index 40d5a73..2726ed1 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -166,7 +166,7 @@ Markdown >> fromString: markdownString [ bodyTemp nextPutAll: paragraph; cr; cr ]. self body: bodyTemp contents withInternetLineEndings. - yamlMetadataRaw + (yamlMetadataRaw sanitizeMultilineValuesWith: markdownString) ifNotNil: [ self metadata ifEmpty: [ self metadata: yamlMetadataRaw ] diff --git a/src/MiniDocs/OrderedDictionary.extension.st b/src/MiniDocs/OrderedDictionary.extension.st index 0ece656..8d71a79 100644 --- a/src/MiniDocs/OrderedDictionary.extension.st +++ b/src/MiniDocs/OrderedDictionary.extension.st @@ -64,12 +64,20 @@ OrderedDictionary >> replaceWithUniqueNilsAndBooleansStartingAt: anInteger [ { #category : #'*MiniDocs' } OrderedDictionary >> sanitizeMultilineValuesWith: aString [ - | toSanitize | + | toSanitize response | toSanitize := OrderedCollection new. + response := OrderedCollection new. self keysAndValuesDo: [:k :v | - (v isString and: [v lines size > 1]) ifTrue: [ toSanitize add: k ] + (v isString and: [v lines size > 1]) + ifTrue: [ + aString lines + detect: [:line | line includesSubstring: k ] + ifFound: [:line | | sanitized| + sanitized := (line withoutPrefix: k, ':'), String cr, + v indentedWithExtraSpaces: 4. + self at: k put: sanitized ] + ] ]. - ^ toSanitize ] { #category : #'*MiniDocs' } diff --git a/src/MiniDocs/String.extension.st b/src/MiniDocs/String.extension.st index b8087d6..be6ce55 100644 --- a/src/MiniDocs/String.extension.st +++ b/src/MiniDocs/String.extension.st @@ -105,6 +105,16 @@ String >> detectYAMLMetadata [ ifFound: [ ^ true ] ifNone: [ ^ false ] ] ] +{ #category : #'*MiniDocs' } +String >> indentedWithExtraSpaces: spaceNumber [ + | response indent | + response := '' writeStream. + indent := String new. + spaceNumber timesRepeat: [ indent := indent, ' ' ]. + self lines do: [:line | response nextPutAll: indent, line, String lf ]. + ^ response contents +] + { #category : #'*MiniDocs' } String >> markdownHeaders [ | response headers |