Skip to content

Commit 380d9e8

Browse files
committed
A couple more but also skipped new ones that needs more thoughts
1 parent 499141c commit 380d9e8

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

src/Microdown-Templated/MicTemplatedWriter.class.st

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,21 @@ MicTemplatedWriter >> visitAnchorReference: aReference [
333333
ifAbsent: [ defaultWriter visitAnchorReference: aReference ]
334334
]
335335

336-
{ #category : 'old visiting' }
337-
MicTemplatedWriter >> visitAnnotatedParagraph: anAnnotatedParagraph [
336+
{ #category : 'visiting' }
337+
MicTemplatedWriter >> visitAnnotated: anAnnotatedParagraph [
338338

339339
| arguments |
340-
arguments := { 'annotation' -> anAnnotatedParagraph annotation }.
340+
arguments := { 'label' -> anAnnotatedParagraph label }.
341341
self
342342
write: anAnnotatedParagraph
343-
withTemplateFileName: anAnnotatedParagraph annotation , '.mustache'
343+
withTemplateFileName: anAnnotatedParagraph label , '.mustache'
344344
extraArguments: arguments
345345
ifAbsent: [
346346
self
347347
write: anAnnotatedParagraph
348348
withTemplateFileName: self defaultAnnotatedParagraphTemplateFileName
349349
extraArguments: arguments
350-
ifAbsent: [ defaultWriter visitAnnotatedParagraph: anAnnotatedParagraph ] ]
350+
ifAbsent: [ defaultWriter visitAnnotated: anAnnotatedParagraph ] ]
351351
]
352352

353353
{ #category : 'visiting' }

src/Microdown-Templated/MicTemplatedWriterTest.class.st

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,19 @@ MicTemplatedWriterTest >> addTemplateFiles [
4444
writeStreamDo: [ :s | s << self paragraphContents ].
4545
fileSystem / MicTemplatedWriter environmentTemplateFileName
4646
writeStreamDo: [ :s | s << self environmentContents ].
47+
48+
"Pay attention here this is the note label that determines the template name"
49+
fileSystem / 'important.mustache'
50+
writeStreamDo: [ :s | s << self annotatedParagraphContents ].
4751

52+
fileSystem / MicTemplatedWriter defaultAnnotatedParagraphTemplateFileName
53+
writeStreamDo: [ :s | s << self annotatedParagraphContents ].
54+
]
4855

56+
{ #category : 'running' }
57+
MicTemplatedWriterTest >> annotatedParagraphContents [
58+
59+
^ '<b>{{{label}}}</b>{{{contents}}}'
4960
]
5061

5162
{ #category : 'helpers' }
@@ -111,6 +122,12 @@ MicTemplatedWriterTest >> createTemplateFileAt: aPath withContents: contents [
111122
templateFileReference writeStreamDo: [ :stream | stream nextPutAll: contents ].
112123
]
113124

125+
{ #category : 'running' }
126+
MicTemplatedWriterTest >> defaultAnnotatedParagraph [
127+
128+
^ '<b>{{{label}}}</b>{{{contents}}}'
129+
]
130+
114131
{ #category : 'running' }
115132
MicTemplatedWriterTest >> environmentContents [
116133
"Ideally we should be able to have template for each of the different environment based on their names."
@@ -203,6 +220,25 @@ MicTemplatedWriterTest >> setUp [
203220
self addTemplateFiles.
204221
]
205222

223+
{ #category : 'new tests' }
224+
MicTemplatedWriterTest >> testAnnotatedParagraphImportant [
225+
226+
self
227+
assertTemplate: 'important.mustache'
228+
writesValue: '<b>important</b>this is important'
229+
forNode: (Microdown parse: '!!important this is important') children first
230+
]
231+
232+
{ #category : 'new tests' }
233+
MicTemplatedWriterTest >> testAnnotatedParagraphUnsupportedIsThenDefault [
234+
235+
self skip. "To be investigated."
236+
self
237+
assertTemplate: 'important.mustache'
238+
writesValue: '<b>Tintin</b>this is important'
239+
forNode: (Microdown parse: '!!Tintin this is important') children first
240+
]
241+
206242
{ #category : 'tests-setup' }
207243
MicTemplatedWriterTest >> testDirectory [
208244

@@ -218,9 +254,9 @@ MicTemplatedWriterTest >> testDirectory [
218254
MicTemplatedWriterTest >> testWriteAnchorUsesDefaultIfNotSpecificIsDefinedTemplate [
219255

220256
self
221-
assertTemplate: MicTemplatedWriter defaultAnnotatedParagraphTemplateFileName
222-
writesValue: 'annotated paragraph'
223-
forNode: (PRAnnotatedParagraph withAll: #() annotation: 'todo')
257+
assertTemplate: 'important.mustache'
258+
writesValue: '<b>important</b>this is important'
259+
forNode: (Microdown parse: '!!important this is important') children first
224260
]
225261

226262
{ #category : 'new tests' }

0 commit comments

Comments
 (0)