Markdown metadata as an object itself. Separating it at creation needs to be implemented.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-03-09 10:10:55 -05:00
parent 11dc04e39f
commit 1fe6a8f548

View File

@ -9,7 +9,8 @@ Class {
#superclass : #Object, #superclass : #Object,
#instVars : [ #instVars : [
'contents', 'contents',
'file' 'file',
'metadata'
], ],
#category : #MiniDocs #category : #MiniDocs
} }
@ -113,6 +114,7 @@ Markdown >> fromFile: aFileReference [
{ #category : #'instance creation' } { #category : #'instance creation' }
Markdown >> fromString: markdownString [ Markdown >> fromString: markdownString [
self contents: markdownString. self contents: markdownString.
self populateMetadata
] ]
{ #category : #accessing } { #category : #accessing }
@ -130,12 +132,25 @@ Markdown >> lines [
{ #category : #accessing } { #category : #accessing }
Markdown >> metadata [ Markdown >> metadata [
^ metadata ifNil: [ metadata := Dictionary new].
]
{ #category : #accessing }
Markdown >> metadata: rawMeta [
metadata := rawMeta
]
{ #category : #accessing }
Markdown >> populateMetadata [
| rawMeta | | rawMeta |
rawMeta := MiniDocs yamlToJson: self yamlMetadataString. rawMeta := MiniDocs yamlToJson: self yamlMetadataString.
rawMeta associationsDo: [ :assoc | rawMeta associationsDo: [ :assoc |
assoc value = 'false' ifTrue: [ assoc value: false ]. assoc value = 'false' ifTrue: [ assoc value: false ].
assoc value = 'true' ifTrue: [ assoc value: true ] ]. assoc value = 'true' ifTrue: [ assoc value: true ] ].
^ rawMeta self metadata: rawMeta
] ]
{ #category : #accessing } { #category : #accessing }