From 96903d8627347f0165909ade28f2fa21fed204eb Mon Sep 17 00:00:00 2001 From: Offray Date: Sun, 3 Nov 2024 14:56:57 -0500 Subject: [PATCH] Implementing Markdown crude semantic splits. --- src/MiniDocs/ByteString.extension.st | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/MiniDocs/ByteString.extension.st b/src/MiniDocs/ByteString.extension.st index cf8e616..2abf6c5 100644 --- a/src/MiniDocs/ByteString.extension.st +++ b/src/MiniDocs/ByteString.extension.st @@ -13,9 +13,12 @@ ByteString >> admonitionBorderLines [ { #category : #'*MiniDocs' } ByteString >> admonitionBorders [ + "For the moment I only work with the admonition starting border + as adding the closing one would imply to redo the #markdownSplitted + method implementing a proper parser, which, ATM is overkill." | response | response := #('info' 'success' 'warning' 'danger') collect: [ :each | ':::', each ]. - ^ response copyWith: ':::' + ^ response "copyWith: ':::'" ] { #category : #'*MiniDocs' } @@ -38,3 +41,20 @@ ByteString >> markdownSplitLines [ yourself. ^ (response associations sorted: [ :x :y | x key < y key ]) asOrderedDictionary ] + +{ #category : #'*MiniDocs' } +ByteString >> markdownSplitted [ + | response lastPart | + self admonitionBorderLines ifEmpty: [ ^ self ]. + response := OrderedCollection new. + self markdownSplitLines keys allButLast doWithIndex: [:key :index | | nextLine part | + nextLine := (self markdownSplitLines keys at: index + 1) - 1. + part := self lines copyFrom: key to: nextLine. + response add: part. + ]. + lastPart := self lines + copyFrom: self markdownSplitLines keys last + to: self lines size. + response add: lastPart. + ^ response +]