From d470dd533ce3cc79de09ca41d3a2fec78467dfc7 Mon Sep 17 00:00:00 2001 From: Offray Date: Mon, 4 Nov 2024 06:33:55 -0500 Subject: [PATCH] Fixing Markdown importation for simple cases. --- src/MiniDocs/HedgeDoc.class.st | 17 ++++++++++++++--- src/MiniDocs/LePage.extension.st | 18 ++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/MiniDocs/HedgeDoc.class.st b/src/MiniDocs/HedgeDoc.class.st index 02b9184..e7b50b8 100644 --- a/src/MiniDocs/HedgeDoc.class.st +++ b/src/MiniDocs/HedgeDoc.class.st @@ -33,9 +33,20 @@ HedgeDoc >> asLePage [ sanitizedMarkdown := self bodyWithoutTitleHeader promoteMarkdownHeaders. newPage := LePage new initializeTitle: self title. - sanitizedMarkdown markdownSplitted do: [:lines | | snippet | + sanitizedMarkdown := sanitizedMarkdown markdownSplitted. + sanitizedMarkdown class = OrderedCollection ifTrue: [ + sanitizedMarkdown do: [:lines | | snippet | + snippet := LeTextSnippet new + string: lines asStringWithCr; + uid: LeUID new. + newPage + addSnippet: snippet; + yourself + ] + ]. + sanitizedMarkdown class = ByteString ifTrue: [ | snippet | snippet := LeTextSnippet new - string: lines asStringWithCr; + string: sanitizedMarkdown; uid: LeUID new. newPage addSnippet: snippet; @@ -159,7 +170,7 @@ HedgeDoc >> server: aUrlString [ { #category : #accessing } HedgeDoc >> url [ - ^ url asUrl + url ifNotNil: [ ^ url asUrl ] ] { #category : #accessing } diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index 971dfb2..eaf0713 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -293,17 +293,19 @@ LePage >> sharedVariablesBindings [ { #category : #'*MiniDocs' } LePage >> splitAdmonitionSnippets [ "I'm used to clean after importing from HedgeDoc to ensure that a snippet contains only admonitions and extra content is put in a new cell." - (self children select: [:node | node string startsWithMarkdownAdmonition ]) - do: [:node | | nodeContent | - node ifNotNil: [ - nodeContent := node string. - nodeContent startsWithMarkdownAdmonition - ifTrue: [ | snippetCommand | + | admonitionSnippets | + admonitionSnippets := self children select: [:node | node string startsWithMarkdownAdmonition ]. + admonitionSnippets ifEmpty: [ ^ self ]. + admonitionSnippets do: [:node | | nodeContent | + node ifNotNil: [ + nodeContent := node string. + nodeContent startsWithMarkdownAdmonition + ifTrue: [ | snippetCommand | snippetCommand := node splitSnippetCommandAtPosition: nodeContent admonitionEndingPosition. - snippetCommand execute - ] + snippetCommand execute ] ] + ] ] { #category : #'*MiniDocs' }