From 79d35182eab1f21fcc9da1c19bde7b32c769fa3a Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Wed, 25 Sep 2024 22:08:01 +0200 Subject: [PATCH 1/4] add text with bracket method for TextualBuilder and a test --- .../MicMicrodownTextualBuilderTest.class.st | 9 +++++++++ .../MicMicrodownTextualBuilder.class.st | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st b/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st index f015d7e9..169d95f5 100644 --- a/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st +++ b/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st @@ -56,6 +56,15 @@ MicMicrodownTextualBuilderTest >> testAnnotated [ > anAnnotatedParagraph', String cr, String cr ] +{ #category : 'tests - anchor' } +MicMicrodownTextualBuilderTest >> testAnnotatedWithMultipleLine [ + + self assert: (builder annotated: 'anAnnotation' paragraph: [ builder textWithBracket: 'anAnnotatedParagraph +an Another Line']) contents equals: '>[!anAnnotation] +> anAnnotatedParagraph +> an Another Line', String cr, String cr +] + { #category : 'tests - anchor' } MicMicrodownTextualBuilderTest >> testAnnotation [ diff --git a/src/Microdown/MicMicrodownTextualBuilder.class.st b/src/Microdown/MicMicrodownTextualBuilder.class.st index ebbfbbb6..2e40b066 100644 --- a/src/Microdown/MicMicrodownTextualBuilder.class.st +++ b/src/Microdown/MicMicrodownTextualBuilder.class.st @@ -525,10 +525,7 @@ MicMicrodownTextualBuilder >> rawAnnotated: annotation paragraph: aBlock [ raw: annotation; raw: AnnotatedParagraphClosingMarkup ; raw: Character cr; - raw: $>; - raw: String space; - rawParagraph: aBlock; - raw: Character cr + rawParagraph: aBlock ] @@ -628,6 +625,19 @@ MicMicrodownTextualBuilder >> strike: aBlock [ self raw: StrikeMarkup. ] +{ #category : 'writing during' } +MicMicrodownTextualBuilder >> textWithBracket: aString [ + + | lines | + lines := aString substrings: String crlf. + lines do: [ :each | + self + raw: $>; + raw: String space; + raw: each; + raw: Character cr ] +] + { #category : 'element - list' } MicMicrodownTextualBuilder >> unorderedListDuring: aBlockClosure [ "For list we do not emit empty line at the end because we do not want to force the creation of a paragraph From 6e56a892be7ecfc2a6f5214c9627a5d0dd527d42 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Wed, 25 Sep 2024 22:11:41 +0200 Subject: [PATCH 2/4] change method use in testAnnotated for add text --- .../MicMicrodownTextualBuilderTest.class.st | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st b/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st index 169d95f5..cc4c99bf 100644 --- a/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st +++ b/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st @@ -52,8 +52,12 @@ MicMicrodownTextualBuilderTest >> testAnchorReference [ { #category : 'tests - anchor' } MicMicrodownTextualBuilderTest >> testAnnotated [ - self assert: (builder annotated: 'anAnnotation' paragraph: [ builder text: 'anAnnotatedParagraph' ]) contents equals: '>[!anAnnotation] -> anAnnotatedParagraph', String cr, String cr + self + assert: (builder + annotated: 'anAnnotation' + paragraph: [ builder textWithBracket: 'anAnnotatedParagraph' ]) contents + equals: '>[!anAnnotation] +> anAnnotatedParagraph' , String cr , String cr ] { #category : 'tests - anchor' } From f4898b1d24ef59b124144f6c0df13439be0e649f Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Sat, 28 Sep 2024 13:30:34 +0200 Subject: [PATCH 3/4] fix MicTextualMicrodownExporter annotated test --- .../MicTextualMicrodownExporter.class.st | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st b/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st index a63fb54b..3ee4e1d2 100644 --- a/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st +++ b/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st @@ -122,9 +122,15 @@ MicTextualMicrodownExporter >> visitAnchorReference: anAnchorReference [ { #category : 'visit - block' } MicTextualMicrodownExporter >> visitAnnotated: anAnnotated [ - builder - annotated: anAnnotated label - paragraph: [ super visitAnnotated: anAnnotated ] + | string textualExporter | + string := ''. + textualExporter := MicTextualMicrodownExporter new. + anAnnotated children do: [ :each | + each accept: textualExporter ]. + + builder + annotated: anAnnotated label + paragraph: [ builder textWithBracket: textualExporter contents ] ] { #category : 'visit - format' } From 1bd2593f8a3fa29c538d67c053fd11df4f3ea902 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Sun, 29 Sep 2024 13:32:56 +0200 Subject: [PATCH 4/4] Removing string variable from visitAnnotated: method of MicTextualMicrodownExporter --- .../MicTextualMicrodownExporter.class.st | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st b/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st index 3ee4e1d2..9c6ad02f 100644 --- a/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st +++ b/src/Microdown-PrettyPrinter/MicTextualMicrodownExporter.class.st @@ -122,11 +122,9 @@ MicTextualMicrodownExporter >> visitAnchorReference: anAnchorReference [ { #category : 'visit - block' } MicTextualMicrodownExporter >> visitAnnotated: anAnnotated [ - | string textualExporter | - string := ''. + | textualExporter | textualExporter := MicTextualMicrodownExporter new. - anAnnotated children do: [ :each | - each accept: textualExporter ]. + anAnnotated children do: [ :each | each accept: textualExporter ]. builder annotated: anAnnotated label