From 5ccff44fc9bef70ecadcc078d30b920d2f668290 Mon Sep 17 00:00:00 2001 From: Offray Date: Sun, 3 Nov 2024 22:38:31 -0500 Subject: [PATCH] Improving splitting of admonition strings. --- src/MiniDocs/ByteString.extension.st | 19 +++++++++++++++++++ src/MiniDocs/HedgeDoc.class.st | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/MiniDocs/ByteString.extension.st b/src/MiniDocs/ByteString.extension.st index 2abf6c5..b2b54e9 100644 --- a/src/MiniDocs/ByteString.extension.st +++ b/src/MiniDocs/ByteString.extension.st @@ -21,6 +21,20 @@ ByteString >> admonitionBorders [ ^ response "copyWith: ':::'" ] +{ #category : #'*MiniDocs' } +ByteString >> admonitionEndingPosition [ + | response | + response := 0. + self startsWithMarkdownAdmonition ifFalse: [ ^ response ]. + self lines do: [:line | + response > 0 ifTrue: [ response := response + 1 ]. + (line trimBoth = ':::') + ifFalse: [ response := response + line size ] + ifTrue: [ response := response + line size. ] + ]. + ^ response +] + { #category : #'*MiniDocs' } ByteString >> email [ "Quick fix for importing Lepiter pages that have a plain ByteString field as email." @@ -58,3 +72,8 @@ ByteString >> markdownSplitted [ response add: lastPart. ^ response ] + +{ #category : #'*MiniDocs' } +ByteString >> startsWithMarkdownAdmonition [ + ^ self admonitionBorders includes: self lines first trimBoth +] diff --git a/src/MiniDocs/HedgeDoc.class.st b/src/MiniDocs/HedgeDoc.class.st index c00666f..c15b8c4 100644 --- a/src/MiniDocs/HedgeDoc.class.st +++ b/src/MiniDocs/HedgeDoc.class.st @@ -35,7 +35,8 @@ HedgeDoc >> asLePage [ initializeTitle: self title. sanitizedMarkdown markdownSplitted do: [:lines | | snippet | snippet := LeTextSnippet new - string: lines asStringWithCr. + string: lines asStringWithCr; + uid: LeUID new. newPage addSnippet: snippet; yourself