From ef855a9ae575f2d029f00eba79471f8772980b99 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 27 Dec 2023 19:55:26 -0500 Subject: [PATCH] Improved Markdown exportation for better Pandoc conversions between formats. --- src/MiniDocs/LeDatabase.extension.st | 16 +++++++++++----- src/MiniDocs/LePage.extension.st | 3 ++- src/MiniDocs/LePictureSnippet.extension.st | 5 +++++ src/MiniDocs/LeTextualSnippet.extension.st | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/MiniDocs/LeDatabase.extension.st b/src/MiniDocs/LeDatabase.extension.st index 9f045e9..60c7c3f 100644 --- a/src/MiniDocs/LeDatabase.extension.st +++ b/src/MiniDocs/LeDatabase.extension.st @@ -78,7 +78,7 @@ LeDatabase >> addPageFromMarkdeepUrl: aString [ page ifNotNil: [ :arg | self importErrorForLocal: page withRemote: aString. - ^ self ]. + ^ self errorCardFor: page uidString ]. ^ self addPageFromMarkdeep: (self docTreeForLink: aString) withRemote: aString ] @@ -98,11 +98,10 @@ LeDatabase >> docTreeForLink: aString [ ] { #category : #'*MiniDocs' } -LeDatabase >> errorCardFor: error [ +LeDatabase >> errorCardFor: errorKey [ - | keepButton overwriteButton loadCopyButton errorMessageUI localPage errorKey | + | keepButton overwriteButton loadCopyButton errorMessageUI localPage | - errorKey := error keys last. localPage := self pageWithID: errorKey. keepButton := BrButton new aptitude: BrGlamorousButtonWithIconAndLabelAptitude; @@ -134,7 +133,13 @@ LeDatabase >> errorCardFor: error [ aptitude: BrGlamorousRegularEditorAptitude new ; text: (self errors at: errorKey at: 'message'); vFitContent. - ^ { errorMessageUI. keepButton. overwriteButton. loadCopyButton } + ^ BrHorizontalPane new + matchParent; + alignCenter; + addChild:errorMessageUI; + addChild: keepButton; + addChild: overwriteButton; + addChild: loadCopyButton ] { #category : #'*MiniDocs' } @@ -210,6 +215,7 @@ LeDatabase >> importErrorForLocal: page withRemote: externalDocLocation [ at: 'message' put: message ; yourself. self errors at: id put: error. + ^ self errors at: id. ] { #category : #'*MiniDocs' } diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index 5175290..d6c3fe0 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -63,7 +63,8 @@ LePage >> asMarkdown [ bodyStream nextPutAll: k , ': "' , v, '"'; nextPutAll: String lf ]. - bodyStream nextPutAll: '---' , String lf , String lf. + bodyStream nextPutAll: '---' , String lf , String lf, String lf. + bodyStream nextPutAll: '# ', self title, String lf , String lf. self preorderTraversal do: [ :snippet | bodyStream nextPutAll: snippet asMarkdown ]. markdown := Markdown new contents: bodyStream contents. diff --git a/src/MiniDocs/LePictureSnippet.extension.st b/src/MiniDocs/LePictureSnippet.extension.st index 7e81d2b..77df79c 100644 --- a/src/MiniDocs/LePictureSnippet.extension.st +++ b/src/MiniDocs/LePictureSnippet.extension.st @@ -25,6 +25,11 @@ LePictureSnippet >> asMarkdeep [ ^ output contents ] +{ #category : #'*MiniDocs' } +LePictureSnippet >> asMarkdown [ + ^ self asMarkdeep +] + { #category : #'*MiniDocs' } LePictureSnippet >> contentFrom: markdeepDiv [ | caption width | diff --git a/src/MiniDocs/LeTextualSnippet.extension.st b/src/MiniDocs/LeTextualSnippet.extension.st index 5fe9714..11b1ccc 100644 --- a/src/MiniDocs/LeTextualSnippet.extension.st +++ b/src/MiniDocs/LeTextualSnippet.extension.st @@ -40,7 +40,9 @@ LeTextualSnippet >> asMarkdown [ { #category : #'*MiniDocs' } LeTextualSnippet >> contentAsStringCustomized [ - ^ self contentAsString + (self contentAsString beginsWith: '#') + ifTrue: [ ^ '#', self contentAsString ] + ifFalse: [ ^ self contentAsString ] ] { #category : #'*MiniDocs' }