From f85ed1803b2a055cd001c22d181f34f7ed43cd5b Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 21 Nov 2024 17:23:45 -0500 Subject: [PATCH] Pushing up methods. --- src/MiniDocs/ByteString.extension.st | 73 ---------------------- src/MiniDocs/LeTextualSnippet.extension.st | 2 +- src/MiniDocs/String.extension.st | 73 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/MiniDocs/ByteString.extension.st b/src/MiniDocs/ByteString.extension.st index 0a0a9c7..127ea20 100644 --- a/src/MiniDocs/ByteString.extension.st +++ b/src/MiniDocs/ByteString.extension.st @@ -1,40 +1,5 @@ Extension { #name : #ByteString } -{ #category : #'*MiniDocs' } -ByteString >> admonitionBorderLines [ - | response | - response := OrderedDictionary new. - self lines doWithIndex: [:line :index | - (self admonitionBorders includes: line trimBoth) - ifTrue: [ response at: index put: line trimBoth ] - ]. - ^ response -] - -{ #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: ':::'" -] - -{ #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 >> asHTMLComment [ ^ '' @@ -45,41 +10,3 @@ ByteString >> email [ "Quick fix for importing Lepiter pages that have a plain ByteString field as email." ^ self ] - -{ #category : #'*MiniDocs' } -ByteString >> markdownSplitLines [ - "I'm useful for conversions between the HedgeDoc Markdown variant and Lepiter page snippets. - I provide broad places to where semantic breaks should be located in a page, - depending on headers or admonitions to create pages snippets with similar divisions. - Further page splits should be provided manually by the document author." - | response | - response := OrderedDictionary new. - response := response - addAll: self markdownHeaders; - addAll: self admonitionBorderLines; - 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 -] - -{ #category : #'*MiniDocs' } -ByteString >> startsWithMarkdownAdmonition [ - self lines ifEmpty: [ ^ false ]. - ^ self admonitionBorders includes: self lines first trimBoth -] diff --git a/src/MiniDocs/LeTextualSnippet.extension.st b/src/MiniDocs/LeTextualSnippet.extension.st index 565f349..6907eca 100644 --- a/src/MiniDocs/LeTextualSnippet.extension.st +++ b/src/MiniDocs/LeTextualSnippet.extension.st @@ -108,7 +108,7 @@ LeTextualSnippet >> metadataUpdate [ editEmailSanitized := self editEmail asString withoutXMLTagDelimiters. ^ OrderedDictionary new at: 'id' put: self uidString; - at: 'parent' put: (self parent ifNotNil: [self parent uidString]); + at: 'parent' put: (self parent ifNotNil: [self parent uidString ]); at: 'created' put: self createTime asString; at: 'modified' put: self latestEditTime asString; at: 'creator' put: createEmailSanitized; diff --git a/src/MiniDocs/String.extension.st b/src/MiniDocs/String.extension.st index a619ac6..c7e88fa 100644 --- a/src/MiniDocs/String.extension.st +++ b/src/MiniDocs/String.extension.st @@ -13,6 +13,41 @@ String >> accentedCharactersCorrection [ ^ modified ] +{ #category : #'*MiniDocs' } +String >> admonitionBorderLines [ + | response | + response := OrderedDictionary new. + self lines doWithIndex: [:line :index | + (self admonitionBorders includes: line trimBoth) + ifTrue: [ response at: index put: line trimBoth ] + ]. + ^ response +] + +{ #category : #'*MiniDocs' } +String >> 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: ':::'" +] + +{ #category : #'*MiniDocs' } +String >> 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' } String >> asDashedLowercase [ "I convert phrases like 'This is a phrase' into 'this-is-a-phrase'." @@ -82,6 +117,38 @@ String >> markdownHeaders [ ^ response ] +{ #category : #'*MiniDocs' } +String >> markdownSplitLines [ + "I'm useful for conversions between the HedgeDoc Markdown variant and Lepiter page snippets. + I provide broad places to where semantic breaks should be located in a page, + depending on headers or admonitions to create pages snippets with similar divisions. + Further page splits should be provided manually by the document author." + | response | + response := OrderedDictionary new. + response := response + addAll: self markdownHeaders; + addAll: self admonitionBorderLines; + yourself. + ^ (response associations sorted: [ :x :y | x key < y key ]) asOrderedDictionary +] + +{ #category : #'*MiniDocs' } +String >> markdownSplitted [ + | response lastPart | + self markdownSplitLines 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 +] + { #category : #'*MiniDocs' } String >> promoteMarkdownHeaders [ | response | @@ -104,6 +171,12 @@ String >> romanizeAccents [ ^ modified ] +{ #category : #'*MiniDocs' } +String >> startsWithMarkdownAdmonition [ + self lines ifEmpty: [ ^ false ]. + ^ self admonitionBorders includes: self lines first trimBoth +] + { #category : #'*MiniDocs' } String >> startsWithYAMLMetadataDelimiter [ self lines ifEmpty: [^false].