diff --git a/repository/Grafoscopio-Utils/LePage.extension.st b/repository/Grafoscopio-Utils/LePage.extension.st index dfd1b89..260d2de 100644 --- a/repository/Grafoscopio-Utils/LePage.extension.st +++ b/repository/Grafoscopio-Utils/LePage.extension.st @@ -5,9 +5,10 @@ LePage >> asMarkdeep [ | bodyStream | bodyStream := '' writeStream. self preorderTraversal do: [:snippet | - bodyStream nextPutAll: snippet contentAsString; lf; lf. + bodyStream nextPutAll: snippet asMarkdeep ]. ^ Markdeep new + title: self title; body: bodyStream contents contents. ] @@ -17,3 +18,15 @@ LePage >> asMarkdeepInto: aFileLocator [ self preorderTraversal ] + +{ #category : #'*Grafoscopio-Utils-Core' } +LePage >> fileName [ + ^ self title asDashedLowercase, '.', ((self uidString copyFrom: 1 to: 5 ) copyWithoutAll: '/'), '.md.html' +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LePage >> markdeepTemporalFile [ + | fileName | + fileName := self title asDashedLowercase, '.',(self uidString copyFrom: 1 to: 5), '.md.html'. + ^ FileLocator temp / fileName. +] diff --git a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st new file mode 100644 index 0000000..7821bde --- /dev/null +++ b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st @@ -0,0 +1,41 @@ +Extension { #name : #LeTextualSnippet } + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextualSnippet >> asMarkdeep [ + | output | + output := '' writeStream. + output + nextPutAll: '
'; lf; + nextPutAll: self markdeepCustomOpener; + nextPutAll: self contentAsString; lf; + nextPutAll: self markdeepCustomCloser; + nextPutAll: '
'; lf; lf. + ^ output contents +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextualSnippet >> childrenIds [ + ^ self children select: [ :each | each uidString ] +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextualSnippet >> markdeepCustomCloser [ + ^ '' +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextualSnippet >> markdeepCustomOpener [ + ^ '' +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextualSnippet >> metadata [ + ^ OrderedDictionary new + at:'id' put: self uidString; + at: 'created' put: self createTime asString; + at: 'edited' put: self latestEditTime asString; + at: 'creator' put: self createEmail asString; + at: 'editor' put: self editEmail asString; + yourself. +] diff --git a/repository/Grafoscopio-Utils/Markdeep.class.st b/repository/Grafoscopio-Utils/Markdeep.class.st index 94b28ea..7e67181 100644 --- a/repository/Grafoscopio-Utils/Markdeep.class.st +++ b/repository/Grafoscopio-Utils/Markdeep.class.st @@ -5,15 +5,14 @@ Class { #name : #Markdeep, #superclass : #Object, #instVars : [ + 'title', + 'body', 'tocStyle', 'comments', 'header', 'tail', - 'body', 'language', - 'markdownFile', - 'config', - 'title' + 'config' ], #category : #'Grafoscopio-Utils-Core' } @@ -72,14 +71,27 @@ Markdeep >> commentsSupport [ ^ self commentsProviderStrings at: self commentsProvider ] +{ #category : #accessing } +Markdeep >> config [ + + ^ config +] + +{ #category : #accessing } +Markdeep >> config: aDictionary [ + + config := aDictionary +] + { #category : #'instance creation' } Markdeep >> contents [ | output | output := '' writeStream. output - nextPutAll: self header; crlf; - nextPutAll: self body; crlf; - nextPutAll: self tail; crlf; crlf; + nextPutAll: self header; lf; lf; + nextPutAll: ' **', self title, '**'; lf; lf; + nextPutAll: self body; lf; lf; + nextPutAll: self tail; lf; lf; lf; lf; nextPutAll: self commentsSupport. ^ output contents. ] @@ -97,7 +109,8 @@ Markdeep >> exportAsFileOn: aFileReference [ aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. aFileReference writeStreamDo: [ :stream | stream nextPutAll: self contents ]. - self inform: 'Exported as: ', String cr, aFileReference fullName + self inform: 'Exported as: ', String cr, aFileReference fullName. + ^ aFileReference ] { #category : #utilities } @@ -115,6 +128,14 @@ Markdeep >> fromMarkdownFile: aFileReference [ ^ self. ] +{ #category : #accessing } +Markdeep >> gtTextFor: aView [ + + ^ aView textEditor + title: 'Text'; + text: [ self contents ] +] + { #category : #accessing } Markdeep >> header [ ^ self fontAwesomeHeader @@ -135,15 +156,32 @@ Markdeep >> language: anObject [ language := anObject ] +{ #category : #accessing } +Markdeep >> markdeepScriptTag [ + ^ ' +' +] + { #category : #accessing } Markdeep >> markdownFile [ - ^ markdownFile + ^ self config at: 'markdownFile' ] { #category : #accessing } Markdeep >> markdownFile: aFileReference [ - "I provide information about which Markdown file was used to generate the Markdeep body" - markdownFile := aFileReference + "Where the Mardown file associated with me is stored. Used for sync. and import/export purposes." + self config at: 'markdownFile' put: aFileReference +] + +{ #category : #printing } +Markdeep >> printOn: aStream [ + + super printOn: aStream. + aStream + nextPutAll: '( ', self title, ' )' ] { #category : #'instance creation' } @@ -158,17 +196,15 @@ Markdeep >> processMarkdownFor: aFileReference [ { #category : #accessing } Markdeep >> tail [ "I enable the document tail, which, in turn, enables a Markdeep document" - ^ ' - - - - - - - ' + | output | + output := '' writeStream. + output + nextPutAll: ''; lf; lf; + nextPutAll: ''; lf; + nextPutAll: ''; lf; + nextPutAll: self markdeepScriptTag; lf; + nextPutAll: ''. + ^ output contents ] { #category : #accessing } @@ -176,9 +212,21 @@ Markdeep >> tail: anObject [ tail := anObject ] +{ #category : #accessing } +Markdeep >> title [ + + ^ title +] + +{ #category : #accessing } +Markdeep >> title: anObject [ + + title := anObject +] + { #category : #accessing } Markdeep >> tocStyle [ - ^ tocStyle + ^ tocStyle ifNil: [ tocStyle := 'short' ] ] { #category : #accessing }