-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File parser #744
File parser #744
Changes from all commits
7a02d16
55f5d68
1a264f7
67a9eec
c983b3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,16 @@ MicRootBlock >> canConsumeLine: line [ | |
^ true | ||
] | ||
|
||
{ #category : 'visiting' } | ||
MicRootBlock >> fromFile [ " retieve " | ||
^ self propertyAt: #file . | ||
] | ||
|
||
{ #category : 'visiting' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in visiting |
||
MicRootBlock >> fromFile: aFile [ " put file object in the root" | ||
self propertyAt: #file put: aFile . | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MicRootBlock >> indent [ | ||
^0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,12 @@ Microdown class >> parse: aStreamOrString [ | |
^ self new parse: aStreamOrString | ||
] | ||
|
||
{ #category : 'facade' } | ||
Microdown class >> parseFile: aFile [ | ||
|
||
^ self new parseFile: aFile | ||
] | ||
|
||
{ #category : 'facade' } | ||
Microdown class >> resolveDocument: document withBase: base [ | ||
"resolve all relative urls in document with respect to the absolute uri | ||
|
@@ -146,6 +152,16 @@ Microdown >> parse: aStreamOrString [ | |
^ MicrodownParser parse: aStreamOrString | ||
] | ||
|
||
{ #category : 'facade' } | ||
Microdown >> parseFile: aFile [ | ||
|
||
|root| | ||
root := MicrodownParser parse:(aFile contents) . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parse: (aFile contents). No extra space |
||
root fromFile: aFile . | ||
^ root . | ||
|
||
] | ||
|
||
{ #category : 'facade' } | ||
Microdown >> render: aStringOrDoc [ | ||
"Facade method to render a microdown string to Text" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Class { | ||
#name : 'FileParser', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you rename your class FromFileTest? |
||
#superclass : 'TestCase', | ||
#category : 'microdown-fileParser', | ||
#package : 'microdown-fileParser' | ||
} | ||
|
||
{ #category : 'as yet unclassified' } | ||
FileParser >> testCreatingFileAndParsingtheContent [ | ||
|
||
| file root | | ||
file := (FileSystem workingDirectory / 'myFile.txt') asFileReference. | ||
file ensureCreateFile. | ||
|
||
|
||
|
||
file writeStreamDo: [ :stream | stream nextPutAll: ' | ||
### title | ||
@first | ||
|
||
just talking about somthing @*first*@ ' ] . | ||
|
||
root := Microdown parseFile: file contents . | ||
|
||
self assert: (root isKindOf: MicRootBlock ) . | ||
self assert: root fromFile equals: file contents . | ||
file ensureDelete . | ||
|
||
|
||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package { #name : 'microdown-fileParser' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the last period is not needed.