diff --git a/repository/Grafoscopio-Utils/LePage.extension.st b/repository/Grafoscopio-Utils/LePage.extension.st index f97b517..e9d4792 100644 --- a/repository/Grafoscopio-Utils/LePage.extension.st +++ b/repository/Grafoscopio-Utils/LePage.extension.st @@ -101,11 +101,12 @@ LePage >> options [ { #category : #'*Grafoscopio-Utils-Core' } LePage >> populateChildrenFrom: docTreeDivs [ - docTreeDivs doWithIndex: [:div :i | | snippet | + docTreeDivs doWithIndex: [:div :i | | snippet parent | snippet := LeSnippet fromMetaMarkdeep:div. self children addSnippet: snippet beforeIndex: i. - "self detectSnippetWithUid: " + parent := self detectSnippetWithUid: (snippet metadata at: 'parent'). + snippet parent: parent. ] ] @@ -116,3 +117,8 @@ LePage >> preorderTraversal [ self withDeepCollect: [:each | each allChildrenBreadthFirstDo: [:child | output add: child ] ]. ^ output. ] + +{ #category : #'*Grafoscopio-Utils-Core' } +LePage >> removeSnippetsMetadata [ + self preorderTraversal do: [ :snippet | snippet options removeKey: 'metadata' ] +] diff --git a/repository/Grafoscopio-Utils/LePictureSnippet.extension.st b/repository/Grafoscopio-Utils/LePictureSnippet.extension.st index 1ac6079..c3f1823 100644 --- a/repository/Grafoscopio-Utils/LePictureSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LePictureSnippet.extension.st @@ -33,23 +33,27 @@ LePictureSnippet >> contentFrom: markdeepDiv [ self optionAt: 'caption' put: caption; optionAt: 'width' put: width. - ^ self urlString: (markdeepDiv // 'img' @ 'src') stringValue. + self urlString: (markdeepDiv // 'img' @ 'src') stringValue. +] + +{ #category : #'*Grafoscopio-Utils-Core' } +LePictureSnippet >> metadata [ + ^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ] ] { #category : #'*Grafoscopio-Utils-Core' } LePictureSnippet >> metadataInit [ - ^ OrderedDictionary new - at: 'id' put: self uidString; - at: 'parent' put: self parent uidString; - at: 'url' put: self contentAsString; - at: 'created' put: self createTime asString; - at: 'modified' put: self latestEditTime asString; - at: 'creator' put: self createEmail asString; - at: 'modifier' put: self editEmail asString; - yourself -] - -{ #category : #'*Grafoscopio-Utils-Core' } -LePictureSnippet >> metatada [ - self optionAt: 'metadata' ifAbsent: [ self metadataInit ] + | surrogate | + self parent + ifNil: [ surrogate := nil] + ifNotNil: [ surrogate := self parent uidString ]. + ^ OrderedDictionary new + at: 'id' put: self uidString; + at: 'parent' put: surrogate; + at: 'url' put: self contentAsString; + at: 'created' put: self createTime asString; + at: 'modified' put: self latestEditTime asString; + at: 'creator' put: self createEmail asString; + at: 'modifier' put: self editEmail asString; + yourself ] diff --git a/repository/Grafoscopio-Utils/LeTextSnippet.extension.st b/repository/Grafoscopio-Utils/LeTextSnippet.extension.st index 1626de2..538fe3f 100644 --- a/repository/Grafoscopio-Utils/LeTextSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LeTextSnippet.extension.st @@ -8,20 +8,3 @@ LeTextSnippet >> contentFrom: markdeepDiv [ sanitized := sanitized allButLast. self string: sanitized. ] - -{ #category : #'*Grafoscopio-Utils-Core' } -LeTextSnippet >> metadata [ - ^ self optionAt: 'metadata' ifAbsentPut: [ self metadataInit ] -] - -{ #category : #'*Grafoscopio-Utils-Core' } -LeTextSnippet >> metadataInit [ - ^ OrderedDictionary new - at: 'id' put: self uidString; - at: 'parent' put: self parent uid asString; - at: 'created' put: self createTime asString; - at: 'modified' put: self latestEditTime asString; - at: 'creator' put: self createEmail asString; - at: 'modifier' put: self editEmail asString; - yourself -] diff --git a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st index 13c5e0f..4ca908d 100644 --- a/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st +++ b/repository/Grafoscopio-Utils/LeTextualSnippet.extension.st @@ -30,3 +30,19 @@ LeTextualSnippet >> markdeepCustomCloser [ LeTextualSnippet >> markdeepCustomOpener [ ^ '' ] + +{ #category : #'*Grafoscopio-Utils-Core' } +LeTextualSnippet >> metadataInit [ + | surrogate | + self parent + ifNil: [ surrogate := nil] + ifNotNil: [ surrogate := self parent uidString ]. + ^ OrderedDictionary new + at: 'id' put: self uidString; + at: 'parent' put: surrogate; + at: 'created' put: self createTime asString; + at: 'modified' put: self latestEditTime asString; + at: 'creator' put: self createEmail asString; + at: 'modifier' put: self editEmail asString; + yourself +] diff --git a/repository/Grafoscopio-Utils/MarkdeepTest.class.st b/repository/Grafoscopio-Utils/MarkdeepTest.class.st new file mode 100644 index 0000000..21a731f --- /dev/null +++ b/repository/Grafoscopio-Utils/MarkdeepTest.class.st @@ -0,0 +1,38 @@ +Class { + #name : #MarkdeepTest, + #superclass : #TestCase, + #category : #'Grafoscopio-Utils-Tests' +} + +{ #category : #tests } +MarkdeepTest >> markdeepTestingPictureSnippet [ + ^ (XMLHTMLParser on: '