Skip to content

Commit

Permalink
Code formatting + adding class comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Mar 23, 2024
1 parent 82c90c2 commit b467977
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
9 changes: 5 additions & 4 deletions src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
12 changes: 7 additions & 5 deletions src/Microdown-Tests/MicInlineDelimiterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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') ).
]
]

Expand Down
1 change: 1 addition & 0 deletions src/Microdown/MicInlineBlockWithUrl.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Class {

{ #category : 'parsing' }
MicInlineBlockWithUrl class >> parse: token stream: aTokenStream for: aParser [

^ aParser parseNameUrlBlock: self from: aTokenStream token: token
]

Expand Down
6 changes: 3 additions & 3 deletions src/Microdown/MicInlineDelimiter.class.st
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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

]

Expand All @@ -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 ]
]
Expand Down
11 changes: 8 additions & 3 deletions src/Microdown/MicInlineStandardDelimiter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
]

Expand Down
2 changes: 1 addition & 1 deletion src/Microdown/MicInlineTokenStream.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Microdown/MicLinkBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ,')'
]

0 comments on commit b467977

Please sign in to comment.