Improving Markdeep.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-05-02 13:28:13 +00:00
parent 0bf527c0f3
commit bd897d8def
3 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,16 @@
Class {
#name : #MarkupFile,
#superclass : #Object,
#instVars : [
'file'
],
#category : #'Grafoscopio-Utils'
}
{ #category : #persistence }
MarkupFile class >> exportAsFileOn: aFileReference containing: contents [
aFileReference exists ifFalse: [ aFileReference ensureCreateFile ].
aFileReference writeStreamDo: [ :stream |
stream nextPutAll: contents ].
self inform: 'Exported as: ', String cr, aFileReference fullName
]

View File

@ -0,0 +1,46 @@
"
I provide some utilites to work with OrgMode files.
https://orgmode.org/
"
Class {
#name : #OrgMode,
#superclass : #Object,
#instVars : [
'contents',
'file'
],
#category : #'Grafoscopio-Utils'
}
{ #category : #'instance creation' }
OrgMode class >> fromFile: aFileReference [
^ self new contents: aFileReference contents.
]
{ #category : #accessing }
OrgMode >> contents [
^ contents
]
{ #category : #accessing }
OrgMode >> contents: anObject [
contents := anObject
]
{ #category : #accessing }
OrgMode >> file [
^ file
]
{ #category : #accessing }
OrgMode >> file: anObject [
file := anObject
]
{ #category : #utilities }
OrgMode >> selectHeadlines [
^ self contents lines select: [ :line |
line isOrgModeHeader ]
]

View File

@ -0,0 +1,15 @@
Extension { #name : #String }
{ #category : #'*Grafoscopio-Utils' }
String >> asCapitalizedPhrase [
"I convert phrases like 'THIS IS A PHASE' into 'This is a Phrase'."
^ Character space join: (self substrings collect: [:each | each asLowercase capitalized ])
]
{ #category : #'*Grafoscopio-Utils' }
String >> isOrgModeHeader [
^ self beginsWithAnyOf: #('* ' '** ' '*** ' '**** ' '***** ' '***** ')
]