Improving Markdown with metadata file exportation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-11-16 18:03:04 -05:00
parent b89b3755f7
commit e73cbbb72a
4 changed files with 21 additions and 14 deletions

View File

@ -3,7 +3,7 @@ Extension { #name : #LePage }
{ #category : #'*MiniDocs' }
LePage >> asHtmlFile [
self asMarkdownFile.
self asMarkdownFileWIthMetadataWrappers.
self defaultPandocTemplate exists
ifFalse: [ MarkupFile installTemplate: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/plantillas/Pandoc/clean-menu-mod.html' into: self defaultPandocTemplate parent ].
@ -48,6 +48,7 @@ LePage >> asMarkdeepFile [
{ #category : #'*MiniDocs' }
LePage >> asMarkdown [
"PENDING: to debug the output."
| bodyStream markdown |
bodyStream := '' writeStream.
bodyStream
@ -55,13 +56,13 @@ LePage >> asMarkdown [
self preorderTraversal
do: [ :snippet | bodyStream nextPutAll: snippet asMarkdown ].
markdown := Markdown new
contents: bodyStream contents demoteMarkdownHeaders;
contents: bodyStream contents promoteMarkdownHeaders;
metadata: (self metadata at: 'original' ifAbsentPut: Dictionary new).
^ markdown
]
{ #category : #'*MiniDocs' }
LePage >> asMarkdownFile [
LePage >> asMarkdownFileWIthMetadataWrappers [
| folder |
folder := self storage.
^ MarkupFile exportAsFileOn: folder / self markdownFileName containing: self asMarkdownWithMetadataWrappers contents
@ -71,13 +72,15 @@ LePage >> asMarkdownFile [
LePage >> asMarkdownWithMetadataWrappers [
| bodyStream markdown |
bodyStream := '' writeStream.
bodyStream
nextPutAll: '# ', self title; cr; cr.
"bodyStream
nextPut: Character lf;
nextPutAll: '# ', self title; cr; cr."
self preorderTraversal
do: [ :snippet | bodyStream nextPutAll: snippet asMarkdownWithMetadataWrappers ].
markdown := Markdown new
contents: bodyStream contents demoteMarkdownHeaders;
metadata: (self metadata at: 'original' ifAbsentPut: Dictionary new).
contents: bodyStream contents promoteMarkdownHeaders;
title: self title;
metadata: self metadata.
^ markdown
]
@ -237,7 +240,7 @@ LePage >> notebookMetadataSnippet [
| response |
response := LeTextSnippet new fromString: '<!-- See this snippet source code for this notebook''s metadata -->'.
response parent: self.
(self optionAt: 'HedgeDoc') ifNil: [ ^ response ].
self optionAt: 'HedgeDoc' ifAbsent: [ ^ response ].
(response extra)
at: 'HedgeDoc' put: (self optionAt: 'HedgeDoc').
^ response

View File

@ -34,13 +34,12 @@ LeTextualSnippet >> asMarkdownWithMetadataWrappers [
| output |
output := '' writeStream.
output
nextPutAll: '<div st-class="', self class asString, '"'; lf;
nextPutAll: ' st-data="', (STON toString: self metadata), '">'; lf;
nextPutAll: self metadataDiv;
nextPutAll: self markdownCustomOpener;
nextPutAll: self contentAsStringCustomized; lf;
nextPutAll: self markdownCustomCloser;
nextPutAll: '</div>'; lf; lf.
^ output contents
^ output contents withInternetLineEndings
]
{ #category : #'*MiniDocs' }

View File

@ -73,8 +73,8 @@ Markdown >> contents [
nextPutAll: '---'; cr;
nextPutAll: self metadataAsYAML; cr;
nextPutAll: '---'; cr;
nextPutAll: self body.
^ response contents
nextPutAll: (self body ifNil: [ '' ]).
^ response contents withInternetLineEndings
]
{ #category : #accessing }
@ -142,7 +142,7 @@ Markdown >> exportMetadataAsYaml [
{ #category : #accessing }
Markdown >> file [
^ file ifNil: [ file := FileLocator temp / 'temporalMarkdeep.md.html' ]
^ file ifNil: [ file := FileLocator temp / 'temporalMarkdeep.md' ]
]
{ #category : #accessing }

View File

@ -17,6 +17,11 @@ OrderedDictionary >> asLepiterSnippet [
^ response
]
{ #category : #'*MiniDocs' }
OrderedDictionary >> asYAML [
^ (YQ jsonToYaml: self) accentedCharactersCorrection.
]
{ #category : #'*MiniDocs' }
OrderedDictionary >> errata [
^ self at: 'errata' ifAbsentPut: [ OrderedCollection new]