Pushing up methods.
This commit is contained in:
parent
92760a54a9
commit
f85ed1803b
@ -1,40 +1,5 @@
|
|||||||
Extension { #name : #ByteString }
|
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' }
|
{ #category : #'*MiniDocs' }
|
||||||
ByteString >> asHTMLComment [
|
ByteString >> asHTMLComment [
|
||||||
^ '<!-- ', self , ' -->'
|
^ '<!-- ', self , ' -->'
|
||||||
@ -45,41 +10,3 @@ ByteString >> email [
|
|||||||
"Quick fix for importing Lepiter pages that have a plain ByteString field as email."
|
"Quick fix for importing Lepiter pages that have a plain ByteString field as email."
|
||||||
^ self
|
^ 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
|
|
||||||
]
|
|
||||||
|
@ -13,6 +13,41 @@ String >> accentedCharactersCorrection [
|
|||||||
^ modified
|
^ 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' }
|
{ #category : #'*MiniDocs' }
|
||||||
String >> asDashedLowercase [
|
String >> asDashedLowercase [
|
||||||
"I convert phrases like 'This is a phrase' into 'this-is-a-phrase'."
|
"I convert phrases like 'This is a phrase' into 'this-is-a-phrase'."
|
||||||
@ -82,6 +117,38 @@ String >> markdownHeaders [
|
|||||||
^ response
|
^ 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' }
|
{ #category : #'*MiniDocs' }
|
||||||
String >> promoteMarkdownHeaders [
|
String >> promoteMarkdownHeaders [
|
||||||
| response |
|
| response |
|
||||||
@ -104,6 +171,12 @@ String >> romanizeAccents [
|
|||||||
^ modified
|
^ modified
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #'*MiniDocs' }
|
||||||
|
String >> startsWithMarkdownAdmonition [
|
||||||
|
self lines ifEmpty: [ ^ false ].
|
||||||
|
^ self admonitionBorders includes: self lines first trimBoth
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #'*MiniDocs' }
|
{ #category : #'*MiniDocs' }
|
||||||
String >> startsWithYAMLMetadataDelimiter [
|
String >> startsWithYAMLMetadataDelimiter [
|
||||||
self lines ifEmpty: [^false].
|
self lines ifEmpty: [^false].
|
||||||
|
Loading…
Reference in New Issue
Block a user