Skip to content

Commit

Permalink
add a storeRegex for MicInlineDelimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin.moutte.etu committed Jul 24, 2024
1 parent c446082 commit a1ec9e4
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/Microdown/MicInlineDelimiter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Class {
#name : 'MicInlineDelimiter',
#superclass : 'Object',
#classVars : [
'DelimiterDictionary'
'DelimiterDictionary',
'RegexDictionary'
],
#pools : [
'MicMicrodownSharedPool'
Expand All @@ -28,8 +29,9 @@ MicInlineDelimiter class >> all [

{ #category : 'private utilities' }
MicInlineDelimiter class >> allRegex [
^ ((MicInlineDelimiter all collect: [ :each | each markupAsRegex]) joinUsing: '|') asRegex


RegexDictionary ifNil: [ self initializeRegex ].
^ (RegexDictionary values joinUsing: '|') asRegex
]

{ #category : 'accessing' }
Expand All @@ -40,17 +42,27 @@ MicInlineDelimiter class >> at: markup [

{ #category : 'initialization' }
MicInlineDelimiter class >> initialize [

<script>
DelimiterDictionary := nil
DelimiterDictionary := nil.
RegexDictionary := nil
]

{ #category : 'initialization' }
MicInlineDelimiter class >> initializeDelimiters [

self = MicInlineDelimiter ifFalse: [ ^ self ].
DelimiterDictionary := Dictionary new.
RegexDictionary := Dictionary new.
self allSubclasses do: [ :class | class initializeDelimiters ]
]

{ #category : 'initialization' }
MicInlineDelimiter class >> initializeRegex [

self all
]

{ #category : 'compiling' }
MicInlineDelimiter class >> noteCompilationOf: aSelector meta: isMeta [
"I reset when any method is recompiled"
Expand All @@ -75,6 +87,8 @@ MicInlineDelimiter class >> regexNot: markup [
{ #category : 'adding' }
MicInlineDelimiter >> addMe [
"add me to the dictionary in my class"
self storeRegex.

DelimiterDictionary at: self markup put: self
]

Expand Down Expand Up @@ -114,3 +128,10 @@ MicInlineDelimiter >> markup [
MicInlineDelimiter >> markupAsRegex [
self subclassResponsibility
]

{ #category : 'adding' }
MicInlineDelimiter >> storeRegex [

RegexDictionary at: self markup put: self markupAsRegex

]

0 comments on commit a1ec9e4

Please sign in to comment.