GrafoscopioUtils/repository/Grafoscopio-Utils/Markdeep.class.st

127 lines
2.7 KiB
Smalltalk

"
I model a Mardeep file as described in https://casual-effects.com/markdeep/
"
Class {
#name : #Markdeep,
#superclass : #Object,
#instVars : [
'tocStyle',
'header',
'tail',
'body',
'language',
'markdownFile'
],
#category : #'Grafoscopio-Utils'
}
{ #category : #'as yet unclassified' }
Markdeep class >> fromMarkdownFile: aFileReference [
^ self new fromMarkdownFile: aFileReference.
]
{ #category : #accessing }
Markdeep >> body [
^ body
]
{ #category : #accessing }
Markdeep >> body: anObject [
body := anObject
]
{ #category : #'instance creation' }
Markdeep >> contents [
| output |
output := '' writeStream.
output
nextPutAll: self header; crlf;
nextPutAll: (self body); crlf;
nextPutAll: self tail.
^ output contents.
]
{ #category : #utilities }
Markdeep >> fontAwesomeHeader [
"I enable the font awesome support in the document header"
^ ' <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
'
]
{ #category : #'instance creation' }
Markdeep >> fromMarkdownFile: aFileReference [
"I create a Markdeep document from a given Markdown file."
self processMarkdownFor: aFileReference.
^ self contents.
]
{ #category : #accessing }
Markdeep >> header [
^ self fontAwesomeHeader
]
{ #category : #accessing }
Markdeep >> header: anObject [
header := anObject
]
{ #category : #accessing }
Markdeep >> language [
^ language
]
{ #category : #accessing }
Markdeep >> language: anObject [
language := anObject
]
{ #category : #accessing }
Markdeep >> markdownFile [
^ markdownFile
]
{ #category : #accessing }
Markdeep >> markdownFile: aFileReference [
"I provide information about which Markdown file was used to generate the Markdeep body"
markdownFile := aFileReference
]
{ #category : #'instance creation' }
Markdeep >> processMarkdownFor: aFileReference [
"comment stating purpose of message"
self markdownFile: aFileReference.
self body: (self markdownFile contents).
]
{ #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>--> '
]
{ #category : #accessing }
Markdeep >> tail: anObject [
tail := anObject
]
{ #category : #accessing }
Markdeep >> tocStyle [
^ tocStyle
]
{ #category : #accessing }
Markdeep >> tocStyle: anObject [
tocStyle := anObject
]