From 05269ac364c7468b2fa32fffd26537e846a8e8df Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 10 Mar 2024 11:21:53 -0500 Subject: [PATCH] Optimistic reading of a Markdeep file as a live object done. --- src/MiniDocs/Markdeep.class.st | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index 9f9f6e2..03fabae 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -183,7 +183,7 @@ Markdeep >> extractYamlMetadataFrom: documentTree [ yamlComment children allButFirst allButLast do: [:each | response nextPutAll: each text; cr ]. - ^ YAML2JSON fromString: response contents + ^ {YAML2JSON fromString: response contents . yamlComment } ] { #category : #accessing } @@ -194,7 +194,7 @@ Markdeep >> file: aFileReference [ { #category : #accessing } Markdeep >> fillInContentsFrom: aFileReference [ - | docTree docTreeChildren headTree bodyLineIndex | + | docTree docTreeChildren headTree bodyStartLine bodyEndLine contentLines rawMetadata | aFileReference exists ifFalse: [ ^ self ]. docTree := (Markdown new contents: aFileReference contents) documentTree. docTreeChildren := docTree children. @@ -205,15 +205,17 @@ Markdeep >> fillInContentsFrom: aFileReference [ headTree children allButFirst allButLast do: [ :node | node className = 'PPCMHtml' ifTrue: [ self head add: node text ] ]. self head: self head asSet asOrderedCollection. - self metadata: (self extractYamlMetadataFrom: docTree). + rawMetadata := (self extractYamlMetadataFrom: docTree). + self metadata: rawMetadata first. self title: (self metadata at: 'title' ifAbsent: [self extractTitleFrom: docTree]). self title: (self title trimBoth: [ :char | char = $" ]). self metadata at: 'title' put: self title. - bodyLineIndex := docTreeChildren - detectIndex: [ :node | node text includesSubstring: self title ]. - ^ {self . - bodyLineIndex. - docTree } + contentLines := self file contents lines. + bodyStartLine := (contentLines + detectIndex: [ :line | line includesSubstring: '