Modularizing and cleaning to improve upcoming support for tagged snippets.
This commit is contained in:
parent
6072fd8971
commit
94fdf3052f
@ -45,33 +45,8 @@ LeTextualSnippet >> asMarkdownWithMetadataWrappers [
|
|||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeTextualSnippet >> contentAsStringAnnotated [
|
LeTextualSnippet >> contentAsStringAnnotated [
|
||||||
| annotations substitutions exported pageConfig|
|
self ast ifNotNil: [ ^ self processSnippetAnnotations ].
|
||||||
self ast ifNil: [ ^ self contentAsString ].
|
^ self contentAsString
|
||||||
annotations := self ast parts select: [:each | each className includesSubstring: 'AnnotationNode' ].
|
|
||||||
annotations ifEmpty: [ ^ self contentAsString ].
|
|
||||||
substitutions := OrderedDictionary new.
|
|
||||||
pageConfig := self page config.
|
|
||||||
annotations do: [ :each | | key type value color |
|
|
||||||
key := each source.
|
|
||||||
type := (key splitOn: ':') first copyWithoutAll: '{{'.
|
|
||||||
value := key copyFrom: type size + 4 to: key size - 2.
|
|
||||||
pageConfig
|
|
||||||
ifNil: [ color := 'default' ]
|
|
||||||
ifNotNil: [ | colors |
|
|
||||||
colors := pageConfig at: 'annotationColors' ifAbsent: [ nil ].
|
|
||||||
colors ifNotNil: [
|
|
||||||
color := colors at: type ifAbsent: [ colors at: 'defaultColor' ifAbsentPut: ['default'] ]
|
|
||||||
]
|
|
||||||
].
|
|
||||||
substitutions
|
|
||||||
at: key
|
|
||||||
put: '<span st-class="',type,'" style="color:', color, '">', value,'</span>'.
|
|
||||||
].
|
|
||||||
exported := self contentAsString.
|
|
||||||
substitutions keysAndValuesDo: [:k :v |
|
|
||||||
exported := exported copyReplaceAll: k with: v.
|
|
||||||
].
|
|
||||||
^ exported
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
@ -143,6 +118,37 @@ LeTextualSnippet >> metadataUpdate [
|
|||||||
yourself
|
yourself
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
LeTextualSnippet >> processSnippetAnnotations [
|
||||||
|
| exported substitutions annotations pageConfig |
|
||||||
|
annotations := self ast parts
|
||||||
|
select: [ :each | each className includesSubstring: 'AnnotationNode' ].
|
||||||
|
annotations ifEmpty: [ ^ self contentAsString ].
|
||||||
|
substitutions := OrderedDictionary new.
|
||||||
|
pageConfig := self page config.
|
||||||
|
annotations
|
||||||
|
do: [ :each |
|
||||||
|
| key type value color |
|
||||||
|
key := each source.
|
||||||
|
type := (key splitOn: ':') first copyWithoutAll: '{{'.
|
||||||
|
value := key copyFrom: type size + 4 to: key size - 2.
|
||||||
|
pageConfig
|
||||||
|
ifNil: [ color := 'default' ]
|
||||||
|
ifNotNil: [ | colors |
|
||||||
|
colors := pageConfig at: 'annotationColors' ifAbsent: [ nil ].
|
||||||
|
colors
|
||||||
|
ifNotNil: [ color := colors
|
||||||
|
at: type
|
||||||
|
ifAbsent: [ colors at: 'defaultColor' ifAbsentPut: [ 'default' ] ] ] ].
|
||||||
|
substitutions
|
||||||
|
at: key
|
||||||
|
put: '<span st-class="' , type , '" style="color:' , color , '">' , value , '</span>' ].
|
||||||
|
exported := self contentAsString.
|
||||||
|
substitutions
|
||||||
|
keysAndValuesDo: [ :k :v | exported := exported copyReplaceAll: k with: v ].
|
||||||
|
^ exported
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
LeTextualSnippet >> sanitizeMetadata [
|
LeTextualSnippet >> sanitizeMetadata [
|
||||||
self options ifNil: [^ self ].
|
self options ifNil: [^ self ].
|
||||||
|
Loading…
Reference in New Issue
Block a user