From 690ae86e2fab0600b324703751f4e1127c9920e3 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 12 Mar 2023 11:40:07 -0500 Subject: [PATCH] Refactoring class and methods hierarchies. --- src/MiniDocs/Markdeep.class.st | 16 +++------------- src/MiniDocs/Markdown.class.st | 11 +++++++++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index a202feb..1fd80a4 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -3,15 +3,13 @@ I model a Mardeep file as described in https://casual-effects.com/markdeep/ " Class { #name : #Markdeep, - #superclass : #Object, + #superclass : #Markdown, #instVars : [ 'title', - 'body', 'comments', 'tail', 'language', 'config', - 'metadata', 'head', 'navTop', 'options' @@ -146,18 +144,10 @@ Markdeep >> contents [ Markdeep >> exportAsFile [ | newFile | self markdownFile ifNil: [ self inform: 'Define an input Markdown file or use #exportAsFileOn: instead.' ]. - newFile := (self markdownFile file fullName, '.html') asFileReference. + newFile := (self markdownFile fullName, '.html') asFileReference. ^ self notifyExportAsFileOn: newFile. ] -{ #category : #persistence } -Markdeep >> exportAsFileOn: aFileReference [ - aFileReference ensureDelete. - aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. - aFileReference writeStreamDo: [ :stream | - stream nextPutAll: self contents ]. -] - { #category : #utilities } Markdeep >> fontAwesomeHeader [ "I enable the font awesome support in the document header" @@ -231,7 +221,7 @@ Markdeep >> markdeepScriptTag [ { #category : #accessing } Markdeep >> markdownFile [ - ^ Markdown new fromFile: (self config at: 'markdownFile') + ^ self file ifNil: [ self file: FileLocator temp / ('untitled--', NanoID generate, '.md')]. ] { #category : #accessing } diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index b0ca824..48a439c 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -6,9 +6,8 @@ particularly the ones provided by Pandoc and/or Lunamark. " Class { #name : #Markdown, - #superclass : #Object, + #superclass : #MarkupFile, #instVars : [ - 'file', 'metadata', 'body' ], @@ -75,6 +74,14 @@ Markdown >> detectYAMLMetadata [ ifFound: [ ^ true ] ifNone: [ ^ false ] ] ] +{ #category : #persistence } +Markdown >> exportAsFileOn: aFileReference [ + aFileReference ensureDelete. + aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. + aFileReference writeStreamDo: [ :stream | + stream nextPutAll: self contents ]. +] + { #category : #operation } Markdown >> exportMetadataAsJson [ "TBD: Lua scripts should be checked and installed when missing. Maybe a shared location