diff --git a/src/MiniDocs/Markdown.class.st b/src/MiniDocs/Markdown.class.st index 9db6cd5..21864d6 100644 --- a/src/MiniDocs/Markdown.class.st +++ b/src/MiniDocs/Markdown.class.st @@ -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 } diff --git a/src/MiniDocs/MarkupFile.class.st b/src/MiniDocs/MarkupFile.class.st index 63b6016..1a95f1e 100644 --- a/src/MiniDocs/MarkupFile.class.st +++ b/src/MiniDocs/MarkupFile.class.st @@ -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 ]. diff --git a/src/MiniDocs/String.extension.st b/src/MiniDocs/String.extension.st index de321c9..3352cd6 100644 --- a/src/MiniDocs/String.extension.st +++ b/src/MiniDocs/String.extension.st @@ -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 |