Skip to content

Commit

Permalink
Merge branch 'pillar-markup:dev' into 698-MicInlineDelimiter-logic-ca…
Browse files Browse the repository at this point in the history
…n-be-optimized
  • Loading branch information
moufort authored Jul 24, 2024
2 parents a1ec9e4 + 89affb2 commit c6705f2
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Class {
#name : 'MicMicrodownToSlide2Test',
#superclass : 'TestCase',
#category : 'Microdown-BeamerExporter-Tests',
#package : 'Microdown-BeamerExporter-Tests'
}

{ #category : 'as yet unclassified' }
MicMicrodownToSlide2Test >> testSectionLevelOneIsMapToSlide [

| doc slide |
doc := MicrodownParser new parse: '# Slide title
- item 1
- item 2
'.
MicMicrodownToSlideVisitor2 new visit: doc.
slide := doc children first.
self assert: slide class equals: MicSlideBlock.
self assert: slide title equals: 'Slide title'.
self assert: doc children second class equals: MicUnorderedListBlock.


]

{ #category : 'as yet unclassified' }
MicMicrodownToSlide2Test >> testSlideGotCorrectParent [

| doc slide |
doc := MicrodownParser new parse: '# Slide title
- item 1
- item 2
'.
self assert: doc children size equals: 2.
MicMicrodownToSlideVisitor2 new visit: doc.
slide := doc children first.
self assert: slide parent equals: doc.
self assert: doc children size equals: 2

]

{ #category : 'as yet unclassified' }
MicMicrodownToSlide2Test >> testSlideMetaData [

| doc |
doc := MicrodownParser new parse: '
{
"title":"Essence of Dispatch",
"subtitle":"Taking Pharo Booleans as example",
"slidesid" : "M1S1"
}
# Slide title
- item 1
- item 2
'.
self assert: doc children size equals: 3.
MicMicrodownToSlideVisitor2 new visit: doc.
self assert: doc children first class equals: MicMetaDataBlock.
self assert: doc children second class equals: MicSlideBlock

]

{ #category : 'as yet unclassified' }
MicMicrodownToSlide2Test >> testSlideShouldContainFollowingElement [

| doc |
doc := MicrodownParser new parse: '# Title 1
Textouille 2 ici
- item 1
- item 2
# Title 2
textouille ici
- item 3
- item 4
'.

MicMicrodownToSlideVisitor2 new visit: doc.

self assert: doc children equals: 2.
self assert: doc children first size equals: 2

]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Class {
#package : 'Microdown-BeamerExporter-Tests'
}

{ #category : 'tests' }
{ #category : 'as yet unclassified' }
MicMicrodownToSlideTest >> testSectionLevelOneIsMapToSlide [

| doc slide |
Expand All @@ -23,7 +23,7 @@ MicMicrodownToSlideTest >> testSectionLevelOneIsMapToSlide [

]

{ #category : 'tests' }
{ #category : 'as yet unclassified' }
MicMicrodownToSlideTest >> testSlideGotCorrectParent [

| doc slide |
Expand All @@ -40,7 +40,7 @@ MicMicrodownToSlideTest >> testSlideGotCorrectParent [

]

{ #category : 'tests' }
{ #category : 'as yet unclassified' }
MicMicrodownToSlideTest >> testSlideMetaData [

| doc |
Expand All @@ -62,3 +62,29 @@ MicMicrodownToSlideTest >> testSlideMetaData [
self assert: doc children second class equals: MicSlideBlock

]

{ #category : 'as yet unclassified' }
MicMicrodownToSlideTest >> testSlideShouldContainFollowingElement [

| doc |
doc := MicrodownParser new parse: '# Title 1
Textouille 2 ici
- item 1
- item 2
# Title 2
textouille ici
- item 3
- item 4
'.

MicMicrodownToSlideVisitor new visit: doc.

self assert: doc children equals: 2.
self assert: doc children first size equals: 2

]
41 changes: 41 additions & 0 deletions src/Microdown-BeamerExporter-Tests/MicNestingPreparerTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Class {
#name : 'MicNestingPreparerTest',
#superclass : 'TestCase',
#category : 'Microdown-BeamerExporter-Tests',
#package : 'Microdown-BeamerExporter-Tests'
}

{ #category : 'as yet unclassified' }
MicNestingPreparerTest >> testShouldContainFollowingElement [

| doc pre |
doc := MicrodownParser new parse:
'# Title 1
Textouille 2 ici
- item 1
- item 2
# Title 2
textouille ici
- item 3
- item 4
'.

pre := MicNestingPreparer new.
pre treatElements: doc children.

self assert: pre store keys size equals: 2.
self assert: pre store values size equals: 2.

self assert: (pre store at: doc children first) asArray equals: { doc children second . doc children third }.
self assert: (pre store at: doc children fourth) asArray equals: { doc children fifth . doc children sixth }




]
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ MicMicrodownToSlideVisitor >> prepareForExecutionOn: aPRProject [

{ #category : 'accessing' }
MicMicrodownToSlideVisitor >> start: aMicRootBlock [

aMicRootBlock accept: self.
^ aMicRootBlock
]
Expand Down
41 changes: 41 additions & 0 deletions src/Microdown-BeamerExporter/MicMicrodownToSlideVisitor2.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Class {
#name : 'MicMicrodownToSlideVisitor2',
#superclass : 'MicrodownVisitor',
#category : 'Microdown-BeamerExporter',
#package : 'Microdown-BeamerExporter'
}

{ #category : 'instance-creation' }
MicMicrodownToSlideVisitor2 class >> withContext: aPR [

"does nothing with context"
^ self new
]

{ #category : 'building' }
MicMicrodownToSlideVisitor2 >> contributeToPipelineBuilding: aPRPipelineBuilder [

aPRPipelineBuilder addPillarDocumentTransformation: self
]

{ #category : 'preparation' }
MicMicrodownToSlideVisitor2 >> prepareForExecutionOn: aPRProject [
"emtpy"
]

{ #category : 'accessing' }
MicMicrodownToSlideVisitor2 >> start: aMicRootBlock [
| slideDoc |
slideDoc := MicRootBlock new.
slideDoc properties: aMicRootBlock properties.
aMicRootBlock accept: self.
^ slideDoc
]

{ #category : 'visiting' }
MicMicrodownToSlideVisitor2 >> visitHeader: aHeader [

aHeader parent replace: aHeader by: (MicSlideBlock new title: aHeader header)
"now this is wrong because I would get all the following until the next header as children."

]
50 changes: 50 additions & 0 deletions src/Microdown-BeamerExporter/MicNestingPreparer.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Class {
#name : 'MicNestingPreparer',
#superclass : 'Object',
#instVars : [
'currentHeader',
'currentFollowers',
'store'
],
#category : 'Microdown-BeamerExporter',
#package : 'Microdown-BeamerExporter'
}

{ #category : 'initialization' }
MicNestingPreparer >> initialize [

super initialize.
store := IdentityDictionary new.
currentFollowers := OrderedCollection new.

]

{ #category : 'accessing' }
MicNestingPreparer >> store [
^ store
]

{ #category : 'visiting' }
MicNestingPreparer >> storePastElements [

currentHeader ifNotNil: [
store at: currentHeader put: currentFollowers.
currentFollowers := OrderedCollection new ]
]

{ #category : 'visiting' }
MicNestingPreparer >> treatElement: each [

each class = MicHeaderBlock
ifTrue: [
self storePastElements.
currentHeader := each ]
ifFalse: [ currentFollowers addLast: each ]
]

{ #category : 'visiting' }
MicNestingPreparer >> treatElements: aCol [

aCol do: [ :each | self treatElement: each ].
self storePastElements.
]

0 comments on commit c6705f2

Please sign in to comment.