Using GtSubProcess to work on memory and avoid external files creation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-08-02 13:29:56 -05:00
parent b500a65c00
commit af81f92399

View File

@ -24,14 +24,17 @@ Class {
{ #category : #operation } { #category : #operation }
BreaPage >> bodyContentsAsHTML [ BreaPage >> bodyContentsAsHTML [
| sourcePage | | sourcePage commandParameters |
self contentsFile ifNil: [ ^ self ]. self contentsFile ifNil: [ ^ self ].
sourcePage := self file file.
Smalltalk os isWindows ifTrue: [ Smalltalk os isWindows ifTrue: [
^ Pandoc markdownToHtml: self file file
].
sourcePage := FileLocator temp / 'wikiPage.md'.
MarkupFile exportAsFileOn: sourcePage containing: self contents.
^ Pandoc markdownToHtml: sourcePage ^ Pandoc markdownToHtml: sourcePage
].
commandParameters := ' -f markdown+startnum+task_lists -t html '.
^ GtSubprocessWithInMemoryOutput new
shellCommand: 'pandoc', commandParameters, sourcePage fullName;
runAndWait;
stdout.
] ]
{ #category : #accessing } { #category : #accessing }
@ -63,7 +66,7 @@ BreaPage >> contents [
result nextPutAll: (Markdown fromFile: markdownTempFile) contents. result nextPutAll: (Markdown fromFile: markdownTempFile) contents.
] ]
]. ].
^ result contents. ^ result contents withInternetLineEndings.
] ]
{ #category : #operation } { #category : #operation }