diff --git a/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st b/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st index 3fcf735f..d16ca481 100644 --- a/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st +++ b/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st @@ -77,10 +77,11 @@ MicLaTeXWriter >> createLinkToLabelWithoutAlias: anInternalLink [ { #category : 'helpers' } MicLaTeXWriter >> getStringForAll: aCollection [ "Visit each element of aCollection and exports everything to a new stream. Answer the stream content." - | visitor | - visitor := self class new. - aCollection do: [ :object | visitor visit: object ]. - ^ visitor contents + + | visitor | + visitor := self class new. + aCollection do: [ :object | visitor visit: object ]. + ^ visitor contents ] { #category : 'visiting-document' } diff --git a/src/Microdown-Tests/MicInlineDelimiterTest.class.st b/src/Microdown-Tests/MicInlineDelimiterTest.class.st index 998e923a..ce2a4fb9 100644 --- a/src/Microdown-Tests/MicInlineDelimiterTest.class.st +++ b/src/Microdown-Tests/MicInlineDelimiterTest.class.st @@ -24,11 +24,13 @@ MicInlineDelimiterTest >> testAddMe [ { #category : 'tests' } MicInlineDelimiterTest >> testMarkupAsRegex [ "this test is only for evaluated delimiters" - (MicInlineDelimiter all select: #isEvaluated) do: [ :del | |regex| - regex := del markupAsRegex asRegex. - self assert: (regex matches: del markup ). - self assert: (regex search: ('aaa', del markup) ). - self assert: (regex search: (del markup, 'aaa') ). + (MicInlineDelimiter all select: [:each | each isEvaluated]) + do: [ :del | + | regex | + regex := del markupAsRegex asRegex. + self assert: (regex matches: del markup ). + self assert: (regex search: ('aaa', del markup) ). + self assert: (regex search: (del markup, 'aaa') ). ] ] diff --git a/src/Microdown/MicInlineBlockWithUrl.class.st b/src/Microdown/MicInlineBlockWithUrl.class.st index 34396fa0..c374063a 100644 --- a/src/Microdown/MicInlineBlockWithUrl.class.st +++ b/src/Microdown/MicInlineBlockWithUrl.class.st @@ -23,6 +23,7 @@ Class { { #category : 'parsing' } MicInlineBlockWithUrl class >> parse: token stream: aTokenStream for: aParser [ + ^ aParser parseNameUrlBlock: self from: aTokenStream token: token ] diff --git a/src/Microdown/MicInlineDelimiter.class.st b/src/Microdown/MicInlineDelimiter.class.st index dedc304d..495fbdd3 100644 --- a/src/Microdown/MicInlineDelimiter.class.st +++ b/src/Microdown/MicInlineDelimiter.class.st @@ -1,6 +1,6 @@ " I am a superclass for the inline delimiters. -I am an administrer class which gathers delimiters from my subclasses. +I am an administrer class which gathers delimiters from my subclasses. See the method `MicInlineDelimiter>>#all` and `initializeDelimiters`. I store the actual delimiters in the class variable `DelimiterDictionary`. My class side method `initializeDelimiters` gathers delimiters from my subclasses. @@ -28,7 +28,7 @@ MicInlineDelimiter class >> all [ { #category : 'private utilities' } MicInlineDelimiter class >> allRegex [ - ^ ((MicInlineDelimiter all collect: #markupAsRegex) joinUsing: '|') asRegex + ^ ((MicInlineDelimiter all collect: [ :each | each markupAsRegex]) joinUsing: '|') asRegex ] @@ -46,7 +46,7 @@ MicInlineDelimiter class >> initialize [ { #category : 'initialization' } MicInlineDelimiter class >> initializeDelimiters [ - self = MicInlineDelimiter ifFalse: [ ^self ]. + self = MicInlineDelimiter ifFalse: [ ^ self ]. DelimiterDictionary := Dictionary new. self allSubclasses do: [ :class | class initializeDelimiters ] ] diff --git a/src/Microdown/MicInlineStandardDelimiter.class.st b/src/Microdown/MicInlineStandardDelimiter.class.st index af910e44..02fa975a 100644 --- a/src/Microdown/MicInlineStandardDelimiter.class.st +++ b/src/Microdown/MicInlineStandardDelimiter.class.st @@ -19,22 +19,27 @@ Class { { #category : 'initialization' } MicInlineStandardDelimiter class >> initializeDelimiters [ + "The fixious text delimiter" self new markup: FixiousTextDelimiter; blockClass: MicTextBlock; closer: nil; addMe. + "formating" self new markup: BoldMarkup; blockClass: MicBoldFormatBlock; closer: BoldMarkup; addMe. self new markup: ItalicMarkup; blockClass: MicItalicFormatBlock; closer: ItalicMarkup; addMe. self new markup: StrikeMarkup; blockClass: MicStrikeFormatBlock; closer: StrikeMarkup; addMe. + "anchors & annotations" self new markup: AnchorReferenceOpenerMarkup; blockClass: MicAnchorReferenceBlock; closer: AnchorReferenceCloserMarkup; addMe. self new markup: AnchorReferenceCloserMarkup; blockClass: nil; closer: nil; addMe. self new markup: AnnotationCloserMarkup; blockClass: nil; closer: nil; addMe. self new markup: AnnotationOpenerMarkup; blockClass: MicAnnotationBlock; closer: AnnotationCloserMarkup; addMe. + "unevaluated" self new markup: MathMarkup; blockClass: MicMathInlineBlock; closer: MathMarkup; addMe. self new markup: MonospaceMarkup; blockClass: MicMonospaceFormatBlock; closer: MonospaceMarkup; addMe. self new markup: RawOpenerMarkup; blockClass: MicRawBlock; closer: RawCloserMarkup; addMe. self new markup: RawCloserMarkup; blockClass: nil; closer: nil; addMe. + "Containing URLs" self new markup: LinkNameOpenerMarkup; blockClass: MicLinkBlock; closer: NameCloserUrlOpener; addMe. self new markup: FigureNameOpenerMarkup; blockClass: MicFigureBlock; closer: NameCloserUrlOpener; addMe. @@ -86,10 +91,10 @@ MicInlineStandardDelimiter >> markupAsRegex [ str := WriteStream on: ''. self isRawkind ifTrue: [ - markup do: [:char| str nextPut: $\;nextPut: char]. + markup do: [ :char| str nextPut: $\; nextPut: char ]. str nextPutAll: (self class regexNot: closer). - closer do: [:char| str nextPut: $\;nextPut: char]] - ifFalse: [ markup do: [:char| str nextPut: $\;nextPut: char] ]. + closer do: [ :char| str nextPut: $\; nextPut: char ] ] + ifFalse: [ markup do: [ :char| str nextPut: $\; nextPut: char ] ]. ^ str contents ] diff --git a/src/Microdown/MicInlineTokenStream.class.st b/src/Microdown/MicInlineTokenStream.class.st index 908f2524..cbc560ef 100644 --- a/src/Microdown/MicInlineTokenStream.class.st +++ b/src/Microdown/MicInlineTokenStream.class.st @@ -115,7 +115,7 @@ MicInlineTokenStream >> initialize [ { #category : 'parsing' } MicInlineTokenStream >> tokenize: rawString [ - | inlineString splits from| + | inlineString splits from | inlineString := self class backslashEncode: rawString. splits := MicInlineDelimiter allRegex matchingRangesIn: inlineString. tokens := OrderedCollection new. diff --git a/src/Microdown/MicLinkBlock.class.st b/src/Microdown/MicLinkBlock.class.st index aed7b393..ad188045 100644 --- a/src/Microdown/MicLinkBlock.class.st +++ b/src/Microdown/MicLinkBlock.class.st @@ -28,5 +28,5 @@ MicLinkBlock >> accept: aVisitor [ { #category : 'printing' } MicLinkBlock >> plainText [ - ^ '[', ((self children collect: #plainText) joinUsing: ' '), '](', url ,')' + ^ '[', ((self children collect: [:each | each plainText]) joinUsing: ' '), '](', url ,')' ]