From 18bdabdb595e720d74f408a7a46de3f18a3ead55 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 6 Apr 2023 08:47:40 -0500 Subject: [PATCH] Adding more views to Markdown document tree elements. --- src/MiniDocs/HedgeDoc.class.st | 7 ++++++ src/MiniDocs/LePage.extension.st | 5 +--- src/PetitMarkdown/PPCMHrule.class.st | 24 +++++++++++++++++++ src/PetitMarkdown/PPCMLinkRef.class.st | 17 +++++++++++++ src/PetitMarkdown/PPCMLinkRefDef.class.st | 24 +++++++++++++++++++ .../PPCMLinkRefDefPlaceholder.class.st | 16 +++++++++++++ 6 files changed, 89 insertions(+), 4 deletions(-) diff --git a/src/MiniDocs/HedgeDoc.class.st b/src/MiniDocs/HedgeDoc.class.st index 68df84e..fded226 100644 --- a/src/MiniDocs/HedgeDoc.class.st +++ b/src/MiniDocs/HedgeDoc.class.st @@ -55,6 +55,13 @@ HedgeDoc >> defaultServer [ self server: 'https://docutopia.tupale.co'. ] +{ #category : #accessing } +HedgeDoc >> documentTree [ + | parser| + parser := PPCommonMarkBlockParser new parse: self contents. + ^ parser accept: CMBlockVisitor new +] + { #category : #'as yet unclassified' } HedgeDoc >> htmlUrl [ | link | diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index 52a5b85..9853636 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -181,10 +181,7 @@ LePage >> options [ { #category : #'*MiniDocs' } LePage >> preorderTraversal [ - | output | - output := OrderedCollection new. - self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child]]. - ^ output. + ^ self allChildrenDepthFirst ] { #category : #'*MiniDocs' } diff --git a/src/PetitMarkdown/PPCMHrule.class.st b/src/PetitMarkdown/PPCMHrule.class.st index a391efb..64d8bde 100644 --- a/src/PetitMarkdown/PPCMHrule.class.st +++ b/src/PetitMarkdown/PPCMHrule.class.st @@ -21,3 +21,27 @@ PPCMHrule >> rule [ PPCMHrule >> rule: anObject [ rule := anObject ] + +{ #category : #accessing } +PPCMHrule >> viewBody [ + + | aText | + aText := (self className ,' ', + self rule) asRopedText. + + self children do: [ :child | + aText append: ' ' asRopedText. + aText append: (child destination asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + aText append: ('= "' asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + aText append: (child destination asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + aText append: + ('"' asRopedText foreground: + BrGlamorousColors disabledButtonTextColor) + ]. + + + ^ aText +] diff --git a/src/PetitMarkdown/PPCMLinkRef.class.st b/src/PetitMarkdown/PPCMLinkRef.class.st index 3b01da1..2e6411c 100644 --- a/src/PetitMarkdown/PPCMLinkRef.class.st +++ b/src/PetitMarkdown/PPCMLinkRef.class.st @@ -21,3 +21,20 @@ PPCMLinkRef >> label [ PPCMLinkRef >> label: anObject [ label := anObject ] + +{ #category : #accessing } +PPCMLinkRef >> viewBody [ + + | aText | + aText := (self className ,' ', + self label text) asRopedText. + + self children do: [ :child | + aText append: ' ' asRopedText. + aText append: (child className asRopedText foreground: + BrGlamorousColors disabledButtonTextColor) + ]. + + + ^ aText +] diff --git a/src/PetitMarkdown/PPCMLinkRefDef.class.st b/src/PetitMarkdown/PPCMLinkRefDef.class.st index dafa586..800557c 100644 --- a/src/PetitMarkdown/PPCMLinkRefDef.class.st +++ b/src/PetitMarkdown/PPCMLinkRefDef.class.st @@ -48,3 +48,27 @@ PPCMLinkRefDef >> title [ PPCMLinkRefDef >> title: anObject [ title := anObject ] + +{ #category : #accessing } +PPCMLinkRefDef >> viewBody [ + + | aText | + aText := (self className ,' ', + self label text, ' -> ', self destination) asRopedText. + + self children do: [ :child | + aText append: ' ' asRopedText. + aText append: (child destination asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + aText append: ('= "' asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + aText append: (child destination asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + aText append: + ('"' asRopedText foreground: + BrGlamorousColors disabledButtonTextColor) + ]. + + + ^ aText +] diff --git a/src/PetitMarkdown/PPCMLinkRefDefPlaceholder.class.st b/src/PetitMarkdown/PPCMLinkRefDefPlaceholder.class.st index b1b7ce5..f807fc6 100644 --- a/src/PetitMarkdown/PPCMLinkRefDefPlaceholder.class.st +++ b/src/PetitMarkdown/PPCMLinkRefDefPlaceholder.class.st @@ -13,3 +13,19 @@ PPCMLinkRefDefPlaceholder >> accept: visitor [ PPCMLinkRefDefPlaceholder >> isBlockLevel [ ^ true ] + +{ #category : #accessing } +PPCMLinkRefDefPlaceholder >> viewBody [ + + | aText | + aText := (self className ) asRopedText. + + self children do: [ :child | + aText append: ' ' asRopedText. + aText append: (child className asRopedText foreground: + BrGlamorousColors disabledButtonTextColor). + ]. + + + ^ aText +]