This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-07-19 17:33:17 -05:00
commit 3277bd49b6
2 changed files with 36 additions and 1 deletions

View File

@ -2,8 +2,16 @@ Extension { #name : #LePage }
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LePage >> asHtmlFile [ LePage >> asHtmlFile [
self asMarkdownFile. 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' } { #category : #'*MiniDocs' }
@ -67,6 +75,12 @@ LePage >> asMarkdownFile [
^ MarkupFile exportAsFileOn: folder / self markdownFileName containing: self asMarkdown contents ^ MarkupFile exportAsFileOn: folder / self markdownFileName containing: self asMarkdown contents
] ]
{ #category : #'*MiniDocs' }
LePage >> defaultPandocTemplate [
^ FileLocator home / '.pandoc' / 'templates' / 'clean-menu-mod.html'
]
{ #category : #'*MiniDocs' } { #category : #'*MiniDocs' }
LePage >> exportedFileName [ LePage >> exportedFileName [
| sanitized | | sanitized |
@ -97,3 +111,10 @@ LePage >> preorderTraversal [
self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ]. self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ].
^ output. ^ 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. self inform: 'Exported as: ', String cr, file fullName.
^ file ^ 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
]