Skip to content

Commit

Permalink
Merge pull request #844 from pillar-markup/lineBreak
Browse files Browse the repository at this point in the history
Line break
  • Loading branch information
Ducasse authored Sep 22, 2024
2 parents a2e06ef + 80f6991 commit a20491a
Show file tree
Hide file tree
Showing 23 changed files with 239 additions and 258 deletions.
18 changes: 0 additions & 18 deletions src/Microdown-Macrodown/MacConstants.class.st

This file was deleted.

55 changes: 0 additions & 55 deletions src/Microdown-Macrodown/MacInlineParser.class.st

This file was deleted.

76 changes: 0 additions & 76 deletions src/Microdown-Macrodown/MacLineBreakDelimiter.class.st

This file was deleted.

53 changes: 0 additions & 53 deletions src/Microdown-Macrodown/MacRawParagraphBlock.class.st

This file was deleted.

13 changes: 0 additions & 13 deletions src/Microdown-Macrodown/MicAbstractDelimiter.extension.st

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions src/Microdown-Macrodown/MicrodownVisitor.extension.st

This file was deleted.

33 changes: 33 additions & 0 deletions src/Microdown-NewMacrodown/MacMicrodownSharedPool.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"
I do not know how to integrate the new delimiter in a modular way because
```
MicInlineDelimiter class >> initializeDelimiters
self = MicInlineDelimiter ifFalse: [ ^ self ].
DelimiterDictionary := Dictionary new.
self allSubclasses do: [ :class | class initializeDelimiters ]
```
is basically doing is currently taking all the different subclasses.
The solution would be to have an explicit registration so that we can say
`MicInlineDelimiter useStandard` or `useExtendedSets`.
This has to be done if there is an interest.
"
Class {
#name : 'MacMicrodownSharedPool',
#superclass : 'SharedPool',
#classVars : [
'InlineParagraphDelimiter'
],
#category : 'Microdown-NewMacrodown',
#package : 'Microdown-NewMacrodown'
}

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

InlineParagraphDelimiter := ' '.
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"
This class is copied as it was from Macrodown package.
Paragraph extension to process the extended inlines.
"
Class {
#name : 'MacParagraphBlock',
Expand All @@ -8,10 +11,10 @@ Class {
'textWithoutBreak'
],
#pools : [
'MacConstants'
'MacMicrodownSharedPool'
],
#category : 'Microdown-Macrodown',
#package : 'Microdown-Macrodown'
#category : 'Microdown-NewMacrodown',
#package : 'Microdown-NewMacrodown'
}

{ #category : 'parising' }
Expand All @@ -23,7 +26,7 @@ MacParagraphBlock >> addLineAndReturnNextNode: line [
(line endsWith: InlineParagraphDelimiter) ifFalse: [ ^ self ].
"add nodes up to now, then insert break and continue"
children addAll: (self inlineParse: textWithoutBreak).
children add: (MacLineBreakBlock new).
children add: MicLineBreakBlock new.
textWithoutBreak := nil
]

Expand Down
44 changes: 44 additions & 0 deletions src/Microdown-NewMacrodown/MacRawParagraphBlock.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"
This class is copied as it was from Macrodown package.
In particular I do not really get how the plain HTML is detected. It is a new top level block or an inline block?
It looks like the MacrodownParser is doing the following:
```
blockStarterClassFrom: line
self flag: #HACK. ""This is a special case because it collides with environment""
(MacRawParagraphBlock matchesComment: line)
ifTrue: [ ^ self nonMatchedBlockClassFor: line ].
^ super blockStarterClassFrom: line
```
It would have been nice to know it. I would have changed the syntax for environment.
A raw paragraph block is a block that containes raw content (e.g. plain HTML)
"
Class {
#name : 'MacRawParagraphBlock',
#superclass : 'MicParagraphBlock',
#category : 'Microdown-NewMacrodown',
#package : 'Microdown-NewMacrodown'
}

{ #category : 'visiting' }
MacRawParagraphBlock >> accept: aVisitor [

^ aVisitor visitRawParagraph: self
]

{ #category : 'parse support' }
MacRawParagraphBlock >> closeMe [

self children: {
MicRawBlock
from: 1
to: text size
withSubstring: text }
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This is a variation of the MicrodownParser that tries to be as close as possible
Class {
#name : 'MacrodownParser',
#superclass : 'MicrodownParser',
#category : 'Microdown-Macrodown',
#package : 'Microdown-Macrodown'
#category : 'Microdown-NewMacrodown',
#package : 'Microdown-NewMacrodown'
}

{ #category : 'public' }
Expand Down
24 changes: 24 additions & 0 deletions src/Microdown-NewMacrodown/MicInlineTokenStreamTest.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Extension { #name : 'MicInlineTokenStreamTest' }

{ #category : '*Microdown-NewMacrodown' }
MicInlineTokenStreamTest >> testLineBreak [

| src tokens |
self skip.
src := 'aa bb'.
tokens := (MicInlineTokenStream on: src) contents.
self assert: tokens size equals: 3.
self assert: tokens second string equals: ' '
]

{ #category : '*Microdown-NewMacrodown' }
MicInlineTokenStreamTest >> testLineBreakBackSlashed [

| src tokens |
self skip.
src := 'aa\ bb'.
tokens := (MicInlineTokenStream on: src) contents.
self assert: tokens size equals: 1.
"to me it should not lose the / but we will see this later."
self assert: tokens first string equals: 'aa bb'
]
Loading

0 comments on commit a20491a

Please sign in to comment.