From e22eb1221df11024dfe6d1b2e7bfd5582149dd9a Mon Sep 17 00:00:00 2001 From: Offray Date: Fri, 22 Mar 2024 15:17:39 -0500 Subject: [PATCH 1/2] Improving Markdown importation. --- src/MiniDocs/Markdown.class.st | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index f9bea0c..13bb9c7 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -64,7 +64,10 @@ Markdown >> containsYAMLMetadataClosing [ Markdown >> contents [ | response | response := WriteStream on: ''. - response + response + nextPutAll: '---'; cr; + nextPutAll: self metadataAsYAML; cr; + nextPutAll: '---'; cr; nextPutAll: self body. ^ response contents ] @@ -177,7 +180,8 @@ Markdown >> file: aFileReference [ Markdown >> fromFile: aFileReference [ self contents: aFileReference contents. self file: aFileReference. - self populateMetadata + self populateMetadata. + self body: self contentsWithoutYAMLMetadata ] { #category : #'instance creation' } From a51583e5fc18a857aca1a9c403fd2284dd41e37e Mon Sep 17 00:00:00 2001 From: Offray Date: Fri, 22 Mar 2024 15:42:10 -0500 Subject: [PATCH 2/2] Promoting document title. --- src/MiniDocs/Markdeep.class.st | 1 - src/MiniDocs/Markdown.class.st | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index f94979c..0727910 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -5,7 +5,6 @@ Class { #name : #Markdeep, #superclass : #Markdown, #instVars : [ - 'title', 'comments', 'tail', 'language', diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index 13bb9c7..aca0e1d 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -9,7 +9,8 @@ Class { #superclass : #MarkupFile, #instVars : [ 'metadata', - 'body' + 'body', + 'title' ], #category : #'MiniDocs-Core' } @@ -199,6 +200,14 @@ Markdown >> gtTextFor: aView [ text: [ self contents ] ] +{ #category : #accessing } +Markdown >> headerAsTitle [ + | headerNode | + headerNode := self documentTree children + detect: [ :node | node className = 'PPCMHeader' and: [ node level = 1 ] ] ifNone: [ ^ nil ]. + ^ headerNode text +] + { #category : #utilities } Markdown >> lines [ self file ifNotNil: [^ self file contents lines ]. @@ -245,7 +254,7 @@ Markdown >> populateMetadata [ Markdown >> printOn: aStream [ super printOn: aStream. aStream - nextPutAll: '( ', (self metadata at: 'title' ifAbsent: ['untitled']), ' )' + nextPutAll: '( ', self title , ' )' ] { #category : #utilities } @@ -255,6 +264,11 @@ Markdown >> startsWithYAMLMetadataDelimiter [ ] +{ #category : #accessing } +Markdown >> title [ + ^ self metadata at: 'title' ifAbsentPut: [ self headerAsTitle] +] + { #category : #utilities } Markdown >> yamlMetadataClosingLineNumber [ "I return the line where the closing of the YAML metadata occurs or 0 if no closing is found."