Sanitizing YAML dictionaries.
This commit is contained in:
parent
6825d9f242
commit
60294a40b9
@ -166,7 +166,7 @@ Markdown >> fromString: markdownString [
|
|||||||
bodyTemp nextPutAll: paragraph; cr; cr
|
bodyTemp nextPutAll: paragraph; cr; cr
|
||||||
].
|
].
|
||||||
self body: bodyTemp contents withInternetLineEndings.
|
self body: bodyTemp contents withInternetLineEndings.
|
||||||
yamlMetadataRaw
|
(yamlMetadataRaw sanitizeMultilineValuesWith: markdownString)
|
||||||
ifNotNil: [
|
ifNotNil: [
|
||||||
self metadata
|
self metadata
|
||||||
ifEmpty: [ self metadata: yamlMetadataRaw ]
|
ifEmpty: [ self metadata: yamlMetadataRaw ]
|
||||||
|
@ -64,12 +64,20 @@ OrderedDictionary >> replaceWithUniqueNilsAndBooleansStartingAt: anInteger [
|
|||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
OrderedDictionary >> sanitizeMultilineValuesWith: aString [
|
OrderedDictionary >> sanitizeMultilineValuesWith: aString [
|
||||||
| toSanitize |
|
| toSanitize response |
|
||||||
toSanitize := OrderedCollection new.
|
toSanitize := OrderedCollection new.
|
||||||
|
response := OrderedCollection new.
|
||||||
self keysAndValuesDo: [:k :v |
|
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' }
|
{ #category : #'*MiniDocs' }
|
||||||
|
@ -105,6 +105,16 @@ String >> detectYAMLMetadata [
|
|||||||
ifFound: [ ^ true ] ifNone: [ ^ false ] ]
|
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' }
|
{ #category : #'*MiniDocs' }
|
||||||
String >> markdownHeaders [
|
String >> markdownHeaders [
|
||||||
| response headers |
|
| response headers |
|
||||||
|
Loading…
Reference in New Issue
Block a user