From 0c45ccb39e72eaf1006f6977c78e672f8907b382 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 22 Apr 2024 14:01:59 -0500 Subject: [PATCH] Debugging image links with links in the description. --- src/MiniDocs/XMLElement.extension.st | 20 +++++++++++++++++++- src/PetitMarkdown/PPCMLink.class.st | 5 ++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/MiniDocs/XMLElement.extension.st b/src/MiniDocs/XMLElement.extension.st index 04179db..90104ee 100644 --- a/src/MiniDocs/XMLElement.extension.st +++ b/src/MiniDocs/XMLElement.extension.st @@ -13,7 +13,7 @@ XMLElement >> asSnippetDictionary [ XMLElement >> sanitizedContent [ | className sanitizedText | className := self attributes at: 'st-class'. - ((className = 'LeTextSnippet') or: [className = 'LePictureSnippet']) + (className = 'LeTextSnippet') ifTrue: [ sanitizedText := self contentString. sanitizedText := sanitizedText allButFirst. @@ -26,6 +26,24 @@ XMLElement >> sanitizedContent [ sanitizedText do: [ :line | joinedText nextPutAll: line; nextPut: Character lf ]. sanitizedText := joinedText contents allButLast. ]. + (className = 'LePictureSnippet') + ifTrue: [ | linkParser linkParserNodes| + linkParser := (PPCommonMarkBlockParser parse: self contentString allButFirst) + accept: CMBlockVisitor new. + linkParserNodes := linkParser children first children. + linkParserNodes size = 1 + ifTrue: [ sanitizedText := linkParserNodes first label text ] + ifFalse: [ + sanitizedText := '' writeStream. + linkParserNodes allButLast do: [:each | + each className = 'PPCMText' + ifTrue: [ sanitizedText nextPutAll: each text allButFirst ]. + each className = 'PPCMLink' + ifTrue: [ sanitizedText nextPutAll: each printString ] + ]. + sanitizedText := sanitizedText contents + ] + ]. ^ sanitizedText ] diff --git a/src/PetitMarkdown/PPCMLink.class.st b/src/PetitMarkdown/PPCMLink.class.st index 3ae375b..856b2ee 100644 --- a/src/PetitMarkdown/PPCMLink.class.st +++ b/src/PetitMarkdown/PPCMLink.class.st @@ -39,9 +39,8 @@ PPCMLink >> printOn: aStream [ super initialize. ^ aStream nextPutAll: - self label text, - ' -> ', - self destination + '[',self label text,']', + '(',self destination,')' ] { #category : #accessing }