Skip to content

Commit

Permalink
Merge pull request #774 from moufort/css
Browse files Browse the repository at this point in the history
Fix Microdown after I broke it
  • Loading branch information
Ducasse authored Jun 14, 2024
2 parents 36aca24 + 888b7e7 commit ee647ff
Show file tree
Hide file tree
Showing 93 changed files with 11,648 additions and 35 deletions.
81 changes: 81 additions & 0 deletions src/BaselineOfMicrodownDev/BaselineOfMicrodownDev.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Class {
#name : 'BaselineOfMicrodownDev',
#superclass : 'BaselineOf',
#category : 'BaselineOfMicrodownDev',
#package : 'BaselineOfMicrodownDev'
}

{ #category : 'baselines' }
BaselineOfMicrodownDev >> baseline: spec [

<baseline>
spec for: #common do: [
spec
baseline: 'PillarDocumentModel'
with: [ spec repository: 'github://pillar-markup/pillar:dev-8/src' ].
spec
package: #Microdown;
package: #'Microdown-Tests'
with: [ spec requires: #( #Microdown ) ];

package: #'Microdown-ResolvePath'
with: [ spec requires: #( #'Microdown' ) ];
package: #'Microdown-ResolvePath-Tests'
with: [ spec requires: #( #'Microdown-ResolvePath' ) ];

package: #'Microdown-Pharo-Tools'
with: [ spec requires: #( #Microdown ) ];

package: #'Microdown-RichTextComposer'
with: [ spec requires: #( #Microdown ) ];
package: #'Microdown-RichTextComposer-Tests'
with: [ spec requires: #( #'Microdown-RichTextComposer' ) ];

package: #'Microdown-Transformer'
with: [ spec requires: #( #Microdown ) ];
package: #'Microdown-Transformer-Tests'
with: [ spec requires: #( #'Microdown-Transformer' ) ];

package: #'Microdown-Evaluator'
with: [ spec requires: #( #'Microdown-Transformer' ) ];
package: #'Microdown-Evaluator-Tests'
with: [ spec requires: #( #'Microdown-Evaluator' ) ];

package: #'Microdown-PrettyPrinter'
with: [ spec requires: #( #Microdown ) ];

package: #'Microdown-PrettyPrinter-Tests'
with: [ spec requires: #( #'Microdown-PrettyPrinter' #'Microdown-Tests') ];

package: #'Microdown-Pillar'
with: [ spec requires: #( #Microdown #PillarDocumentModel ) ];
package: #'Microdown-Pillar-Tests'
with: [ spec requires: #( #'Microdown-Pillar' #'Microdown-Tests' ) ].

"I do not want group without tests for now"
spec
group: 'Core'
with: #(
#'Microdown'
#'Microdown-Tests'
#'Microdown-ResolvePath'
#'Microdown-ResolvePath-Tests'
);
group: 'Pillar'
with: #(
#'Microdown'
#'Microdown-Tests'
#'Microdown-Pillar'
#'Microdown-Pillar-Tests' );
group: 'RichText' with: #('Core' #'Microdown-RichTextComposer' );
group: 'Extensions'
with: #(
#'Microdown-Evaluator'
#'Microdown-Evaluator-Tests'
#'Microdown-PrettyPrinter'
#'Microdown-PrettyPrinter-Tests'
#'Microdown-Transformer'
#'Microdown-Transformer-Tests');
group: 'All'
with: #('Core' 'Extensions' #'Microdown-Pharo-Tools' 'RichText') ]
]
44 changes: 44 additions & 0 deletions src/BaselineOfMicrodownH5P/BaselineOfMicrodownH5P.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"
baseline: spec
<baseline>
spec for: #'common' do: [
spec
baseline: 'Mustache'
with: [ spec
repository: 'github://noha/mustache:v1.0/repository';
loads: #('Core' 'Tests') ].
spec
package: #'Microdown-H5P'
with: [ spec requires: #('Mustache') ]
]
"
Class {
#name : 'BaselineOfMicrodownH5P',
#superclass : 'BaselineOf',
#category : 'BaselineOfMicrodownH5P',
#package : 'BaselineOfMicrodownH5P'
}

{ #category : 'baselines' }
BaselineOfMicrodownH5P >> baseline: spec [
<baseline>

spec
for: #(unix osx)
do: [ spec
baseline: 'OSSubprocess'
with: [ spec repository: 'github://pharo-contributions/OSSubprocess:v1.4.0/repository' ] ].

spec for: #'common' do: [
"probably not needed with the latest version e.g. jpeg production."
spec
baseline: 'Mustache'
with: [ spec
repository: 'github://noha/mustache:v1.0/repository';
loads: #('Core' 'Tests') ].
spec
package: #'Microdown-H5P'
with: [ spec requires: #('Mustache' 'OSSubprocess') ]
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Class {
#name : 'BaselineOfPillarSlideConverter',
#superclass : 'BaselineOf',
#category : 'BaselineOfPillarSlideConverter',
#package : 'BaselineOfPillarSlideConverter'
}

{ #category : 'baselines' }
BaselineOfPillarSlideConverter >> baseline: spec [
<baseline>

spec
for: #common
do: [ spec blessing: #baseline.
spec
baseline: 'PetitParser2Core' with: [ spec
repository: 'github://kursjan/petitparser2' ];
package: 'Pillar-Core';
package: 'Pillar-Model';
package: 'Pillar-PetitPillar' with: [ spec
requires: #( 'PetitParser2Core' 'Pillar-Model' ) ];
package: 'Microdown-Slide-Utils' with: [ spec
requires: #( 'PetitParser2Core' 'Pillar-Model' "I do not put microdown here
because I do not want") ]]


]
12 changes: 12 additions & 0 deletions src/Microdown - HTML/MicHTMLBrush.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"
I'm an abstract brush dedicated to HTML documents. As of today, the only subclass is the tag brush but we can imagine others (e.g., to write HTML comments).
"
Class {
#name : 'MicHTMLBrush',
#superclass : 'MicExportBrush',
#instVars : [
'name'
],
#category : 'Microdown - HTML',
#package : 'Microdown - HTML'
}
34 changes: 34 additions & 0 deletions src/Microdown - HTML/MicHTMLCanvas.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : 'MicHTMLCanvas',
#superclass : 'MicExportCanvas',
#instVars : [
'name'
],
#classVars : [
'HTMLCharacters'
],
#category : 'Microdown - HTML',
#package : 'Microdown - HTML'
}

{ #category : 'initialization' }
MicHTMLCanvas class >> initialize [
HTMLCharacters := Dictionary new.
HTMLCharacters
at: $" put: '&quot;';
at: $& put: '&amp;';
at: $< put: '&lt;';
at: $> put: '&gt;'
]
{ #category : 'accessing' }
MicHTMLCanvas >> nextPut: aCharacter [
(HTMLCharacters at: aCharacter ifAbsent: nil)
ifNil: [ super nextPut: aCharacter ]
ifNotNil: [ :string | self raw: string ]
]
{ #category : 'accessing' }
MicHTMLCanvas >> tag [
^ self brush: MicHTMLTag new
]
45 changes: 45 additions & 0 deletions src/Microdown - HTML/MicHTMLExporterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Class {
#name : 'MicHTMLExporterTest',
#superclass : 'TestCase',
#instVars : [
'parser',
'writer',
'factory'
],
#category : 'Microdown - HTML',
#package : 'Microdown - HTML'
}

{ #category : 'utils' }
MicHTMLExporterTest >> parse: aString andCheckWeGet: aResultingString [

| mic |
mic := parser parse: aString.
self assert: (writer visit: mic) contents equals: aResultingString
]

{ #category : 'running' }
MicHTMLExporterTest >> setUp [
super setUp.
parser := MicroDownParser new.
writer := MicHTMLWriter new.
factory := MicMicrodownSnippetFactory new
]

{ #category : 'tests' }
MicHTMLExporterTest >> testHeaderLevel1 [

self parse: factory headerLevel1Sample andCheckWeGet: writer usedNewLine , '<h1>Foo</h1>'

]

{ #category : 'tests' }
MicHTMLExporterTest >> testUnorderedList [
| mic |
mic := parser parse: factory unorderedListWithTwoItemsSample.
self assert: (writer visit: mic) contents equals: '
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>'
]
27 changes: 27 additions & 0 deletions src/Microdown - HTML/MicHTMLTag.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Class {
#name : 'MicHTMLTag',
#superclass : 'MicHTMLBrush',
#category : 'Microdown - HTML',
#package : 'Microdown - HTML'
}

{ #category : 'accessing' }
MicHTMLTag >> name: aString [
name := aString.
stream nextPut: $<; << aString
]

{ #category : 'accessing' }
MicHTMLTag >> parameterAt: aString put: anotherString [
stream space. stream << aString << '="' << anotherString << '"'
]

{ #category : 'accessing' }
MicHTMLTag >> with: aString [
stream
nextPut: $>;
<< aString;
<< '</';
<< name;
nextPut: $>
]
65 changes: 65 additions & 0 deletions src/Microdown - HTML/MicHTMLWriter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Class {
#name : 'MicHTMLWriter',
#superclass : 'MicrodownVisitor',
#instVars : [
'stream',
'canvas'
],
#category : 'Microdown - HTML',
#package : 'Microdown - HTML'
}

{ #category : 'initialization' }
MicHTMLWriter >> canvasClass [

^ MicHTMLCanvas
]

{ #category : 'accessing' }
MicHTMLWriter >> contents [
^ stream contents
]

{ #category : 'initialization' }
MicHTMLWriter >> initialize [
super initialize.
stream := MicOutputStream new setStream: (WriteStream on: (String new: 1000)).
canvas := self canvasClass on: stream.

]

{ #category : 'initialization' }
MicHTMLWriter >> usedNewLine [
"Return the encoded new line. Useful for tests."

^ stream usedNewLine
]

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

canvas newLine.
canvas tag
name: 'h', aHeader level asString;
with: aHeader header

]

{ #category : 'visiting' }
MicHTMLWriter >> visitUnorderedList: anUnorderedList [

canvas newLine.
canvas tag
name: 'ul';
with: [ canvas newLine. super visitUnorderedList: anUnorderedList ]
]

{ #category : 'visiting' }
MicHTMLWriter >> visitUnorderedListItem: anUnorderedListItem [
"will not work with we have text decorators such as bold, italic, monospace"

canvas tag
name: 'li';
with: anUnorderedListItem text.
canvas newLine
]
49 changes: 49 additions & 0 deletions src/Microdown-Agenda-Tests/MicAgendaBlockTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Class {
#name : 'MicAgendaBlockTest',
#superclass : 'TestCase',
#instVars : [
'builder',
'parser'
],
#pools : [
'MicMicrodownSharedPool'
],
#category : 'Microdown-Agenda-Tests',
#package : 'Microdown-Agenda-Tests'
}

{ #category : 'running' }
MicAgendaBlockTest >> setUp [

super setUp.
builder := MicMicrodownTextualBuilder new.
parser := Microdown new.
]

{ #category : 'tests' }
MicAgendaBlockTest >> testAgenda [
"'<!agenda
!>
'"
| source root env|
source := EnvironmentOpeningBlockMarkup , 'agenda', String cr,
EnvironmentClosingBlockMarkup, String cr.
root := parser parse: source.
env := root children first.
self assert: (env isKindOf: MicAgendaBlock).
self assert: env environmentName equals: 'agenda'
]

{ #category : 'tests' }
MicAgendaBlockTest >> testAgendaWithArgument [
"'<!agenda|title='A cool agenda'
!>
'"
| source root env|
source := EnvironmentOpeningBlockMarkup , 'agenda|title=A cool agenda', String cr, EnvironmentClosingBlockMarkup, String cr.
root := parser parse: source.
env := root children first.
self assert: (env isKindOf: MicAgendaBlock).
self assert: env environmentName equals: 'agenda'.
self assert: env title equals: 'A cool agenda'
]
Loading

0 comments on commit ee647ff

Please sign in to comment.