diff --git a/src/MiniDocs/ByteString.extension.st b/src/MiniDocs/ByteString.extension.st index b2b54e9..11b62c5 100644 --- a/src/MiniDocs/ByteString.extension.st +++ b/src/MiniDocs/ByteString.extension.st @@ -30,7 +30,7 @@ ByteString >> admonitionEndingPosition [ response > 0 ifTrue: [ response := response + 1 ]. (line trimBoth = ':::') ifFalse: [ response := response + line size ] - ifTrue: [ response := response + line size. ] + ifTrue: [ ^ response := response + line size. ] ]. ^ response ] @@ -75,5 +75,6 @@ ByteString >> markdownSplitted [ { #category : #'*MiniDocs' } ByteString >> startsWithMarkdownAdmonition [ + self lines ifEmpty: [ ^ false ]. ^ self admonitionBorders includes: self lines first trimBoth ] diff --git a/src/MiniDocs/HedgeDoc.class.st b/src/MiniDocs/HedgeDoc.class.st index c15b8c4..02b9184 100644 --- a/src/MiniDocs/HedgeDoc.class.st +++ b/src/MiniDocs/HedgeDoc.class.st @@ -42,6 +42,7 @@ HedgeDoc >> asLePage [ yourself ]. newPage incomingLinks. + newPage splitAdmonitionSnippets. newPage options at: 'originalMetadata' put: self metadata; at: 'url' put: self url. diff --git a/src/MiniDocs/LePage.extension.st b/src/MiniDocs/LePage.extension.st index ac0d9c6..971dfb2 100644 --- a/src/MiniDocs/LePage.extension.st +++ b/src/MiniDocs/LePage.extension.st @@ -290,6 +290,22 @@ LePage >> sharedVariablesBindings [ ^ shared asDictionary ] +{ #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 | + snippetCommand := node splitSnippetCommandAtPosition: nodeContent admonitionEndingPosition. + snippetCommand execute + ] + ] + ] +] + { #category : #'*MiniDocs' } LePage >> storage [ | current |