From d53eea52394341af383f125fd087d7f9473f0d07 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Mon, 19 Aug 2024 20:11:53 +0200 Subject: [PATCH 1/8] Change AnnotatedParagraph test for use >[! --- .../MicAnnotatedParagraphTest.class.st | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st b/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st index 84ccee7f..85aa40b9 100644 --- a/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st +++ b/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st @@ -15,7 +15,8 @@ MicAnnotatedParagraphTest >> subjectClass [ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraph [ | root annotatedParagraph | - root := parser parse: '!!important This is an important information'. + root := parser parse: '>[! important ] +> This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. self @@ -29,8 +30,8 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraph [ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithALineBreak [ | root annotatedParagraph | - root := parser parse: '!!important -This is an important information'. + root := parser parse: '>[! important ] +> This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. self @@ -44,7 +45,8 @@ This is an important information'. MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithANonSupportedLabel [ | root annotatedParagraph | - root := parser parse: '!!test This is an important information'. + root := parser parse: '>[! important ] +> This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. self @@ -58,7 +60,8 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithANonSupportedLabel [ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithANonSupportedLabelWithUpperCase [ | root annotatedParagraph | - root := parser parse: '!!Test This is an important information'. + root := parser parse: '>[! important ] +> This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. self @@ -73,7 +76,8 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithBlodText [ | root annotatedParagraph | root := parser parse: - '!!important This is an **important** information'. + '>[! important ] +> This is an **important** information'. self assert: root children size equals: 1. annotatedParagraph := root children first. self @@ -91,7 +95,8 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithBlodText [ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithLabelHavingUpperCase [ | root annotatedParagraph | - root := parser parse: '!!ImporTanT This is an important information'. + root := parser parse: '>[! ImporTanT ] +> This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. self From 39cd94f23ad3186be1b3a2138af998d2c214a624 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Mon, 19 Aug 2024 20:54:03 +0200 Subject: [PATCH 2/8] Change the markup of annotated Paragraph --- .../MicAnnotatedParagraphTest.class.st | 4 ++-- .../MicAbstractAnnotatedBlock.class.st | 22 +++++++++++++------ src/Microdown/MicMicrodownSharedPool.class.st | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st b/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st index 85aa40b9..e5fc4449 100644 --- a/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st +++ b/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st @@ -45,7 +45,7 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithALineBreak [ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithANonSupportedLabel [ | root annotatedParagraph | - root := parser parse: '>[! important ] + root := parser parse: '>[! test ] > This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. @@ -60,7 +60,7 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithANonSupportedLabel [ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithANonSupportedLabelWithUpperCase [ | root annotatedParagraph | - root := parser parse: '>[! important ] + root := parser parse: '>[! Test ] > This is an important information'. self assert: root children size equals: 1. annotatedParagraph := root children first. diff --git a/src/Microdown/MicAbstractAnnotatedBlock.class.st b/src/Microdown/MicAbstractAnnotatedBlock.class.st index 26fd2bb7..eca83579 100644 --- a/src/Microdown/MicAbstractAnnotatedBlock.class.st +++ b/src/Microdown/MicAbstractAnnotatedBlock.class.st @@ -18,14 +18,17 @@ MicAbstractAnnotatedBlock >> addLineAndReturnNextNode: line [ ifTrue: [ ^ self ]. label ifNil: [ - | indexOfFirstSpace | - indexOfFirstSpace := line indexOf: Character space. - label := indexOfFirstSpace = 0 + | indexOfFirstClosingBracket | + indexOfFirstClosingBracket := line indexOf: $]. + label := indexOfFirstClosingBracket = 0 ifTrue: [ '' ] - ifFalse: [line copyFrom: self lineMarkup size + 1 to: indexOfFirstSpace - 1.]. - body := (line copyFrom: indexOfFirstSpace + 1 to: line size) trim.] - ifNotNil: [ body = '' ifTrue: [ body := body , line ] - ifFalse: [ body := body , String cr , line ]] + ifFalse: [line copyFrom: self lineMarkup size + 1 to: indexOfFirstClosingBracket - 1.]. + label := label trim] + ifNotNil: [ | treatedLine | + treatedLine := self extractLine: line. + body := body + ifNil: [ treatedLine ] + ifNotNil: [ body , String cr , treatedLine ]] ] { #category : 'accessing' } @@ -41,6 +44,11 @@ MicAbstractAnnotatedBlock >> canConsumeLine: line [ ^ line isNotEmpty ] +{ #category : 'actions' } +MicAbstractAnnotatedBlock >> extractLine: line [ + ^ (line copyFrom: 2 to: line size) trim +] + { #category : 'initialization' } MicAbstractAnnotatedBlock >> initialize [ diff --git a/src/Microdown/MicMicrodownSharedPool.class.st b/src/Microdown/MicMicrodownSharedPool.class.st index cd24cad4..bf63619d 100644 --- a/src/Microdown/MicMicrodownSharedPool.class.st +++ b/src/Microdown/MicMicrodownSharedPool.class.st @@ -57,7 +57,7 @@ MicMicrodownSharedPool class >> initialize [ "self initialize" AnchorMarkup := '@'. - AnnotatedParagraphMarkup := '!!'. + AnnotatedParagraphMarkup := '>[!'. CodeblockMarkup := '```'. CommentedLineMarkup := '%'. EnvironmentClosingBlockMarkup := '!>'. From 86f06a1857440b4fb8904e7df0688cd1e917d881 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Tue, 20 Aug 2024 15:37:50 +0200 Subject: [PATCH 3/8] add new test to AnnotatedParagraph --- .../MicAnnotatedParagraphTest.class.st | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st b/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st index e5fc4449..aa9975ae 100644 --- a/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st +++ b/src/Microdown-Tests/MicAnnotatedParagraphTest.class.st @@ -26,6 +26,33 @@ MicAnnotatedParagraphTest >> testBasicAnnotetedParagraph [ equals: 'This is an important information' ] +{ #category : 'tests' } +MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphIgnoreExtraTextInFirstLine [ + + | root annotatedParagraph | + root := parser parse: '>[! important ] This is an important information +> This is an other information'. + self assert: root children size equals: 1. + annotatedParagraph := root children first. + self + assert: (annotatedParagraph isKindOf: MicAnnotatedParagraph); + assert: annotatedParagraph label equals: 'important'; + assert: annotatedParagraph text + equals: 'This is an other information' +] + +{ #category : 'tests' } +MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWhitoutClosingBracket [ + + | root annotatedParagraph | + root := parser parse: '>[! important +> This is an important information'. + self assert: root children size equals: 1. + annotatedParagraph := root children first. + self + assert: (annotatedParagraph isKindOf: MicBlockQuoteBlock) +] + { #category : 'tests' } MicAnnotatedParagraphTest >> testBasicAnnotetedParagraphWithALineBreak [ From dd2a0ec070cc13ec30c739c90d7b66645ad6fdb4 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Tue, 20 Aug 2024 15:39:56 +0200 Subject: [PATCH 4/8] if annotatedParagraph didn't have closed bracket, so we create a MicBlockQuoteBlock --- .../MicAbstractAnnotatedBlock.class.st | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Microdown/MicAbstractAnnotatedBlock.class.st b/src/Microdown/MicAbstractAnnotatedBlock.class.st index eca83579..1eda5346 100644 --- a/src/Microdown/MicAbstractAnnotatedBlock.class.st +++ b/src/Microdown/MicAbstractAnnotatedBlock.class.st @@ -21,9 +21,10 @@ MicAbstractAnnotatedBlock >> addLineAndReturnNextNode: line [ | indexOfFirstClosingBracket | indexOfFirstClosingBracket := line indexOf: $]. label := indexOfFirstClosingBracket = 0 - ifTrue: [ '' ] - ifFalse: [line copyFrom: self lineMarkup size + 1 to: indexOfFirstClosingBracket - 1.]. - label := label trim] + ifTrue: [ parent children removeLast. ^ self createMicBlockQuoteBlock: line ] + ifFalse: [line copyFrom: self lineMarkup size + 1 to: indexOfFirstClosingBracket - 1. + ]. + label := label trim] ifNotNil: [ | treatedLine | treatedLine := self extractLine: line. body := body @@ -44,6 +45,17 @@ MicAbstractAnnotatedBlock >> canConsumeLine: line [ ^ line isNotEmpty ] +{ #category : 'as yet unclassified' } +MicAbstractAnnotatedBlock >> createMicBlockQuoteBlock: line [ + +^ MicBlockQuoteBlock new + setParser: parser; + parent: parent; + addLineAndReturnNextNode: line + + +] + { #category : 'actions' } MicAbstractAnnotatedBlock >> extractLine: line [ ^ (line copyFrom: 2 to: line size) trim From 6c3bce65d902980e40613aa372e90c5dcc7a87f8 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Wed, 21 Aug 2024 19:49:31 +0200 Subject: [PATCH 5/8] Fix broken exporter test for annotated paragraph --- .../MicHTMLVisitorTest.class.st | 7 +++++-- .../MicTextualMicrodownExporterTest.class.st | 3 ++- src/Microdown-Tests/MicMicrodownSnippetFactory.class.st | 3 ++- .../MicMicrodownTextualBuilderTest.class.st | 3 ++- src/Microdown/MicMicrodownTextualBuilder.class.st | 5 ++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index 81fb1012..668f4ec0 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -148,7 +148,9 @@ MicHTMLVisitorTest >> testCreateAnnotationCompound [ | result | result := writer convertMicString: '# This is a title -!!note Body of annotated block +>[!note] +> Body of annotated block + this is another string'. self @@ -166,7 +168,8 @@ MicHTMLVisitorTest >> testCreateAnnotationSimple [ self assert: writer contents equals: String empty. result := writer convertMicString: - '!!note Body of annotated block'. + '>[!note] +> Body of annotated block'. self assert: result trimBoth equals: diff --git a/src/Microdown-PrettyPrinter-Tests/MicTextualMicrodownExporterTest.class.st b/src/Microdown-PrettyPrinter-Tests/MicTextualMicrodownExporterTest.class.st index 972e43b5..5a1456af 100644 --- a/src/Microdown-PrettyPrinter-Tests/MicTextualMicrodownExporterTest.class.st +++ b/src/Microdown-PrettyPrinter-Tests/MicTextualMicrodownExporterTest.class.st @@ -71,7 +71,8 @@ MicTextualMicrodownExporterTest >> testAnnotated [ | mic | mic := parser parse: factory annotatedSample. - self assert: (mic accept: visitor) contents equals: '!!note label Foo _bar_ + self assert: (mic accept: visitor) contents equals: '>[!note] +> label Foo _bar_ ' ] diff --git a/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st b/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st index 750acbf2..aa8937d8 100644 --- a/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st +++ b/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st @@ -87,7 +87,8 @@ MicMicrodownSnippetFactory >> anchorWithSpaceInsideSample [ { #category : 'anchor' } MicMicrodownSnippetFactory >> annotatedSample [ - ^ '!!label Foo _bar_ + ^ '>[!label] +> Foo _bar_ ' ] diff --git a/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st b/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st index 16a8b8ef..1ea8e30b 100644 --- a/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st +++ b/src/Microdown-Tests/MicMicrodownTextualBuilderTest.class.st @@ -52,7 +52,8 @@ MicMicrodownTextualBuilderTest >> testAnchorReference [ { #category : 'tests - anchor' } MicMicrodownTextualBuilderTest >> testAnnotated [ - self assert: (builder annotated: 'anAnnotation' paragraph: [ builder text: 'anAnnotatedParagraph' ]) contents equals: '!!anAnnotation anAnnotatedParagraph', String cr + self assert: (builder annotated: 'anAnnotation' paragraph: [ builder text: 'anAnnotatedParagraph' ]) contents equals: '>[!anAnnotation] +> anAnnotatedParagraph', String cr ] { #category : 'tests - anchor' } diff --git a/src/Microdown/MicMicrodownTextualBuilder.class.st b/src/Microdown/MicMicrodownTextualBuilder.class.st index 6c1d4b1b..bebfc7a5 100644 --- a/src/Microdown/MicMicrodownTextualBuilder.class.st +++ b/src/Microdown/MicMicrodownTextualBuilder.class.st @@ -524,7 +524,10 @@ MicMicrodownTextualBuilder >> rawAnnotated: annotation paragraph: aBlock [ attention there is not space between the !! and the label (annotation in pillar) or we should improve the microdown parser" self raw: AnnotatedParagraphMarkup; - raw: annotation; + raw: annotation; + raw: $]; + raw: Character cr; + raw: $>; raw: String space; rawParagraph: aBlock From f67f1406d0a79fdfb6be92795edd24127922aa13 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Wed, 21 Aug 2024 20:02:02 +0200 Subject: [PATCH 6/8] Fix broke test of annotated Paragraph in Microdown Parser Test --- .../MicrodownParserTest.class.st | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Microdown-Tests/MicrodownParserTest.class.st b/src/Microdown-Tests/MicrodownParserTest.class.st index eb8a61ec..0916c5e6 100644 --- a/src/Microdown-Tests/MicrodownParserTest.class.st +++ b/src/Microdown-Tests/MicrodownParserTest.class.st @@ -88,7 +88,8 @@ MicrodownParserTest >> testAnchorMarkupInsideLine [ MicrodownParserTest >> testAnnotatedBlock [ | source root annotated | - source := AnnotatedParagraphMarkup , 'important this is an important paragraph on one line.'. + source := AnnotatedParagraphMarkup , 'important] +> this is an important paragraph on one line.'. root := parser parse: source. self assert: root children size equals: 1. annotated := root children first. @@ -130,8 +131,9 @@ important point because...!'. { #category : 'tests - annotated-paragraph' } MicrodownParserTest >> testAnnotatedBlockOnTwoLines [ | source root annotated | - source := AnnotatedParagraphMarkup , 'important this is an important -paragraph on two lines.'. + source := AnnotatedParagraphMarkup , 'important] +> this is an important +> paragraph on two lines.'. root := parser parse: source. self assert: root children size equals: 1. annotated := root children first. @@ -144,8 +146,9 @@ paragraph on two lines.' { #category : 'tests - annotated-paragraph' } MicrodownParserTest >> testAnnotatedBlockOnTwoLinesWithFormatting [ | source root annotated | - source := AnnotatedParagraphMarkup , 'important **this** is an _important_ -paragraph on two lines.'. + source := AnnotatedParagraphMarkup , 'important] +> **this** is an _important_ +> paragraph on two lines.'. root := parser parse: source. self assert: root children size equals: 1. annotated := root children first. @@ -160,7 +163,8 @@ paragraph on two lines.))' MicrodownParserTest >> testAnnotatedBlockTextElements [ | source root annotated | - source := AnnotatedParagraphMarkup , 'important this is an **important** paragraph on one line.'. + source := AnnotatedParagraphMarkup , 'important] +> this is an **important** paragraph on one line.'. root := parser parse: source. self assert: root children size equals: 1. annotated := root children first. @@ -176,8 +180,9 @@ MicrodownParserTest >> testAnnotatedBlockWithListParserLogic [ "The test does not test what we want. We want a listblock inside the annotatedBlock" | source root annotated line | self flag: #fixme. - source := (AnnotatedParagraphMarkup , 'important this is a point -- one + source := (AnnotatedParagraphMarkup , 'important] +> this is a point +> - one * two ' ) readStream. parser := self parser. @@ -192,11 +197,18 @@ MicrodownParserTest >> testAnnotatedBlockWithListParserLogic [ self assert: annotated parent equals: root. self assert: annotated label equals: 'important'. - self assert: (annotated instVarNamed: 'body') equals: 'this is a point'. "third the second line" line := source nextLine. + self assert: (annotated canConsumeLine: line). + annotated := parser handleLine: line. + self assert: parser current equals: annotated. + self assert: (annotated instVarNamed: 'body') equals: 'this is a point'. + + "fourth the third line" + line := source nextLine. + self assert: (annotated canConsumeLine: line). annotated := parser handleLine: line. self assert: parser current equals: annotated. From 14d2c528e0721e6d4f5c4770b048e661f66821c2 Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Wed, 21 Aug 2024 20:10:35 +0200 Subject: [PATCH 7/8] Classify method createMicBlockQuoteBlock: --- src/Microdown/MicAbstractAnnotatedBlock.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microdown/MicAbstractAnnotatedBlock.class.st b/src/Microdown/MicAbstractAnnotatedBlock.class.st index 1eda5346..60d27d54 100644 --- a/src/Microdown/MicAbstractAnnotatedBlock.class.st +++ b/src/Microdown/MicAbstractAnnotatedBlock.class.st @@ -45,7 +45,7 @@ MicAbstractAnnotatedBlock >> canConsumeLine: line [ ^ line isNotEmpty ] -{ #category : 'as yet unclassified' } +{ #category : 'creating classes' } MicAbstractAnnotatedBlock >> createMicBlockQuoteBlock: line [ ^ MicBlockQuoteBlock new From d199ceef5d6701fdc90fb03c6d1e7b576ef0ee6d Mon Sep 17 00:00:00 2001 From: "quentin.moutte.etu" Date: Wed, 21 Aug 2024 20:41:32 +0200 Subject: [PATCH 8/8] Fix the last broken test of MicrodownParserTest --- src/Microdown-Tests/MicrodownParserTest.class.st | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Microdown-Tests/MicrodownParserTest.class.st b/src/Microdown-Tests/MicrodownParserTest.class.st index 0916c5e6..284a6892 100644 --- a/src/Microdown-Tests/MicrodownParserTest.class.st +++ b/src/Microdown-Tests/MicrodownParserTest.class.st @@ -103,8 +103,9 @@ MicrodownParserTest >> testAnnotatedBlock [ MicrodownParserTest >> testAnnotatedBlockOnMultipleLinesParserLogic [ | source root annotated line | - source := (AnnotatedParagraphMarkup , 'important this is an -important point because...!') readStream. + source := (AnnotatedParagraphMarkup , 'important] +> this is an +> important point because...!') readStream. "first the root block" root := parser parse: ''. @@ -116,9 +117,15 @@ important point because...!') readStream. self assert: annotated parent equals: root. self assert: annotated label equals: 'important'. - self assert: (annotated instVarNamed: 'body') equals: 'this is an'. "third the second line" + line := source nextLine. + self assert: (annotated canConsumeLine: line). + annotated := parser handleLine: line. + self assert: parser current equals: annotated. + self assert: (annotated instVarNamed: 'body') equals: 'this is an'. + +"fourth the third line" line := source nextLine. self assert: (annotated canConsumeLine: line). annotated := parser handleLine: line.