Improving Markdown objects reading from files.
This commit is contained in:
parent
0185c741a1
commit
80afb07c77
@ -62,7 +62,7 @@ Markdown >> contents [
|
||||
response
|
||||
nextPutAll: '---'; cr;
|
||||
nextPutAll: self metadataAsYAML; cr;
|
||||
nextPutAll: '---'; cr;
|
||||
nextPutAll: '---'; cr; cr;
|
||||
nextPutAll: self body.
|
||||
^ response contents
|
||||
]
|
||||
@ -72,16 +72,6 @@ Markdown >> contents: aString [
|
||||
body := aString
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdown >> contentsWithoutYAMLMetadata [
|
||||
| newContents |
|
||||
self detectYAMLMetadata ifFalse: [ ^ self ].
|
||||
newContents := '' writeStream.
|
||||
(self lines copyFrom: self yamlMetadataClosingLineNumber + 2 to: self lines size) do: [ :line |
|
||||
newContents nextPutAll: line; cr ].
|
||||
^ newContents contents.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Markdown >> documentTree [
|
||||
| parser|
|
||||
@ -153,17 +143,14 @@ Markdown >> file: aFileReference [
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
Markdown >> fromFile: aFileReference [
|
||||
self contents: aFileReference contents.
|
||||
self fromString: aFileReference contents.
|
||||
self file: aFileReference.
|
||||
self yamlMetadata.
|
||||
self body: self contentsWithoutYAMLMetadata
|
||||
]
|
||||
|
||||
{ #category : #'instance creation' }
|
||||
Markdown >> fromString: markdownString [
|
||||
self contents: markdownString.
|
||||
self yamlMetadata.
|
||||
self contents: self contentsWithoutYAMLMetadata
|
||||
self metadata: markdownString yamlMetadata.
|
||||
self body: markdownString contentsWithoutYAMLMetadata
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -16,8 +16,8 @@ MarkupFile class >> exportAsFileOn: aFileReferenceOrFileName containing: anObjec
|
||||
file := aFileReferenceOrFileName asFileReference.
|
||||
file ensureDelete.
|
||||
file exists ifFalse: [ file ensureCreateFile ].
|
||||
anObject className = String
|
||||
ifTrue: [ preprocessed := anObject withInternetLineEndings ]
|
||||
(#('String' 'ByteString' 'WideString') includes: anObject className )
|
||||
ifTrue: [ preprocessed := anObject ]
|
||||
ifFalse: [preprocessed := STON toStringPretty: anObject ].
|
||||
file writeStreamDo: [ :stream |
|
||||
stream nextPutAll: preprocessed ].
|
||||
|
@ -20,6 +20,16 @@ String >> asDashedLowercase [
|
||||
^ '-' join: (self substrings collect: [:each | each asLowercase ])
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
String >> contentsWithoutYAMLMetadata [
|
||||
| newContents |
|
||||
self detectYAMLMetadata ifFalse: [ ^ self ].
|
||||
newContents := '' writeStream.
|
||||
(self lines copyFrom: self yamlMetadataClosingLineNumber + 2 to: self lines size) do: [ :line |
|
||||
newContents nextPutAll: line; cr ].
|
||||
^ newContents contents.
|
||||
]
|
||||
|
||||
{ #category : #'*MiniDocs' }
|
||||
String >> deleteYAMLMetadata [
|
||||
| newContents |
|
||||
|
Loading…
Reference in New Issue
Block a user