Creating install template method and LePage modified as html.

This commit is contained in:
ruidajo 2022-07-19 17:25:21 -05:00
parent 1443293763
commit 7a704d517d
2 changed files with 36 additions and 1 deletions

View File

@ -2,8 +2,16 @@ Extension { #name : #LePage }
{ #category : #'*MiniDocs' }
LePage >> asHtmlFile [
self asMarkdownFile.
"pandoc" self htmlFileName
self defaultPandocTemplate exists
ifFalse: [ MarkupFile installTemplate: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/plantillas/Pandoc/clean-menu-mod.html' into: self defaultPandocTemplate parent ].
OSSUnixSubprocess new
command: 'pandoc' ;
arguments: { self markdownFileName. '-o'. self htmlFileName};
workingDirectory: self storage;
runAndWaitOnExitDo: [ :process :outString | ^ self storage / self htmlFileName].
]
{ #category : #'*MiniDocs' }
@ -67,6 +75,12 @@ LePage >> asMarkdownFile [
^ MarkupFile exportAsFileOn: folder / self markdownFileName containing: self asMarkdown contents
]
{ #category : #'*MiniDocs' }
LePage >> defaultPandocTemplate [
^ FileLocator home / '.pandoc' / 'templates' / 'clean-menu-mod.html'
]
{ #category : #'*MiniDocs' }
LePage >> exportedFileName [
| sanitized |
@ -97,3 +111,10 @@ LePage >> preorderTraversal [
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
^ output.
]
{ #category : #'*MiniDocs' }
LePage >> storage [
^ self optionAt: 'storage'
ifAbsent: [ ^ FileLocator temp ]
]

View File

@ -21,3 +21,17 @@ MarkupFile class >> exportAsFileOn: aFileReferenceOrFileName containing: text [
self inform: 'Exported as: ', String cr, file fullName.
^ file
]
{ #category : #accessing }
MarkupFile class >> installTemplate: anUrl into: aFolder [
| fileName |
fileName := anUrl asUrl segments last.
(aFolder / fileName) exists
ifTrue: [ (aFolder / fileName) ensureDeleteFile ]
ifFalse: [ aFolder ensureCreateDirectory ].
ZnClient new
url: anUrl;
downloadTo: aFolder.
^ aFolder
]