Skip to content

Commit

Permalink
Removing the notion of syntaxState.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Dec 1, 2024
1 parent f76c9a4 commit c4f1a75
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 133 deletions.
9 changes: 1 addition & 8 deletions src/MicroEd-Spec-Tests/MDEditorFilePresenterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ MDEditorFilePresenterTest >> testGotMicrodownParser [
self assert: presenter microdownParser class equals: MicrodownParser
]

{ #category : 'tests' }
MDEditorFilePresenterTest >> testGotSyntaxStateWhenIsNotSpecify [

presenter syntaxState: MDMicroDownSyntax new.
self assert: presenter syntaxState class equals: MDMicroDownSyntax
]

{ #category : 'running' }
MDEditorFilePresenterTest >> testMDFileOverwriteFileReferenceWhenAnotherSameFile [

Expand Down Expand Up @@ -108,7 +101,7 @@ MDEditorFilePresenterTest >> testSaveWithExtension [
{ #category : 'tests' }
MDEditorFilePresenterTest >> testTextInputTextIsNotSpecify [

self assert: presenter textInputText equals: '% Type your marked-up text here. Render it and see right the output generated as rich text', String cr, String cr, presenter syntaxState exampleText
self assert: presenter textInputText equals: '% Type your marked-up text here. Render it and see right the output generated as rich text', String cr, String cr, presenter exampleText
]

{ #category : 'tests' }
Expand Down
60 changes: 55 additions & 5 deletions src/MicroEd-Spec/MDEditorPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,56 @@ MDEditorPresenter >> defaultLayout [
yourself
]

{ #category : 'utilities' }
MDEditorPresenter >> exampleText [

^ '# Header
A figure:
![Pharologo %width=80&caption=Our great figure.](https://files.pharo.org/media/logo/logo.png)
A link: [http://pharo.org](http://pharo.org)
Unordered Lists:
- item 1
- item 1.1
- item 1.2
- item 2
- item 3
- item 3.1
Ordered Lists:
1. sub item 1
3. sub item 2
and nested
- item 1
1. sub item 1
3. sub item 2
- item 2
Horizontal line:
***
Common formats: **Bold**, _italic_, `monospace`
Pharo hyperlinks in code:
- class `Point`,
- method `Point class`, `Point>>#setX:setY:`, and
- package `#’Microdown-Tests’ (for packages).
A codeblock:
```language=Pharo&caption=Beautiful&label=Fig1
this is a codeblock
```
'
]

{ #category : 'api' }
MDEditorPresenter >> initializeMenuBar [

Expand Down Expand Up @@ -111,8 +161,7 @@ MDEditorPresenter >> initializeMenuBar [
MDEditorPresenter >> initializePresenters [

| initialText |
self syntaxState: MDMicroDownSyntax new.
initialText := '% Type your marked-up text here. Render it and see right the output generated as rich text', String cr, String cr, self syntaxState exampleText.
initialText := '% Type your marked-up text here. Render it and see right the output generated as rich text', String cr, String cr, self exampleText.

self initializePresentersWithText: initialText.

Expand Down Expand Up @@ -148,7 +197,7 @@ MDEditorPresenter >> initializeWindow: aWindowPresenter [
aWindowPresenter
title: self title;
initialExtent: 800 @ 600;
windowIcon: (self application iconNamed: #glamorousBrowseIcon)
windowIcon: (self application iconNamed: #browseIcon)
]

{ #category : 'accessing' }
Expand All @@ -160,7 +209,7 @@ MDEditorPresenter >> mdFile [
{ #category : 'accessing' }
MDEditorPresenter >> mdFile: aMDFile [

mdFile := aMDFile.
mdFile := aMDFile
]

{ #category : 'utilities' }
Expand All @@ -179,7 +228,8 @@ MDEditorPresenter >> openFile [
openModal.
selectedFile
ifNotNil: [
self mdFile: (MDFile new file: selectedFile).

self mdFile: (MDFile newFromFileReference: selectedFile asFileReference).
textInput text: selectedFile contents.
self cleanOutput.
self updateTitle ]
Expand Down
24 changes: 11 additions & 13 deletions src/MicroEd-Tests/MDFileTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ MDFileTest >> setUp [
toDelete := OrderedCollection new.
mdfile := MDFile new.
fileExample := memoryFS / 'example.md'.
fileReferenceWithName := (memoryFS / 'anotherFile.md')
ensureCreateFile.
fileReferenceWithName := (memoryFS / 'anotherFile.md') ensureCreateFile.
toDelete add: fileExample.
fileExample writeStreamDo: [ :stream |
stream nextPutAll: 'example file' ].

parser := MicrodownParser new.
]

Expand All @@ -39,23 +37,23 @@ MDFileTest >> tearDown [
super tearDown
]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileCreationWithExistingFile [

mdfile initializeWithFileReference: fileExample.
self assert: mdfile hasFile.

]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileCreationWithoutExistingFile [

| fileWithoutFileReference |
fileWithoutFileReference := MDFile new.
self assert: fileWithoutFileReference hasFile not.
]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileExistingFileWithName [


Expand All @@ -69,7 +67,7 @@ MDFileTest >> testMDFileExistingFileWithName [

]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileExistingFileWithoutName [

| file fileReferenceWithoutName |
Expand All @@ -82,7 +80,7 @@ MDFileTest >> testMDFileExistingFileWithoutName [

]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileHasFileReferenceAddMetaData [

| root file |
Expand All @@ -98,7 +96,7 @@ MDFileTest >> testMDFileHasFileReferenceAddMetaData [

]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileHasFileReferenceHasMetaData [

| root file |
Expand All @@ -117,7 +115,7 @@ MDFileTest >> testMDFileHasFileReferenceHasMetaData [

]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileHasFileReferenceHasNotMetaData [

| root file |
Expand All @@ -131,7 +129,7 @@ MDFileTest >> testMDFileHasFileReferenceHasNotMetaData [

]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileHasFileReferenceWithFormatISO [

| file date |
Expand All @@ -141,10 +139,10 @@ MDFileTest >> testMDFileHasFileReferenceWithFormatISO [
self deny: (fileReferenceWithName exists )
]

{ #category : 'running' }
{ #category : 'tests' }
MDFileTest >> testMDFileUnderstandFile [

mdfile initializeWithFileReference: fileExample.
self assert: mdfile file class equals: FileReference.
self assert: mdfile fileReference class equals: FileReference.

]
21 changes: 0 additions & 21 deletions src/MicroEd-Tests/MDMicroDownSyntaxTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,3 @@ Class {
#category : 'MicroEd-Tests',
#package : 'MicroEd-Tests'
}

{ #category : 'tests' }
MDMicroDownSyntaxTest >> testGotExtensionWhenIsNotSpecify [

syntax := MDMicroDownSyntax new.
self assert: syntax extension equals: 'md'
]

{ #category : 'tests' }
MDMicroDownSyntaxTest >> testGotNameWhenIsNotSpecify [

syntax := MDMicroDownSyntax new.
self assert: syntax name equals: 'MicroDown'
]

{ #category : 'tests' }
MDMicroDownSyntaxTest >> testGotParserWhenIsNotSpecify [

syntax := MDMicroDownSyntax new.
self assert: syntax parser equals: MicrodownParser
]
12 changes: 9 additions & 3 deletions src/MicroEd/MDFile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ MDFile >> addMetaDataElements [

| root |
root := MicrodownParser parse: fileReference contents.

root hasMetaDataElement
ifFalse: [
root := MicrodownParser parse: '{
"author" : "addos"
}
'.
}
'.
root metaDataElement
atKey: 'author' put: (fileReference entry reference path at: 3);
atKey: 'title' put: nameOfFileReferenceBeforeSaved;
Expand Down Expand Up @@ -102,6 +102,12 @@ MDFile >> fileReference [
^ fileReference
]

{ #category : 'accessing' }
MDFile >> fileReference: aFileReference [

fileReference := aFileReference
]

{ #category : 'accessing' }
MDFile >> hasFile [

Expand Down
83 changes: 0 additions & 83 deletions src/MicroEd/MDMicroDownSyntax.class.st

This file was deleted.

0 comments on commit c4f1a75

Please sign in to comment.