From 38f7136e9275e2ae1bf597ad76b3924008abc685 Mon Sep 17 00:00:00 2001 From: "antoine.usal" Date: Mon, 1 Jun 2026 16:07:31 +0200 Subject: [PATCH 1/4] Add new checker MicSecondaryRoot --- src/Microdown-BookTester/MicChecker.class.st | 6 ++++ .../MicSecondaryRootBlockTest.class.st | 36 +++++++++++++++++++ .../MicFileIncluder.class.st | 9 +++-- src/Microdown/MicRootBlock.class.st | 5 +++ src/Microdown/MicSecondaryRootBlock.class.st | 18 ++++++++++ src/Microdown/MicrodownVisitor.class.st | 6 ++++ 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 src/Microdown-Tests/MicSecondaryRootBlockTest.class.st create mode 100644 src/Microdown/MicSecondaryRootBlock.class.st diff --git a/src/Microdown-BookTester/MicChecker.class.st b/src/Microdown-BookTester/MicChecker.class.st index 6d6551232..93daae06a 100644 --- a/src/Microdown-BookTester/MicChecker.class.st +++ b/src/Microdown-BookTester/MicChecker.class.st @@ -157,3 +157,9 @@ MicChecker >> rootDirectory: aFileReference [ rootDirectory := aFileReference ] + +{ #category : 'testing' } +MicChecker >> visitSecondaryRootBlock: aSecondaryRootBlock [ + + ^ self visitChildrenOf: aSecondaryRootBlock +] diff --git a/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st b/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st new file mode 100644 index 000000000..6dca15800 --- /dev/null +++ b/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st @@ -0,0 +1,36 @@ +Class { + #name : 'MicSecondaryRootBlockTest', + #superclass : 'TestCase', + #category : 'Microdown-Tests-Model', + #package : 'Microdown-Tests', + #tag : 'Model' +} + +{ #category : 'tests' } +MicSecondaryRootBlockTest >> testAcceptDoubleDispatch [ + + | block visitor | + block := MicSecondaryRootBlock new. + visitor := MicrodownVisitor new. + self shouldnt: [ block accept: visitor ] raise: Error +] + +{ #category : 'tests' } +MicSecondaryRootBlockTest >> testCanHoldChildren [ + + | root child | + root := MicSecondaryRootBlock new. + child := MicParagraphBlock new. + + root addChild: child. + + self assert: root children size equals: 1. + self assert: root children first equals: child +] + +{ #category : 'tests' } +MicSecondaryRootBlockTest >> testIsSecondaryRoot [ + + self assert: MicSecondaryRootBlock new isSecondaryRoot. + self deny: MicRootBlock new isSecondaryRoot +] diff --git a/src/Microdown-Transformer/MicFileIncluder.class.st b/src/Microdown-Transformer/MicFileIncluder.class.st index 176cc82ac..56440d0ab 100644 --- a/src/Microdown-Transformer/MicFileIncluder.class.st +++ b/src/Microdown-Transformer/MicFileIncluder.class.st @@ -113,14 +113,17 @@ MicFileIncluder >> topFile: aFileReference [ MicFileIncluder >> visitInputFile: anInputFileAnnotation [ "I load the file and if the file exist I replace the node of the annotation by the content of the file." - | inputRef inputDoc | + | inputRef inputDoc newRoot | inputRef := anInputFileAnnotation path. [ inputDoc := inputRef loadMicrodown inlineInputFiles] on: MicResourceReferenceError do: [ :error | isStrict ifFalse: [ ^ self ] ifTrue: [ error pass ]]. - - self replaceCurrentNodeBy: inputDoc children + + newRoot := MicSecondaryRootBlock new. + newRoot children: inputDoc children. + + self replaceCurrentNodeBy: { newRoot } ] diff --git a/src/Microdown/MicRootBlock.class.st b/src/Microdown/MicRootBlock.class.st index 7cd5b796f..1562e49bf 100644 --- a/src/Microdown/MicRootBlock.class.st +++ b/src/Microdown/MicRootBlock.class.st @@ -105,6 +105,11 @@ MicRootBlock >> initialize [ debugId := self class nextDebugId. ] +{ #category : 'debugging' } +MicRootBlock >> isSecondaryRoot [ + ^ false +] + { #category : 'hooks' } MicRootBlock >> massageLine: aLine [ "In some cases an element may want to massage the line such as removing leading tab. By default we delegate to the parent because environments may contain nodes such as code block and this is this nesting that will determine what should be done with the tab. In such a case the environment should remov the tabs. Here on the root we do nothing special." diff --git a/src/Microdown/MicSecondaryRootBlock.class.st b/src/Microdown/MicSecondaryRootBlock.class.st new file mode 100644 index 000000000..9dd33f786 --- /dev/null +++ b/src/Microdown/MicSecondaryRootBlock.class.st @@ -0,0 +1,18 @@ +Class { + #name : 'MicSecondaryRootBlock', + #superclass : 'MicRootBlock', + #category : 'Microdown-Model', + #package : 'Microdown', + #tag : 'Model' +} + +{ #category : 'testing' } +MicSecondaryRootBlock >> accept: aVisitor [ + + ^ aVisitor visitSecondaryRootBlock: self +] + +{ #category : 'testing' } +MicSecondaryRootBlock >> isSecondaryRoot [ + ^true +] diff --git a/src/Microdown/MicrodownVisitor.class.st b/src/Microdown/MicrodownVisitor.class.st index 03822d82e..c314d731e 100644 --- a/src/Microdown/MicrodownVisitor.class.st +++ b/src/Microdown/MicrodownVisitor.class.st @@ -264,6 +264,12 @@ MicrodownVisitor >> visitScript: aSlide [ ^ self visitChildrenOf: aSlide ] +{ #category : 'visiting' } +MicrodownVisitor >> visitSecondaryRootBlock: aSecondaryRootBlock [ + + ^ self visitRoot: aSecondaryRootBlock +] + { #category : 'visiting' } MicrodownVisitor >> visitSegment: aSegment [ "subclassResponsibility" From 75b1c2509bd87776aeaaab1c069171d11851ddd6 Mon Sep 17 00:00:00 2001 From: "antoine.usal" Date: Tue, 2 Jun 2026 11:41:40 +0200 Subject: [PATCH 2/4] Update MicSecondaryRoot --- src/Microdown-BookTester/MicChecker.class.st | 6 ----- .../MicSecondaryRootBlockTest.class.st | 23 +++++++++++++++++-- .../MicFileIncluder.class.st | 5 ++-- src/Microdown/MicRootBlock.class.st | 3 ++- src/Microdown/MicSecondaryRootBlock.class.st | 14 +++++++++-- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/Microdown-BookTester/MicChecker.class.st b/src/Microdown-BookTester/MicChecker.class.st index 93daae06a..6d6551232 100644 --- a/src/Microdown-BookTester/MicChecker.class.st +++ b/src/Microdown-BookTester/MicChecker.class.st @@ -157,9 +157,3 @@ MicChecker >> rootDirectory: aFileReference [ rootDirectory := aFileReference ] - -{ #category : 'testing' } -MicChecker >> visitSecondaryRootBlock: aSecondaryRootBlock [ - - ^ self visitChildrenOf: aSecondaryRootBlock -] diff --git a/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st b/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st index 6dca15800..303397e5f 100644 --- a/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st +++ b/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st @@ -28,9 +28,28 @@ MicSecondaryRootBlockTest >> testCanHoldChildren [ self assert: root children first equals: child ] +{ #category : 'tests' } +MicSecondaryRootBlockTest >> testFileProperty [ + + | root fileRef | + root := MicSecondaryRootBlock new. + fileRef := 'fichierInclus.md'. + + root file: fileRef. + + self assert: root file equals: fileRef +] + { #category : 'tests' } MicSecondaryRootBlockTest >> testIsSecondaryRoot [ - self assert: MicSecondaryRootBlock new isSecondaryRoot. - self deny: MicRootBlock new isSecondaryRoot + | mainRoot secondaryRoot | + mainRoot := MicRootBlock new. + secondaryRoot := MicSecondaryRootBlock new. + + self deny: mainRoot isSecondaryRoot. + + secondaryRoot parent: mainRoot. + + self assert: secondaryRoot isSecondaryRoot ] diff --git a/src/Microdown-Transformer/MicFileIncluder.class.st b/src/Microdown-Transformer/MicFileIncluder.class.st index 56440d0ab..8fdbbbd61 100644 --- a/src/Microdown-Transformer/MicFileIncluder.class.st +++ b/src/Microdown-Transformer/MicFileIncluder.class.st @@ -120,10 +120,11 @@ MicFileIncluder >> visitInputFile: anInputFileAnnotation [ do: [ :error | isStrict ifFalse: [ ^ self ] ifTrue: [ error pass ]]. - + newRoot := MicSecondaryRootBlock new. + newRoot file: inputRef. newRoot children: inputDoc children. - + self replaceCurrentNodeBy: { newRoot } ] diff --git a/src/Microdown/MicRootBlock.class.st b/src/Microdown/MicRootBlock.class.st index 1562e49bf..3ecafffe5 100644 --- a/src/Microdown/MicRootBlock.class.st +++ b/src/Microdown/MicRootBlock.class.st @@ -107,7 +107,8 @@ MicRootBlock >> initialize [ { #category : 'debugging' } MicRootBlock >> isSecondaryRoot [ - ^ false + + ^ parent notNil ] { #category : 'hooks' } diff --git a/src/Microdown/MicSecondaryRootBlock.class.st b/src/Microdown/MicSecondaryRootBlock.class.st index 9dd33f786..4a809ffce 100644 --- a/src/Microdown/MicSecondaryRootBlock.class.st +++ b/src/Microdown/MicSecondaryRootBlock.class.st @@ -1,6 +1,9 @@ Class { #name : 'MicSecondaryRootBlock', #superclass : 'MicRootBlock', + #instVars : [ + 'file' + ], #category : 'Microdown-Model', #package : 'Microdown', #tag : 'Model' @@ -13,6 +16,13 @@ MicSecondaryRootBlock >> accept: aVisitor [ ] { #category : 'testing' } -MicSecondaryRootBlock >> isSecondaryRoot [ - ^true +MicSecondaryRootBlock >> file [ + + ^ file +] + +{ #category : 'testing' } +MicSecondaryRootBlock >> file: aFileReference [ + + file := aFileReference ] From 73ad69cfb41399be56d176b053d9083bc5ce4566 Mon Sep 17 00:00:00 2001 From: "antoine.usal" Date: Mon, 8 Jun 2026 14:52:40 +0200 Subject: [PATCH 3/4] Remove file: --- .../MicSecondaryRootBlockTest.class.st | 11 +++-------- src/Microdown-Transformer/MicFileIncluder.class.st | 3 +-- src/Microdown/MicRootBlock.class.st | 3 +-- src/Microdown/MicSecondaryRootBlock.class.st | 14 ++------------ 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st b/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st index 303397e5f..3acca03f0 100644 --- a/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st +++ b/src/Microdown-Tests/MicSecondaryRootBlockTest.class.st @@ -30,26 +30,21 @@ MicSecondaryRootBlockTest >> testCanHoldChildren [ { #category : 'tests' } MicSecondaryRootBlockTest >> testFileProperty [ - | root fileRef | root := MicSecondaryRootBlock new. - fileRef := 'fichierInclus.md'. + fileRef := 'fichierInclus.md' asFileReference. - root file: fileRef. + root fromFile: fileRef. - self assert: root file equals: fileRef + self assert: root fromFile equals: fileRef ] { #category : 'tests' } MicSecondaryRootBlockTest >> testIsSecondaryRoot [ - | mainRoot secondaryRoot | mainRoot := MicRootBlock new. secondaryRoot := MicSecondaryRootBlock new. self deny: mainRoot isSecondaryRoot. - - secondaryRoot parent: mainRoot. - self assert: secondaryRoot isSecondaryRoot ] diff --git a/src/Microdown-Transformer/MicFileIncluder.class.st b/src/Microdown-Transformer/MicFileIncluder.class.st index 8fdbbbd61..2b694b4e6 100644 --- a/src/Microdown-Transformer/MicFileIncluder.class.st +++ b/src/Microdown-Transformer/MicFileIncluder.class.st @@ -122,9 +122,8 @@ MicFileIncluder >> visitInputFile: anInputFileAnnotation [ ifTrue: [ error pass ]]. newRoot := MicSecondaryRootBlock new. - newRoot file: inputRef. + newRoot fromFile: inputRef. newRoot children: inputDoc children. self replaceCurrentNodeBy: { newRoot } - ] diff --git a/src/Microdown/MicRootBlock.class.st b/src/Microdown/MicRootBlock.class.st index 3ecafffe5..1562e49bf 100644 --- a/src/Microdown/MicRootBlock.class.st +++ b/src/Microdown/MicRootBlock.class.st @@ -107,8 +107,7 @@ MicRootBlock >> initialize [ { #category : 'debugging' } MicRootBlock >> isSecondaryRoot [ - - ^ parent notNil + ^ false ] { #category : 'hooks' } diff --git a/src/Microdown/MicSecondaryRootBlock.class.st b/src/Microdown/MicSecondaryRootBlock.class.st index 4a809ffce..b54fe783e 100644 --- a/src/Microdown/MicSecondaryRootBlock.class.st +++ b/src/Microdown/MicSecondaryRootBlock.class.st @@ -1,9 +1,6 @@ Class { #name : 'MicSecondaryRootBlock', #superclass : 'MicRootBlock', - #instVars : [ - 'file' - ], #category : 'Microdown-Model', #package : 'Microdown', #tag : 'Model' @@ -16,13 +13,6 @@ MicSecondaryRootBlock >> accept: aVisitor [ ] { #category : 'testing' } -MicSecondaryRootBlock >> file [ - - ^ file -] - -{ #category : 'testing' } -MicSecondaryRootBlock >> file: aFileReference [ - - file := aFileReference +MicSecondaryRootBlock >> isSecondaryRoot [ + ^ true ] From 70bfdf19a62c6852b9996b9c9eefc8058848b196 Mon Sep 17 00:00:00 2001 From: "antoine.usal" Date: Thu, 11 Jun 2026 16:05:42 +0200 Subject: [PATCH 4/4] fix broken tests --- .../MicFileIncluderTest.class.st | 127 +++++++----------- .../MicFileIncluder.class.st | 1 + src/Microdown/MicSecondaryRootBlock.class.st | 5 + 3 files changed, 58 insertions(+), 75 deletions(-) diff --git a/src/Microdown-Transformer-Tests/MicFileIncluderTest.class.st b/src/Microdown-Transformer-Tests/MicFileIncluderTest.class.st index d49f752e5..279694d5e 100644 --- a/src/Microdown-Transformer-Tests/MicFileIncluderTest.class.st +++ b/src/Microdown-Transformer-Tests/MicFileIncluderTest.class.st @@ -84,7 +84,6 @@ Pharo is **cool** { #category : 'tests' } MicFileIncluderTest >> testHandleNestedFileResolution [ - | root file reference | (filesystem workingDirectory / 'Chapters') createDirectory. (filesystem workingDirectory / 'Chapters' / 'SUnit') createDirectory. @@ -95,46 +94,39 @@ MicFileIncluderTest >> testHandleNestedFileResolution [ setStream: stream; inputfile: 'SUnit/anExample1.md' ]. - file := filesystem workingDirectory / 'Chapters' / 'SUnit' - / 'anExample1.md'. + file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'anExample1.md'. file writeStreamDo: [ :stream | builder setStream: stream; header: [ builder text: 'Foo' ] withLevel: 1; inputfile: 'anExample2.md' ]. - file := filesystem workingDirectory / 'Chapters' / 'SUnit' - / 'anExample2.md'. + file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'anExample2.md'. file writeStreamDo: [ :stream | builder setStream: stream; header: [ builder text: 'Example2' ] withLevel: 1 ]. - reference := (MicResourceReference fromUri: - 'file:///Chapters/SUnit.md') fileSystem: filesystem. + reference := (MicResourceReference fromUri: 'file:///Chapters/SUnit.md') fileSystem: filesystem. includer topFile: reference fileReference parent. includer visit: (root := reference loadMicrodown). - self assert: root children first class equals: MicHeaderBlock. - self - assert: root children first children first bodyString - equals: 'Foo'. + self assert: root children first class equals: MicSecondaryRootBlock. + self assert: root children first children first class equals: MicHeaderBlock. + self assert: root children first children first children first bodyString equals: 'Foo'. - self assert: root children second class equals: MicHeaderBlock. - self - assert: root children second children first bodyString - equals: 'Example2' + self assert: root children first children second class equals: MicSecondaryRootBlock. + self assert: root children first children second children first class equals: MicHeaderBlock. + self assert: root children first children second children first children first bodyString equals: 'Example2' ] { #category : 'tests' } MicFileIncluderTest >> testHandleNestedFileResolutionOnDifferentLevel [ - | root file reference | (filesystem workingDirectory / 'Chapters') createDirectory. (filesystem workingDirectory / 'Chapters' / 'SUnit') createDirectory. - (filesystem workingDirectory / 'Chapters' / 'SUnit' / 'Sub') - createDirectory. + (filesystem workingDirectory / 'Chapters' / 'SUnit' / 'Sub') createDirectory. file := filesystem workingDirectory / 'Chapters' / 'SUnit.md'. file writeStreamDo: [ :stream | @@ -142,47 +134,40 @@ MicFileIncluderTest >> testHandleNestedFileResolutionOnDifferentLevel [ setStream: stream; inputfile: 'SUnit/anExample1.md' ]. - file := filesystem workingDirectory / 'Chapters' / 'SUnit' - / 'anExample1.md'. + file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'anExample1.md'. file writeStreamDo: [ :stream | builder setStream: stream; header: [ builder text: 'Foo' ] withLevel: 1; inputfile: 'Sub/anExample2.md' ]. - file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'Sub' - / 'anExample2.md'. + file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'Sub' / 'anExample2.md'. file writeStreamDo: [ :stream | builder setStream: stream; header: [ builder text: 'Example2' ] withLevel: 1 ]. - reference := (MicResourceReference fromUri: - 'file:///Chapters/SUnit.md') fileSystem: filesystem. + reference := (MicResourceReference fromUri: 'file:///Chapters/SUnit.md') fileSystem: filesystem. includer topFile: reference fileReference parent. includer visit: (root := reference loadMicrodown). - self assert: root children first class equals: MicHeaderBlock. - self - assert: root children first children first bodyString - equals: 'Foo'. + self assert: root children first class equals: MicSecondaryRootBlock. + self assert: root children first children first class equals: MicHeaderBlock. + self assert: root children first children first children first bodyString equals: 'Foo'. - self assert: root children second class equals: MicHeaderBlock. - self - assert: root children second children first bodyString - equals: 'Example2' + self assert: root children first children second class equals: MicSecondaryRootBlock. + self assert: root children first children second children first class equals: MicHeaderBlock. + self assert: root children first children second children first children first bodyString equals: 'Example2' ] { #category : 'tests' } MicFileIncluderTest >> testIncluderIncludesInputFileFromTheSameLevel [ - | root file reference | (filesystem workingDirectory / 'Chapters') createDirectory. (filesystem workingDirectory / 'Chapters' / 'SUnit') createDirectory. - file := filesystem workingDirectory / 'Chapters' / 'SUnit' - / 'anExample1.md'. + file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'anExample1.md'. file writeStreamDo: [ :stream | builder setStream: stream; @@ -190,30 +175,25 @@ MicFileIncluderTest >> testIncluderIncludesInputFileFromTheSameLevel [ text: 'Pharo is cool'; codeblock: 'This is a code' ]. - file := filesystem workingDirectory / 'Chapters' / 'SUnit' - / 'SUnit.md'. + file := filesystem workingDirectory / 'Chapters' / 'SUnit' / 'SUnit.md'. file writeStreamDo: [ :stream | builder setStream: stream; inputfile: 'anExample1.md' ]. - reference := (MicResourceReference fromUri: - 'file:///Chapters/SUnit/SUnit.md') fileSystem: - filesystem. + reference := (MicResourceReference fromUri: 'file:///Chapters/SUnit/SUnit.md') fileSystem: filesystem. root := reference loadMicrodown. self assert: root children first class equals: MicInputfileBlock. - self assert: - (root children first path isKindOf: MicResourceReference). + self assert: (root children first path isKindOf: MicResourceReference). includer visit: root. - self assert: root children first class equals: MicHeaderBlock. - self - assert: root children first children first bodyString - equals: 'Foo'. - self assert: root children second class equals: MicParagraphBlock. - self assert: root children third class equals: MicCodeBlock + self assert: root children first class equals: MicSecondaryRootBlock. + self assert: root children first children first class equals: MicHeaderBlock. + self assert: root children first children first children first bodyString equals: 'Foo'. + self assert: root children first children second class equals: MicParagraphBlock. + self assert: root children first children third class equals: MicCodeBlock ] { #category : 'tests' } @@ -227,26 +207,23 @@ MicFileIncluderTest >> testIncluderIncludesInputFilesWithinTheSameParagraph [ setStream: stream; inputfile: 'anExample1.md'; inputfile: 'anExample2.md' ]. - reference := (MicResourceReference fromUri: 'file:///test.md') - fileSystem: filesystem. + reference := (MicResourceReference fromUri: 'file:///test.md') fileSystem: filesystem. root := reference loadMicrodown. includer visit: root. - self assert: root children first class equals: MicHeaderBlock. - self - assert: root children first children first bodyString - equals: 'Foo'. - self assert: root children first level equals: 1. - self assert: root children second class equals: MicParagraphBlock. - self assert: root children third class equals: MicCodeBlock. - - self assert: root children fourth class equals: MicHeaderBlock. - self - assert: root children fourth children first bodyString - equals: 'Bar'. - self assert: root children fourth level equals: 2. - self assert: root children fifth class equals: MicParagraphBlock. - self assert: root children sixth class equals: MicCodeBlock + self assert: root children first class equals: MicSecondaryRootBlock. + self assert: root children first children first class equals: MicHeaderBlock. + self assert: root children first children first children first bodyString equals: 'Foo'. + self assert: root children first children first level equals: 1. + self assert: root children first children second class equals: MicParagraphBlock. + self assert: root children first children third class equals: MicCodeBlock. + + self assert: root children second class equals: MicSecondaryRootBlock. + self assert: root children second children first class equals: MicHeaderBlock. + self assert: root children second children first children first bodyString equals: 'Bar'. + self assert: root children second children first level equals: 2. + self assert: root children second children second class equals: MicParagraphBlock. + self assert: root children second children third class equals: MicCodeBlock ] { #category : 'tests' } @@ -270,12 +247,11 @@ MicFileIncluderTest >> testIncluderJustReturnInputFileBlockWhenIncludedFileDoesN { #category : 'tests' } MicFileIncluderTest >> testMicFileInclusionTransformMicInputFiles [ - | root file reference | file := filesystem workingDirectory / 'test.md'. file writeStreamDo: [ :stream | builder - setStream: stream; + setStream: stream; inputfile: 'anExample1.md'; paragraph: ''; inputfile: 'anExample2.md' ]. @@ -283,13 +259,14 @@ MicFileIncluderTest >> testMicFileInclusionTransformMicInputFiles [ root := reference loadMicrodown. includer visit: root. - self assert: root children first class equals: MicHeaderBlock. - self assert: root children second class equals: MicParagraphBlock. - self assert: root children third class equals: MicCodeBlock. - - self assert: root children fourth class equals: MicHeaderBlock. - self assert: root children fifth class equals: MicParagraphBlock. + self assert: root children first class equals: MicSecondaryRootBlock. + self assert: root children first children first class equals: MicHeaderBlock. + self assert: root children first children second class equals: MicParagraphBlock. + self assert: root children first children third class equals: MicCodeBlock. - self assert: root children fifth children size equals: 2. - self assert: root children sixth class equals: MicCodeBlock + self assert: root children second class equals: MicSecondaryRootBlock. + self assert: root children second children first class equals: MicHeaderBlock. + self assert: root children second children second class equals: MicParagraphBlock. + self assert: root children second children second children size equals: 2. + self assert: root children second children third class equals: MicCodeBlock ] diff --git a/src/Microdown-Transformer/MicFileIncluder.class.st b/src/Microdown-Transformer/MicFileIncluder.class.st index 2b694b4e6..83ce942d3 100644 --- a/src/Microdown-Transformer/MicFileIncluder.class.st +++ b/src/Microdown-Transformer/MicFileIncluder.class.st @@ -124,6 +124,7 @@ MicFileIncluder >> visitInputFile: anInputFileAnnotation [ newRoot := MicSecondaryRootBlock new. newRoot fromFile: inputRef. newRoot children: inputDoc children. + newRoot children do: [ :each | each parent: newRoot ]. self replaceCurrentNodeBy: { newRoot } ] diff --git a/src/Microdown/MicSecondaryRootBlock.class.st b/src/Microdown/MicSecondaryRootBlock.class.st index b54fe783e..0a4c30a61 100644 --- a/src/Microdown/MicSecondaryRootBlock.class.st +++ b/src/Microdown/MicSecondaryRootBlock.class.st @@ -12,6 +12,11 @@ MicSecondaryRootBlock >> accept: aVisitor [ ^ aVisitor visitSecondaryRootBlock: self ] +{ #category : 'testing' } +MicSecondaryRootBlock >> fromFile: aFileOrResource [ + self propertyAt: #file put: aFileOrResource +] + { #category : 'testing' } MicSecondaryRootBlock >> isSecondaryRoot [ ^ true