Sanitizing YAML dictionaries.
This commit is contained in:
parent
6825d9f242
commit
60294a40b9
@ -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 ]
|
||||
|
@ -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' }
|
||||
|
@ -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 |
|
||||
|
Loading…
Reference in New Issue
Block a user