-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pillar-markup:dev' into 698-MicInlineDelimiter-logic-ca…
…n-be-optimized
- Loading branch information
Showing
6 changed files
with
252 additions
and
3 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
src/Microdown-BeamerExporter-Tests/MicMicrodownToSlide2Test.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Microdown-BeamerExporter-Tests/MicNestingPreparerTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
|
||
|
||
|
||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Microdown-BeamerExporter/MicMicrodownToSlideVisitor2.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
] |