Markdeep exportation for Lepiter, early prototype.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-01-23 20:38:07 -05:00
parent 05d2f3b182
commit d5d052dc5a
3 changed files with 126 additions and 24 deletions

View File

@ -5,9 +5,10 @@ LePage >> asMarkdeep [
| bodyStream | | bodyStream |
bodyStream := '' writeStream. bodyStream := '' writeStream.
self preorderTraversal do: [:snippet | self preorderTraversal do: [:snippet |
bodyStream nextPutAll: snippet contentAsString; lf; lf. bodyStream nextPutAll: snippet asMarkdeep
]. ].
^ Markdeep new ^ Markdeep new
title: self title;
body: bodyStream contents body: bodyStream contents
contents. contents.
] ]
@ -17,3 +18,15 @@ LePage >> asMarkdeepInto: aFileLocator [
self preorderTraversal 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.
]

View File

@ -0,0 +1,41 @@
Extension { #name : #LeTextualSnippet }
{ #category : #'*Grafoscopio-Utils-Core' }
LeTextualSnippet >> asMarkdeep [
| output |
output := '' writeStream.
output
nextPutAll: '<div x-class="', self class asString, '" '; lf;
nextPutAll: 'x-data="', (STON toString: self metadata), '">'; lf;
nextPutAll: self markdeepCustomOpener;
nextPutAll: self contentAsString; lf;
nextPutAll: self markdeepCustomCloser;
nextPutAll: '</div>'; 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.
]

View File

@ -5,15 +5,14 @@ Class {
#name : #Markdeep, #name : #Markdeep,
#superclass : #Object, #superclass : #Object,
#instVars : [ #instVars : [
'title',
'body',
'tocStyle', 'tocStyle',
'comments', 'comments',
'header', 'header',
'tail', 'tail',
'body',
'language', 'language',
'markdownFile', 'config'
'config',
'title'
], ],
#category : #'Grafoscopio-Utils-Core' #category : #'Grafoscopio-Utils-Core'
} }
@ -72,14 +71,27 @@ Markdeep >> commentsSupport [
^ self commentsProviderStrings at: self commentsProvider ^ self commentsProviderStrings at: self commentsProvider
] ]
{ #category : #accessing }
Markdeep >> config [
^ config
]
{ #category : #accessing }
Markdeep >> config: aDictionary [
config := aDictionary
]
{ #category : #'instance creation' } { #category : #'instance creation' }
Markdeep >> contents [ Markdeep >> contents [
| output | | output |
output := '' writeStream. output := '' writeStream.
output output
nextPutAll: self header; crlf; nextPutAll: self header; lf; lf;
nextPutAll: self body; crlf; nextPutAll: ' **', self title, '**'; lf; lf;
nextPutAll: self tail; crlf; crlf; nextPutAll: self body; lf; lf;
nextPutAll: self tail; lf; lf; lf; lf;
nextPutAll: self commentsSupport. nextPutAll: self commentsSupport.
^ output contents. ^ output contents.
] ]
@ -97,7 +109,8 @@ Markdeep >> exportAsFileOn: aFileReference [
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ]. aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
aFileReference writeStreamDo: [ :stream | aFileReference writeStreamDo: [ :stream |
stream nextPutAll: self contents ]. stream nextPutAll: self contents ].
self inform: 'Exported as: ', String cr, aFileReference fullName self inform: 'Exported as: ', String cr, aFileReference fullName.
^ aFileReference
] ]
{ #category : #utilities } { #category : #utilities }
@ -115,6 +128,14 @@ Markdeep >> fromMarkdownFile: aFileReference [
^ self. ^ self.
] ]
{ #category : #accessing }
Markdeep >> gtTextFor: aView [
<gtView>
^ aView textEditor
title: 'Text';
text: [ self contents ]
]
{ #category : #accessing } { #category : #accessing }
Markdeep >> header [ Markdeep >> header [
^ self fontAwesomeHeader ^ self fontAwesomeHeader
@ -135,15 +156,32 @@ Markdeep >> language: anObject [
language := anObject language := anObject
] ]
{ #category : #accessing }
Markdeep >> markdeepScriptTag [
^ '<script src="markdeep.min.js" charset="utf-8"></script>
<script
src="https://casual-effects.com/markdeep/latest/markdeep.min.js?"
charset="utf-8">
</script>'
]
{ #category : #accessing } { #category : #accessing }
Markdeep >> markdownFile [ Markdeep >> markdownFile [
^ markdownFile ^ self config at: 'markdownFile'
] ]
{ #category : #accessing } { #category : #accessing }
Markdeep >> markdownFile: aFileReference [ Markdeep >> markdownFile: aFileReference [
"I provide information about which Markdown file was used to generate the Markdeep body" "Where the Mardown file associated with me is stored. Used for sync. and import/export purposes."
markdownFile := aFileReference self config at: 'markdownFile' put: aFileReference
]
{ #category : #printing }
Markdeep >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self title, ' )'
] ]
{ #category : #'instance creation' } { #category : #'instance creation' }
@ -158,17 +196,15 @@ Markdeep >> processMarkdownFor: aFileReference [
{ #category : #accessing } { #category : #accessing }
Markdeep >> tail [ Markdeep >> tail [
"I enable the document tail, which, in turn, enables a Markdeep document" "I enable the document tail, which, in turn, enables a Markdeep document"
^ ' | output |
<!-- Markdeep: --> output := '' writeStream.
output
<style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style> nextPutAll: '<!-- Markdeep: -->'; lf; lf;
<script>window.markdeepOptions = {tocStyle: "medium"}</script> nextPutAll: '<style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style>'; lf;
<script src="markdeep.min.js" charset="utf-8"></script> nextPutAll: '<script>window.markdeepOptions = {tocStyle: "', self tocStyle,'"}</script>'; lf;
<script nextPutAll: self markdeepScriptTag; lf;
src="https://casual-effects.com/markdeep/latest/markdeep.min.js?" nextPutAll: '<!--<script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>-->'.
charset="utf-8"> ^ output contents
</script>
<!--<script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>--> '
] ]
{ #category : #accessing } { #category : #accessing }
@ -176,9 +212,21 @@ Markdeep >> tail: anObject [
tail := anObject tail := anObject
] ]
{ #category : #accessing }
Markdeep >> title [
^ title
]
{ #category : #accessing }
Markdeep >> title: anObject [
title := anObject
]
{ #category : #accessing } { #category : #accessing }
Markdeep >> tocStyle [ Markdeep >> tocStyle [
^ tocStyle ^ tocStyle ifNil: [ tocStyle := 'short' ]
] ]
{ #category : #accessing } { #category : #accessing }