Markdeep exportation for Lepiter, early prototype.
This commit is contained in:
parent
05d2f3b182
commit
d5d052dc5a
@ -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.
|
||||
]
|
||||
|
41
repository/Grafoscopio-Utils/LeTextualSnippet.extension.st
Normal file
41
repository/Grafoscopio-Utils/LeTextualSnippet.extension.st
Normal 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.
|
||||
]
|
@ -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 [
|
||||
<gtView>
|
||||
^ 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 [
|
||||
^ '<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 }
|
||||
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"
|
||||
^ '
|
||||
<!-- Markdeep: -->
|
||||
|
||||
<style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style>
|
||||
<script>window.markdeepOptions = {tocStyle: "medium"}</script>
|
||||
<script src="markdeep.min.js" charset="utf-8"></script>
|
||||
<script
|
||||
src="https://casual-effects.com/markdeep/latest/markdeep.min.js?"
|
||||
charset="utf-8">
|
||||
</script>
|
||||
<!--<script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>--> '
|
||||
| output |
|
||||
output := '' writeStream.
|
||||
output
|
||||
nextPutAll: '<!-- Markdeep: -->'; lf; lf;
|
||||
nextPutAll: '<style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style>'; lf;
|
||||
nextPutAll: '<script>window.markdeepOptions = {tocStyle: "', self tocStyle,'"}</script>'; lf;
|
||||
nextPutAll: self markdeepScriptTag; lf;
|
||||
nextPutAll: '<!--<script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>-->'.
|
||||
^ 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 }
|
||||
|
Loading…
Reference in New Issue
Block a user