diff --git a/src/Microdown/MicArgumentList.class.st b/src/Microdown/MicArgumentList.class.st index 7f64ba9d..7ce8c755 100644 --- a/src/Microdown/MicArgumentList.class.st +++ b/src/Microdown/MicArgumentList.class.st @@ -179,8 +179,9 @@ MicArgumentList >> setNoDefaultButArguments: string [ "string is assumed to be on the form key=value&key=value" | pairs | pairs := string splitOn: $&. - pairs do: [ :p | |keyValue| - keyValue := p splitOnFirst: $=. + pairs do: [ :p | + | keyValue | + keyValue := p splitOnFirst: $= noneValue: nil. self at: keyValue first trim asSymbol put: keyValue second ] ] diff --git a/src/Microdown/MicInlineBlockWithUrl.class.st b/src/Microdown/MicInlineBlockWithUrl.class.st index bf577f6c..e3af821a 100644 --- a/src/Microdown/MicInlineBlockWithUrl.class.st +++ b/src/Microdown/MicInlineBlockWithUrl.class.st @@ -113,16 +113,14 @@ MicInlineBlockWithUrl >> children: anObject [ { #category : 'visiting' } MicInlineBlockWithUrl >> closeMe [ - "the link url - ![alt text](url) - url is allowed to have title in quotes - (url ""title"") " - | split title | - split := url splitOnFirst: Character space. + | split | + split := url splitOnFirst: Character space noneValue: nil. self reference: (MicResourceReference fromUri: split first). - self arguments ifNil: [ - title := (split second ifNil: [ '' ]) - trimBoth: [:char | {$". Character space} includes: char]. - self arguments: (MicArgumentList withString: title)] + self arguments + ifNil: [ | title | + title := split second ifNotNil: [ :s | s] ifNil: [ '' ]. + self arguments: (MicArgumentList withString: title) ] ] { #category : 'utilities' } diff --git a/src/Microdown/SequenceableCollection.extension.st b/src/Microdown/SequenceableCollection.extension.st index d867c93e..737ad098 100644 --- a/src/Microdown/SequenceableCollection.extension.st +++ b/src/Microdown/SequenceableCollection.extension.st @@ -1,10 +1,25 @@ Extension { #name : 'SequenceableCollection' } { #category : '*Microdown' } -SequenceableCollection >> splitOnFirst: char [ - | indexOfChar | - indexOfChar := self indexOf: char. - indexOfChar = 0 ifTrue: [ ^{self. nil} ]. - ^{self copyFrom: 1 to: indexOfChar -1. self copyFrom: indexOfChar +1 to: self size} +SequenceableCollection >> splitOnFirst: anObject [ + "Split the receiver on the first element that match anObject, returns two sequenceable." + + "#(1 2 3 0 4 5 6 0 7) splitOnFirst: 0 >> #(#(1 2 3) #(4 5 6 0 7)) " + "#(1 2 3 0 4 5 6 0 7) splitOnFirst: 99 >> #(#(1 2 3 04 5 6 0 7) #() " + + ^ self splitOnFirst: anObject noneValue: #() +] + +{ #category : '*Microdown' } +SequenceableCollection >> splitOnFirst: anObject noneValue: aValue [ + "Split the receiver on the first element that match anObject" + + "#(1 2 3 0 4 5 6 0 7) splitOnFirst: 0 noneValue: 33>> #(#(1 2 3) #(4 5 6 0 7)) " + "#(1 2 3 0 4 5 6 0 7) splitOnFirst: 99 noneValue: #()>> #(#(1 2 3 04 5 6 0 7) #() " + + | element | + element := self indexOf: anObject. + element = 0 ifTrue: [ ^ { self. aValue } ]. + ^ { self copyFrom: 1 to: element -1 . self copyFrom: element + 1 to: self size } ]