From 2d7eeec25e45b8097276a035cd8b9567a748c3a8 Mon Sep 17 00:00:00 2001 From: anquetil Date: Thu, 2 Jan 2025 12:12:04 +0100 Subject: [PATCH 01/67] Proposing a simple workaround that add empty columns for short rows --- src/Microdown-RichTextComposer/MicRichTextTable.class.st | 5 ++++- src/Microdown-RichTextComposer/MicrodownParser.extension.st | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microdown-RichTextComposer/MicRichTextTable.class.st b/src/Microdown-RichTextComposer/MicRichTextTable.class.st index 1e084bd8e..21bb2912e 100644 --- a/src/Microdown-RichTextComposer/MicRichTextTable.class.st +++ b/src/Microdown-RichTextComposer/MicRichTextTable.class.st @@ -22,7 +22,10 @@ MicRichTextTable >> addHeaders: headers with: renderedRows [ totalHeight := 0. 1 to: headers size do:[ :colIndex | |header colRows colWidth colHeight| header := headers at: colIndex. - colRows := renderedRows collect: [ :row | row at: colIndex ]. + colRows := renderedRows collect: [ :row | + (row size >= colIndex) + ifFalse: [ row add: '' asText ]. + row at: colIndex ]. colWidth := (header asTextMorph width) max: (colRows collect: [:cell| cell asTextMorph width]) max. totalWidth := totalWidth + colWidth. diff --git a/src/Microdown-RichTextComposer/MicrodownParser.extension.st b/src/Microdown-RichTextComposer/MicrodownParser.extension.st index 40f674c8a..ca23a5a9b 100644 --- a/src/Microdown-RichTextComposer/MicrodownParser.extension.st +++ b/src/Microdown-RichTextComposer/MicrodownParser.extension.st @@ -1,6 +1,6 @@ Extension { #name : 'MicrodownParser' } { #category : '*Microdown-RichTextComposer' } -MicrodownParser classSide >> convertToRichText: aString [ +MicrodownParser class >> convertToRichText: aString [ ^ MicRichTextComposer new visit: (self new parse: aString) ] From fef9aac190da8ee5132b0edeeec6bbd1192b423b Mon Sep 17 00:00:00 2001 From: anquetil Date: Tue, 14 Jan 2025 11:59:02 +0100 Subject: [PATCH 02/67] Added tests on the table generated by MicRichTextTable --- .../MicRichTextTableTest.class.st | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/Microdown-RichTextComposer-Tests/MicRichTextTableTest.class.st diff --git a/src/Microdown-RichTextComposer-Tests/MicRichTextTableTest.class.st b/src/Microdown-RichTextComposer-Tests/MicRichTextTableTest.class.st new file mode 100644 index 000000000..40ab3ef1e --- /dev/null +++ b/src/Microdown-RichTextComposer-Tests/MicRichTextTableTest.class.st @@ -0,0 +1,74 @@ +" +A MicRichTextTableTest is a test class for testing the behavior of MicRichTextTable +" +Class { + #name : 'MicRichTextTableTest', + #superclass : 'TestCase', + #instVars : [ + 'tableBlock', + 'header', + 'rowShort', + 'row3' + ], + #category : 'Microdown-RichTextComposer-Tests-Table-Support', + #package : 'Microdown-RichTextComposer-Tests', + #tag : 'Table-Support' +} + +{ #category : 'running' } +MicRichTextTableTest >> setUp [ + + super setUp. + + tableBlock := MicTableBlock new. + + header := { 'Header' asText . 'with' asText . '3 columns' asText }. + rowShort := OrderedCollection withAll: { 'Row' asText . 'with 2 columns' asText }. + row3 := { 'Row' asText . 'with' asText . '3 columns' asText }. + +] + +{ #category : 'tests' } +MicRichTextTableTest >> testRowWith2Columns [ + "if one row is shorter (less columns) than the header, add columns to it" + | table | + + table := MicRichTextTable headers: header rows: { rowShort }. + + self assert: table columns size equals: 3. + self assert: table container exposedRows anyOne submorphs size equals: 3 +] + +{ #category : 'tests' } +MicRichTextTableTest >> testRowWith3Columns [ + + | table | + + table := MicRichTextTable headers: header rows: { row3 }. + + self assert: table columns size equals: 3 +] + +{ #category : 'tests' } +MicRichTextTableTest >> testTableHeader [ + + | table | + + table := MicRichTextTable headers: header rows: { row3 }. + + self assert: table columns size equals: 3. + + table columns do: [ :aFTColumn | + self assert: aFTColumn id isNotNil + ] +] + +{ #category : 'tests' } +MicRichTextTableTest >> testTableRows [ + + | table | + + table := MicRichTextTable headers: header rows: { row3 . row3 }. + + self assert: table container exposedRows size equals: 2 +] From 1e1784dd171f760394cf11f84d1e003f1d91d87d Mon Sep 17 00:00:00 2001 From: Ignacio Losiggio Date: Fri, 31 Jan 2025 17:35:25 +0100 Subject: [PATCH 03/67] Add package tags as a semantic entity that we can attach actions to. Co-Authored-By: Matija Kljajic --- .../MicSemanticAction.class.st | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Microdown-RichTextComposer/MicSemanticAction.class.st b/src/Microdown-RichTextComposer/MicSemanticAction.class.st index 8db6e33d2..c22bcecf4 100644 --- a/src/Microdown-RichTextComposer/MicSemanticAction.class.st +++ b/src/Microdown-RichTextComposer/MicSemanticAction.class.st @@ -59,7 +59,7 @@ MicSemanticAction >> computeEntity [ "either 'Point' for a class or #'''System-Caching''' for a package" size = 1 ifTrue: [ self getClassOrNil - ifNil: [self getPackageOrNil ]. + ifNil: [self getPackageOrNil ifNil: [ self getTagOrNil ] ]. ^ self ]. "only 'Point class'" @@ -139,6 +139,21 @@ MicSemanticAction >> getPackageOrNil [ ] +{ #category : 'instance creation' } +MicSemanticAction >> getTagOrNil [ + + | tagName | + tagName := tokens first asSymbol. + self class packageOrganizer packages do: [ :package | + (tagName beginsWith: package name) ifTrue: [ + package tags do: [ :tag | + package name , '-' , tag name = tagName ifTrue: [ + entity := tag. + ^ entity ] ] ] ]. + entity := nil. + ^ entity +] + { #category : 'testing' } MicSemanticAction >> hasEntity [ ^ entity isNotNil From 693a0134f8b2ea7240e2266ceb1989823b9662dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Thu, 20 Feb 2025 13:37:35 +0100 Subject: [PATCH 04/67] Remove one flaky and not that useful test --- src/Microdown-Tests/MicResourceSettingsTest.class.st | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Microdown-Tests/MicResourceSettingsTest.class.st b/src/Microdown-Tests/MicResourceSettingsTest.class.st index dc81b863f..e73283bf3 100644 --- a/src/Microdown-Tests/MicResourceSettingsTest.class.st +++ b/src/Microdown-Tests/MicResourceSettingsTest.class.st @@ -139,15 +139,6 @@ MicResourceSettingsTest >> testIsOfflineTrueNotFound [ self assert: (self cacheAt: self imageUrl asZnUrl ) isNil ] -{ #category : 'tests' } -MicResourceSettingsTest >> testOnlyOneMethodInMicrodownDefinesSettings [ - | all | - all :=(Pragma allNamed: #systemsettings) - collect: [ :pragma | pragma methodClass ]. - all := all select: [ :class | class package name beginsWith: 'Microdown' ]. - self assert: all size equals: 1 -] - { #category : 'tests' } MicResourceSettingsTest >> testThereAreTwoSettings [ "I am an approximation, just making sure the two class variables exist" From 977891175a37142645c578e469d65e1df8e53196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Thu, 20 Feb 2025 13:44:51 +0100 Subject: [PATCH 05/67] Update README.md --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 43349aa61..649eff5db 100644 --- a/README.md +++ b/README.md @@ -163,23 +163,24 @@ The markup is not interpreted. Codeblock does not support more than four backticks. -## Development in Pharo 12! +## Development in Pharo 13! ### Loading specific version -To load the latest stable version load the master. If you have trouble loading in the latest Pharo just execute the preloading.st script in the .github folder. -This script will remove the existing Microdown package and clear the system. +To load the latest stable version load the master. If you have trouble loading in the latest Pharo just execute the preloading.st script in the .github folder. This script will remove the existing Microdown package and clear the system. +You can also execute the script provided below. + ```Smalltalk Metacello new baseline: 'Microdown'; - repository: 'github://pillar-markup/Microdown:master/src'; + repository: 'github://pillar-markup/Microdown:v2.7.2/src'; load. ``` The process is the following: -- Development in dev -- When stable dev -> in master +- Development happens dev. +- When stable dev -> in master. - When we can build books master is tagged. - Then there is the Pharo integration in dedicated branches. @@ -213,8 +214,15 @@ Metacello new We have two sources: Pharo in one hand and Pillar and both are not totally synchronized. -Using Pharo 12: v2.5.x +Using Pharo 13: v2.7.x +- v2.7.2 merge pharo 13 changes / added gitbridge / OCompiler migration / cleaning syntax description / Ready for Pillar and Foliage +- v2.7.1 LatexQuoteblock-should-not-use-verbatim +- v2.7.0 Fix some errors and API/clients of the textualbuilder + + +Using Pharo 12: v2.5.x +- v2.5.6 - Change html visitor and test for annotated paragraph - v2.5.5 - add support for top-level header as slide definition - v2.5.4 - add backward compatible anchor in caption + tonel V3 format - v2.5.1 - add LaTeX math with reference support for Pharo 12 and Pillar development up to v10.0.0 From 803ef9f296178b19eb04663910ff918611709d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Kljaji=C4=87?= <64456143+matijakljajic@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:45:07 +0100 Subject: [PATCH 06/67] Add atKey:ifAbsent: to MicMetaDataBlock --- src/Microdown/MicMetaDataBlock.class.st | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Microdown/MicMetaDataBlock.class.st b/src/Microdown/MicMetaDataBlock.class.st index a4a9349f2..db51c016c 100644 --- a/src/Microdown/MicMetaDataBlock.class.st +++ b/src/Microdown/MicMetaDataBlock.class.st @@ -42,6 +42,11 @@ MicMetaDataBlock >> atKey: aString [ ^ self body at: aString ] +{ #category : 'accessing' } +MicMetaDataBlock >> atKey: aString ifAbsent: aBlock [ + ^ self body at: aString ifAbsent: aBlock +] + { #category : 'accessing' } MicMetaDataBlock >> atKey: aString put: aString2 [ self body at: aString put: aString2 From 6af2313fbb04d8289b5c223076c5cc6eab3651ef Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Thu, 13 Mar 2025 14:58:59 +0100 Subject: [PATCH 07/67] Inline usage of asStringWithCr --- src/Microdown-BrowserExtensions/Class.extension.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microdown-BrowserExtensions/Class.extension.st b/src/Microdown-BrowserExtensions/Class.extension.st index 6eb2d2495..dd2920933 100644 --- a/src/Microdown-BrowserExtensions/Class.extension.st +++ b/src/Microdown-BrowserExtensions/Class.extension.st @@ -53,10 +53,10 @@ Class >> documentExampleCode [ and: [ self documentExampleCodeSelector match: each selector match ] ] ifNone: [ ^ nil ]. - ^ (exampleMethod sourceCode lines + ^ ((exampleMethod sourceCode lines allButFirst "Remove method name" reject: [ :each | each trimLeft beginsWith: '<' ]) "Remove pragmas" - asStringWithCr + joinUsing: Character cr) trimmed ] From ac53cee115beb5e19a77e833fe23a33084e35e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Kljaji=C4=87?= <64456143+matijakljajic@users.noreply.github.com> Date: Sun, 23 Mar 2025 21:20:10 +0100 Subject: [PATCH 08/67] Add possible rawParagraph rendering and an Environment test --- .../MicHTMLVisitor.class.st | 13 +++++++++++ .../MicEnvironmentBlockTest.class.st | 23 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index 2270094f7..128b10d22 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -474,6 +474,19 @@ MicHTMLVisitor >> visitQuote: aQuote [ with: [ super visitQuote: aQuote ] ] +{ #category : 'visiting - html extensions' } +MicHTMLVisitor >> visitRawParagraph: aParagraph [ + + canvas + newLine; + raw: '<' , aParagraph label , '>'; + raw: (aParagraph body + ifNil: [ '' ] + ifNotNil: [ canvas newLine. ^ aParagraph body ]); + newLine; + raw: aParagraph lineStopMarkup +] + { #category : 'visiting - inline elements' } MicHTMLVisitor >> visitStrike: aStrike [ diff --git a/src/Microdown-Tests/MicEnvironmentBlockTest.class.st b/src/Microdown-Tests/MicEnvironmentBlockTest.class.st index b1058982a..3ae21fc52 100644 --- a/src/Microdown-Tests/MicEnvironmentBlockTest.class.st +++ b/src/Microdown-Tests/MicEnvironmentBlockTest.class.st @@ -294,6 +294,29 @@ environment, else we force writer to enter a new line to declare the end of the paragraph.'. ] +{ #category : 'tests' } +MicEnvironmentBlockTest >> testEnvironmentWithSameNestedElementAsParent [ + "' +?> +'" + + | source root env environmentName | + environmentName := 'slide'. + source := EnvironmentOpeningBlockMarkup , environmentName , String cr + , EnvironmentOpeningBlockMarkup , environmentName + , String cr , EnvironmentClosingBlockMarkup , String cr + , EnvironmentClosingBlockMarkup , String cr. + root := parser parse: source. + + self assert: root children size equals: 1. + env := root children first. + self assert: (env isKindOf: MicSlideBlock). + + self assert: env children first class equals: MicSlideBlock +] + { #category : 'tests - extensions' } MicEnvironmentBlockTest >> testExtensionClassWithSpaceAndArgIsCreated [ From 7172d6bd9984e41a6dbc37d6278febfcd076bff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 24 Mar 2025 11:22:46 +0100 Subject: [PATCH 09/67] Adding another test for nested environment --- .../MicEnvironmentBlockTest.class.st | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Microdown-Tests/MicEnvironmentBlockTest.class.st b/src/Microdown-Tests/MicEnvironmentBlockTest.class.st index 3ae21fc52..92ab58d7a 100644 --- a/src/Microdown-Tests/MicEnvironmentBlockTest.class.st +++ b/src/Microdown-Tests/MicEnvironmentBlockTest.class.st @@ -317,6 +317,34 @@ MicEnvironmentBlockTest >> testEnvironmentWithSameNestedElementAsParent [ self assert: env children first class equals: MicSlideBlock ] +{ #category : 'tests' } +MicEnvironmentBlockTest >> testEnvironmentWithSameNestedElementAsParentWithBody [ + "' +?> +'" + + | source root env environmentName | + environmentName := 'slide'. + source := EnvironmentOpeningBlockMarkup , environmentName , String cr, +'- item 1 +- item 2 + +' + , EnvironmentOpeningBlockMarkup , environmentName + , String cr , '## Here is a slide', String cr, EnvironmentClosingBlockMarkup , String cr + , EnvironmentClosingBlockMarkup , String cr. + root := parser parse: source. + + self assert: root children size equals: 1. + env := root children first. + self assert: (env isKindOf: MicSlideBlock). + + self assert: env children first class equals: MicUnorderedListBlock. + self assert: env children second class equals: MicSlideBlock. +] + { #category : 'tests - extensions' } MicEnvironmentBlockTest >> testExtensionClassWithSpaceAndArgIsCreated [ From ed6c676c9340341b5a466abbbe4a7fff0124eef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 24 Mar 2025 11:40:31 +0100 Subject: [PATCH 10/67] Fix visitRawParagraph: Add some tests + one skip ready to fix the parsing of argumentList --- .../MicHTMLVisitorTest.class.st | 38 +++++++++++++++++++ .../MicHTMLVisitor.class.st | 12 +++--- .../MicMicrodownSnippetFactory.class.st | 10 +++++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index 197c869d2..8ad2ff4cf 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -198,6 +198,44 @@ MicHTMLVisitorTest >> testCreateItalic [ ] +{ #category : 'tests' } +MicHTMLVisitorTest >> testRawParagraphIframe [ + + | result | + self skip. + self assert: writer contents equals: String empty. + + result := writer convertMicString: ''. + self assert: result trimBoth equals: '' + +] + +{ #category : 'tests' } +MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ + + | result | + self assert: writer contents equals: String empty. + + result := writer convertMicString: MicMicrodownSnippetFactory new rawParagraphSimpleDiv. + self assert: result trimBoth equals: MicMicrodownSnippetFactory new rawParagraphSimpleDiv. + +] + +{ #category : 'tests' } +MicHTMLVisitorTest >> testRawParagraphSimpleEmptyDiv [ + + | result | + self assert: writer contents equals: String empty. + + result := writer convertMicString: '
+
'. + self assert: result trimBoth equals: '
+
' + +] + { #category : 'tests' } MicHTMLVisitorTest >> testVisitAnchor [ diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index 128b10d22..7abf7bdb0 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -476,13 +476,15 @@ MicHTMLVisitor >> visitQuote: aQuote [ { #category : 'visiting - html extensions' } MicHTMLVisitor >> visitRawParagraph: aParagraph [ - + canvas newLine; - raw: '<' , aParagraph label , '>'; - raw: (aParagraph body - ifNil: [ '' ] - ifNotNil: [ canvas newLine. ^ aParagraph body ]); + raw: '<' , aParagraph label , '>'. + (aParagraph body + ifNil: [ canvas raw: '' ] + ifNotNil: [ canvas newLine. + canvas raw: aParagraph body ]). + canvas newLine; raw: aParagraph lineStopMarkup ] diff --git a/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st b/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st index 178980130..6c81e7346 100644 --- a/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st +++ b/src/Microdown-Tests/MicMicrodownSnippetFactory.class.st @@ -858,6 +858,16 @@ a{{Foo}}b ' ] +{ #category : 'rawParagraph' } +MicMicrodownSnippetFactory >> rawParagraphSimpleDiv [ + + ^ '
+some text +and +more +
' +] + { #category : 'figures' } MicMicrodownSnippetFactory >> realLinkSample [ ^ ' From 149c593798143dad2d3c805f74357e2eb0251638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 24 Mar 2025 16:25:39 +0100 Subject: [PATCH 11/67] Fixing ugly tests --- .../MicHTMLVisitorTest.class.st | 19 ++++++++++--------- src/Microdown/MicRawParagraphBlock.class.st | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index 8ad2ff4cf..8ca855134 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -215,11 +215,13 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ { #category : 'tests' } MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ - | result | + | result source | self assert: writer contents equals: String empty. - - result := writer convertMicString: MicMicrodownSnippetFactory new rawParagraphSimpleDiv. - self assert: result trimBoth equals: MicMicrodownSnippetFactory new rawParagraphSimpleDiv. + source := '
', newLine , 'some text +and +more', newLine, '
'. + result := writer convertMicString: source. + self assert: result trimBoth equals: source. ] @@ -229,11 +231,10 @@ MicHTMLVisitorTest >> testRawParagraphSimpleEmptyDiv [ | result | self assert: writer contents equals: String empty. - result := writer convertMicString: '
-
'. - self assert: result trimBoth equals: '
-
' - + result := writer convertMicString: '
', newLine, +'
'. + self assert: result trimBoth equals: '
', newLine, +'
'. ] { #category : 'tests' } diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index 476307ad4..5a1a29dc8 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -20,7 +20,8 @@ MicRawParagraphBlock >> bodyFromLine: line [ (self doesLineStartWithStopMarkup: line) ifTrue: [ isClosed := true ] - ifFalse: [ body := body ifNil: [ line ] ifNotNil: [ body , String cr , line ] ] + ifFalse: [ body := body ifNil: [ line ] ifNotNil: [ + body , String cr , line ] ] ] { #category : 'handle' } From 47fc376884261d5f7a3a41fc020290cd00404131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 24 Mar 2025 16:49:33 +0100 Subject: [PATCH 12/67] Adding an important comment --- src/Microdown/MicEnvironmentBlock.class.st | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Microdown/MicEnvironmentBlock.class.st b/src/Microdown/MicEnvironmentBlock.class.st index c0af9ac9f..c75b4ea57 100644 --- a/src/Microdown/MicEnvironmentBlock.class.st +++ b/src/Microdown/MicEnvironmentBlock.class.st @@ -152,6 +152,9 @@ MicEnvironmentBlock >> closeMe [ body := self inlineParse: body ]. children := body" + "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser + For example the # Header to Slide is a typically case. " + arguments := MicArgumentList split: firstLine defaultArg: #environmentName @@ -179,12 +182,16 @@ MicEnvironmentBlock >> extractFirstLineFrom: aLine [ ifFalse: [ firstLine ] ] -{ #category : 'initialization' } +{ #category : 'parse support' } MicEnvironmentBlock >> initialize [ super initialize. - arguments := MicArgumentList new - + + "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser + For example the # Header to Slide is a typically case. Therefore the following initialization is needed even if + on parse time the arguments will get reset with another one." + + arguments := MicArgumentList new ] { #category : 'markups' } From 45907f62829b8cbb6069f4c871deae36b5de8106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 24 Mar 2025 21:45:27 +0100 Subject: [PATCH 13/67] Getting a first version of MicRawParagraph support for nested elements. - introduced a new superclass - migrated tests that were supposing that elements cannot be nested. - revisited visitRawParagraph: - all tests green - next step - make the test: testRawParagraphIframe passes --- .../MicHTMLVisitorTest.class.st | 11 +- .../MicHTMLVisitor.class.st | 6 +- ...downObjectToPillarObjectConverter.class.st | 11 +- .../MicRawParagraphBlockTest.class.st | 7 +- src/Microdown/MicAbstractCodeBlock.class.st | 11 ++ src/Microdown/MicEnvironmentBlock.class.st | 107 +---------------- src/Microdown/MicNestedMarkupBlock.class.st | 111 ++++++++++++++++++ src/Microdown/MicRawParagraphBlock.class.st | 33 +++--- src/Microdown/MicRawParagraphBlock2.class.st | 44 +++++++ 9 files changed, 204 insertions(+), 137 deletions(-) create mode 100644 src/Microdown/MicNestedMarkupBlock.class.st create mode 100644 src/Microdown/MicRawParagraphBlock2.class.st diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index 8ca855134..e45a51ec9 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -217,11 +217,14 @@ MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ | result source | self assert: writer contents equals: String empty. - source := '
', newLine , 'some text -and -more', newLine, '
'. + source := '
', newLine , 'some text', newLine, newLine, +'and', newLine, newLine, '
'. + result := writer convertMicString: source. - self assert: result trimBoth equals: source. + self + assert: result trimBoth + equals: '
', newLine , '

some text

', newLine, newLine, +'

and

', newLine, '
'. ] diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index 7abf7bdb0..cf13df352 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -480,10 +480,8 @@ MicHTMLVisitor >> visitRawParagraph: aParagraph [ canvas newLine; raw: '<' , aParagraph label , '>'. - (aParagraph body - ifNil: [ canvas raw: '' ] - ifNotNil: [ canvas newLine. - canvas raw: aParagraph body ]). + (aParagraph children do: [ :each | each accept: self ] + separatedBy: [ canvas newLine ]). canvas newLine; raw: aParagraph lineStopMarkup diff --git a/src/Microdown-Pillar/MicMicrodownObjectToPillarObjectConverter.class.st b/src/Microdown-Pillar/MicMicrodownObjectToPillarObjectConverter.class.st index 4e40de003..0b669cced 100644 --- a/src/Microdown-Pillar/MicMicrodownObjectToPillarObjectConverter.class.st +++ b/src/Microdown-Pillar/MicMicrodownObjectToPillarObjectConverter.class.st @@ -46,7 +46,10 @@ MicMicrodownObjectToPillarObjectConverter >> visitAnchor: aMicAnchorBlock [ { #category : 'visiting inline' } MicMicrodownObjectToPillarObjectConverter >> visitAnchorReference: aMicAnchorReference [ - ^ PRInternalLink new anchor: aMicAnchorReference substring; yourself + + ^ PRInternalLink new + anchor: aMicAnchorReference bodyString; + yourself ] { #category : 'visiting' } @@ -234,8 +237,10 @@ MicMicrodownObjectToPillarObjectConverter >> visitQuote: aMicQuoteBlock [ { #category : 'visiting inline' } MicMicrodownObjectToPillarObjectConverter >> visitRaw: aMicRaw [ - ^ PRRaw new text: aMicRaw substring ; yourself - + + ^ PRRaw new + text: aMicRaw bodyString; + yourself ] { #category : 'visiting' } diff --git a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st index 6c96af983..7997dc21e 100644 --- a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st @@ -51,7 +51,7 @@ And after we get a paragraph') children. ] { #category : 'tests' } -MicRawParagraphBlockTest >> testRawParagraphCannotBeNested [ +MicRawParagraphBlockTest >> testRawParagraphCanBeNested [ | children | children := (parser parse: ' No idea what it is :) @@ -63,7 +63,10 @@ hkhkjhkj self assert: children size equals: 1. self assert: children first class equals: MicRawParagraphBlock. self assert: children first label equals: 'title'. - self assertEmpty: children first children + self assert: children first children size equals: 2. + self assert: children first children first class equals: MicParagraphBlock. + self assert: children first children second label equals: 'button'. + self assert: children first children second class equals: MicRawParagraphBlock. ] { #category : 'tests' } diff --git a/src/Microdown/MicAbstractCodeBlock.class.st b/src/Microdown/MicAbstractCodeBlock.class.st index 4313c8a6c..29ee48d9b 100644 --- a/src/Microdown/MicAbstractCodeBlock.class.st +++ b/src/Microdown/MicAbstractCodeBlock.class.st @@ -11,8 +11,19 @@ Class { { #category : 'public' } MicAbstractCodeBlock class >> alternateBlockClassFor: line [ + "This method is an extension point to be able to declare environment subclasses just specifying a tag. + + For example + + <?Foo|title=Stef?> + and a subclass of MicEnvironment with the tag 'Foo' exists then the parser will automatically + create instances of such subclass. + + " + "If there is one subclass with the corresponding tag, returns it, else resturn the current class." + "line is of the form ```tag|title=Schedule - we should use MicArgumentList for parsing, but alas, we do not at the moment" | tag | diff --git a/src/Microdown/MicEnvironmentBlock.class.st b/src/Microdown/MicEnvironmentBlock.class.st index c75b4ea57..0a595ad1b 100644 --- a/src/Microdown/MicEnvironmentBlock.class.st +++ b/src/Microdown/MicEnvironmentBlock.class.st @@ -44,10 +44,7 @@ This is important for better column support in the future: " Class { #name : 'MicEnvironmentBlock', - #superclass : 'MicStartStopMarkupBlock', - #instVars : [ - 'arguments' - ], + #superclass : 'MicNestedMarkupBlock', #category : 'Microdown-Model', #package : 'Microdown', #tag : 'Model' @@ -95,82 +92,12 @@ MicEnvironmentBlock >> accept: aVisitor [ ^ aVisitor visitEnvironment: self ] -{ #category : 'handle' } -MicEnvironmentBlock >> addLineAndReturnNextNode: line [ - "add line to this node. - Notice, the action is allowed to create new nodes in the block tree. - Returns the node to handle next line - typically self." - - - | withoutPreTabs | - isClosed - ifTrue: [ ^ self ]. - withoutPreTabs := line withoutPreTabs. - "Here the withoutPreTabs is probably not necessary because handlingPrefixTabOfLine: should do its job." - (self doesLineStartWithStopMarkup: withoutPreTabs) - ifTrue: [ ^ self ]. - firstLine - ifNil: - [ firstLine := self extractFirstLineFrom: withoutPreTabs ] - ifNotNil: [ ^ self bodyFromLine: withoutPreTabs ]. - ^ self -] - -{ #category : 'accessing' } -MicEnvironmentBlock >> arguments [ - - ^ arguments -] - -{ #category : 'accessing' } -MicEnvironmentBlock >> body [ - - ^ String streamContents: [:s | self bodyElements do: [ :each | s nextPutAll: each substring ] ] -] - -{ #category : 'accessing' } -MicEnvironmentBlock >> bodyElements [ - - ^ children -] - -{ #category : 'accessing' } -MicEnvironmentBlock >> bodyFromLine: line [ - - | newBlock | - newBlock := (self newBlockFor: line parent: self). - self parser setCurrent: newBlock. - ^ newBlock -] - -{ #category : 'parse support' } -MicEnvironmentBlock >> closeMe [ - - "this is a temporary solution because normally the parser should populate body with MicBlocks. - Right now just make sure that we have structured text = inline elements. " - "body ifNotNil: [ - body := self inlineParse: body ]. - children := body" - - "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser - For example the # Header to Slide is a typically case. " - - arguments := MicArgumentList - split: firstLine - defaultArg: #environmentName - defaultValue: ''. -] - -{ #category : 'accessing' } -MicEnvironmentBlock >> environmentName [ - ^ arguments at: #environmentName -] - { #category : 'accessing' } MicEnvironmentBlock >> extractFirstLineFrom: aLine [ "we got <! env ...x !> foo bar or <! env ...x and we return env ...x " | extract | + firstLine := super extractFirstLineFrom: aLine. firstLine := firstLine trimBoth. extract := firstLine copyUpToSubstring: EnvironmentClosingBlockMarkup. @@ -181,33 +108,3 @@ MicEnvironmentBlock >> extractFirstLineFrom: aLine [ extract trimRight ] ifFalse: [ firstLine ] ] - -{ #category : 'parse support' } -MicEnvironmentBlock >> initialize [ - - super initialize. - - "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser - For example the # Header to Slide is a typically case. Therefore the following initialization is needed even if - on parse time the arguments will get reset with another one." - - arguments := MicArgumentList new -] - -{ #category : 'markups' } -MicEnvironmentBlock >> lineStartMarkup [ - - ^ EnvironmentOpeningBlockMarkup -] - -{ #category : 'markups' } -MicEnvironmentBlock >> lineStopMarkup [ - - ^ EnvironmentClosingBlockMarkup -] - -{ #category : 'handle' } -MicEnvironmentBlock >> massageLine: aLine [ - - ^ aLine withoutPreTabs -] diff --git a/src/Microdown/MicNestedMarkupBlock.class.st b/src/Microdown/MicNestedMarkupBlock.class.st new file mode 100644 index 000000000..c875e8fda --- /dev/null +++ b/src/Microdown/MicNestedMarkupBlock.class.st @@ -0,0 +1,111 @@ +Class { + #name : 'MicNestedMarkupBlock', + #superclass : 'MicStartStopMarkupBlock', + #instVars : [ + 'arguments' + ], + #category : 'Microdown-Model', + #package : 'Microdown', + #tag : 'Model' +} + +{ #category : 'handle' } +MicNestedMarkupBlock >> addLineAndReturnNextNode: line [ + "add line to this node. + Notice, the action is allowed to create new nodes in the block tree. + Returns the node to handle next line - typically self." + + + | withoutPreTabs | + isClosed + ifTrue: [ ^ self ]. + withoutPreTabs := line withoutPreTabs. + "Here the withoutPreTabs is probably not necessary because handlingPrefixTabOfLine: should do its job." + firstLine + ifNil: + [ firstLine := self extractFirstLineFrom: withoutPreTabs. + ^ self ]. + (self doesLineStartWithStopMarkup: withoutPreTabs) + ifTrue: [ ^ self ]. + ^ self bodyFromLine: withoutPreTabs +] + +{ #category : 'accessing' } +MicNestedMarkupBlock >> arguments [ + + ^ arguments +] + +{ #category : 'accessing' } +MicNestedMarkupBlock >> body [ + + ^ String streamContents: [:s | self bodyElements do: [ :each | s nextPutAll: each substring ] ] +] + +{ #category : 'accessing' } +MicNestedMarkupBlock >> bodyElements [ + + ^ children +] + +{ #category : 'accessing' } +MicNestedMarkupBlock >> bodyFromLine: line [ + + | newBlock | + newBlock := (self newBlockFor: line parent: self). + self parser setCurrent: newBlock. + ^ newBlock +] + +{ #category : 'parse support' } +MicNestedMarkupBlock >> closeMe [ + + "this is a temporary solution because normally the parser should populate body with MicBlocks. + Right now just make sure that we have structured text = inline elements. " + "body ifNotNil: [ + body := self inlineParse: body ]. + children := body" + + "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser + For example the # Header to Slide is a typically case. " + + arguments := MicArgumentList + split: firstLine + defaultArg: #environmentName + defaultValue: ''. +] + +{ #category : 'accessing' } +MicNestedMarkupBlock >> environmentName [ + ^ arguments at: #environmentName +] + +{ #category : 'parse support' } +MicNestedMarkupBlock >> initialize [ + + super initialize. + + "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser + For example the # Header to Slide is a typically case. Therefore the following initialization is needed even if + on parse time the arguments will get reset with another one." + + arguments := MicArgumentList new +] + +{ #category : 'markups' } +MicNestedMarkupBlock >> lineStartMarkup [ + + ^ EnvironmentOpeningBlockMarkup +] + +{ #category : 'markups' } +MicNestedMarkupBlock >> lineStopMarkup [ + + ^ EnvironmentClosingBlockMarkup +] + +{ #category : 'handle' } +MicNestedMarkupBlock >> massageLine: aLine [ + + ^ aLine withoutPreTabs +] diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index 5a1a29dc8..ce3348091 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -1,9 +1,6 @@ Class { #name : 'MicRawParagraphBlock', - #superclass : 'MicStartStopMarkupBlock', - #instVars : [ - 'label' - ], + #superclass : 'MicNestedMarkupBlock', #category : 'Microdown-Extensions', #package : 'Microdown', #tag : 'Extensions' @@ -16,29 +13,27 @@ MicRawParagraphBlock >> accept: aVisitor [ ] { #category : 'handle' } -MicRawParagraphBlock >> bodyFromLine: line [ - - (self doesLineStartWithStopMarkup: line) - ifTrue: [ isClosed := true ] - ifFalse: [ body := body ifNil: [ line ] ifNotNil: [ - body , String cr , line ] ] -] - -{ #category : 'handle' } -MicRawParagraphBlock >> extractFirstLineFrom: line [ - "we cannot know in advance the markup so we have to guess and store it for closing." - - label := line allButFirst copyUpToSubstring: '>' +MicRawParagraphBlock >> extractFirstLineFrom: aLine [ + "we got < tag ...x > foo bar or < tag ...x and we return tag ...x " + | extract | + firstLine := aLine copyFrom: self lineStartMarkup size to: aLine size. + firstLine := firstLine trimBoth. + extract := firstLine copyUpToSubstring: '>'. + "we can just trimboth and avoid this test" + ^ extract size < firstLine size + ifTrue: [ + extract trimRight ] + ifFalse: [ firstLine ] ] { #category : 'accessing' } MicRawParagraphBlock >> label [ - ^ label + ^ firstLine ] { #category : 'markups' } MicRawParagraphBlock >> lineStopMarkup [ - ^ '</', label, '>' + ^ '</', self label, '>' ] diff --git a/src/Microdown/MicRawParagraphBlock2.class.st b/src/Microdown/MicRawParagraphBlock2.class.st new file mode 100644 index 000000000..53e2ba530 --- /dev/null +++ b/src/Microdown/MicRawParagraphBlock2.class.st @@ -0,0 +1,44 @@ +Class { + #name : 'MicRawParagraphBlock2', + #superclass : 'MicStartStopMarkupBlock', + #instVars : [ + 'label' + ], + #category : 'Microdown-Extensions', + #package : 'Microdown', + #tag : 'Extensions' +} + +{ #category : 'visiting' } +MicRawParagraphBlock2 >> accept: aVisitor [ + + aVisitor visitRawParagraph: self +] + +{ #category : 'handle' } +MicRawParagraphBlock2 >> bodyFromLine: line [ + + (self doesLineStartWithStopMarkup: line) + ifTrue: [ isClosed := true ] + ifFalse: [ body := body ifNil: [ line ] ifNotNil: [ + body , String cr , line ] ] +] + +{ #category : 'handle' } +MicRawParagraphBlock2 >> extractFirstLineFrom: line [ + "we cannot know in advance the markup so we have to guess and store it for closing." + + label := line allButFirst copyUpToSubstring: '>' + +] + +{ #category : 'accessing' } +MicRawParagraphBlock2 >> label [ + ^ label +] + +{ #category : 'markups' } +MicRawParagraphBlock2 >> lineStopMarkup [ + + ^ '</', label, '>' +] From 6d16af4e30124e1046c3eedb7194c33d9fc72da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= <stephane.ducasse@inria.fr> Date: Mon, 24 Mar 2025 21:55:12 +0100 Subject: [PATCH 14/67] Adding two more tests showing bugs but skipped for now. --- .../MicHTMLVisitorTest.class.st | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index e45a51ec9..8e16c10b9 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -198,6 +198,51 @@ MicHTMLVisitorTest >> testCreateItalic [ ] +{ #category : 'tests' } +MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ + + | result source | + self skip. + self assert: writer contents equals: String empty. + source := +'<div style="background-color:#8ebf42">', newLine, +'Tintin', newLine, newLine, '</div>'. + + result := writer convertMicString: source. + self + assert: result trimBoth + equals: '<div style="background-color:#8ebf42">', newLine , '<p>Tintin</p>', newLine, newLine, + '</div>'. + +] + +{ #category : 'tests' } +MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ + + | result source | + self skip. + self assert: writer contents equals: String empty. + source := +'<div style="background-color:#8ebf42"> +<p>We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this +<span style="color:#1c87c9"> +word +</span> +we place it within <span> tag.</p> +<p> +Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it. +</p> +</div>'. + + + result := writer convertMicString: source. + self + assert: result trimBoth + equals: '<div>', newLine , '<p>some text</p>', newLine, newLine, +'<p>and</p>', newLine, '</div>'. + +] + { #category : 'tests' } MicHTMLVisitorTest >> testRawParagraphIframe [ From 2a36b5abb30577460a07e0a9c944810ac9d9b895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= <stephane.ducasse@inria.fr> Date: Tue, 25 Mar 2025 14:34:17 +0100 Subject: [PATCH 15/67] now going over arguments --- .../MicHTMLVisitor.class.st | 3 +- src/Microdown/MicNestedMarkupBlock.class.st | 2 +- src/Microdown/MicRawParagraphBlock.class.st | 39 +++++++++++++++---- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index cf13df352..fe5efda2c 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -476,12 +476,13 @@ MicHTMLVisitor >> visitQuote: aQuote [ { #category : 'visiting - html extensions' } MicHTMLVisitor >> visitRawParagraph: aParagraph [ - + canvas newLine; raw: '<' , aParagraph label , '>'. (aParagraph children do: [ :each | each accept: self ] separatedBy: [ canvas newLine ]). + self halt. canvas newLine; raw: aParagraph lineStopMarkup diff --git a/src/Microdown/MicNestedMarkupBlock.class.st b/src/Microdown/MicNestedMarkupBlock.class.st index c875e8fda..013253a90 100644 --- a/src/Microdown/MicNestedMarkupBlock.class.st +++ b/src/Microdown/MicNestedMarkupBlock.class.st @@ -68,7 +68,7 @@ MicNestedMarkupBlock >> closeMe [ "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser For example the # Header to Slide is a typically case. " - + arguments := MicArgumentList split: firstLine defaultArg: #environmentName diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index ce3348091..f295dc427 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -1,6 +1,9 @@ Class { #name : 'MicRawParagraphBlock', #superclass : 'MicNestedMarkupBlock', + #instVars : [ + 'label' + ], #category : 'Microdown-Extensions', #package : 'Microdown', #tag : 'Extensions' @@ -12,19 +15,41 @@ MicRawParagraphBlock >> accept: aVisitor [ aVisitor visitRawParagraph: self ] +{ #category : 'handle' } +MicRawParagraphBlock >> closeMe [ + + "this is a temporary solution because normally the parser should populate body with MicBlocks. + Right now just make sure that we have structured text = inline elements. " + "body ifNotNil: [ + body := self inlineParse: body ]. + children := body" + + "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser + For example the # Header to Slide is a typically case. " + | args | + args := (firstLine allButFirst: label size). + args last = $> ifTrue: [ args := args copyFrom: 1 to: args size - 1 ]. + arguments := MicArgumentList + split: args + defaultArg: #environmentName + defaultValue: ''. +] + { #category : 'handle' } MicRawParagraphBlock >> extractFirstLineFrom: aLine [ "we got < tag ...x > foo bar or < tag ...x and we return tag ...x " - | extract | firstLine := aLine copyFrom: self lineStartMarkup size to: aLine size. firstLine := firstLine trimBoth. - extract := firstLine copyUpToSubstring: '>'. - "we can just trimboth and avoid this test" - ^ extract size < firstLine size - ifTrue: [ - extract trimRight ] - ifFalse: [ firstLine ] + label := firstLine copyUpToSubstring: Character space asString. + "we could do here a split on first space and get the label and the optional args. + and treat here the arguments instead of doing it in the closeMe." + + label last = $> ifTrue: [ label := label allButLast ]. + self halt. + ^ firstLine + + ] { #category : 'accessing' } From 150d5d884eb9cc909e0641160edca6151d71b42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= <stephane.ducasse@inria.fr> Date: Tue, 25 Mar 2025 15:21:16 +0100 Subject: [PATCH 16/67] Making progress with matija --- .../MicHTMLVisitorTest.class.st | 28 +++++++++--- .../MicHTMLVisitor.class.st | 12 +++-- src/Microdown/MicEnvironmentBlock.class.st | 18 ++++++++ src/Microdown/MicNestedMarkupBlock.class.st | 18 -------- src/Microdown/MicRawParagraphBlock.class.st | 45 ++++++++----------- 5 files changed, 65 insertions(+), 56 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index 8e16c10b9..c7009a591 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -202,7 +202,6 @@ MicHTMLVisitorTest >> testCreateItalic [ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ | result source | - self skip. self assert: writer contents equals: String empty. source := '<div style="background-color:#8ebf42">', newLine, @@ -211,7 +210,7 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ result := writer convertMicString: source. self assert: result trimBoth - equals: '<div style="background-color:#8ebf42">', newLine , '<p>Tintin</p>', newLine, newLine, + equals: '<div style="background-color:#8ebf42">', newLine , '<p>Tintin</p>', newLine, '</div>'. ] @@ -238,8 +237,18 @@ Pay attention, that the <div> tag is a block-level element, so a line brea result := writer convertMicString: source. self assert: result trimBoth - equals: '<div>', newLine , '<p>some text</p>', newLine, newLine, -'<p>and</p>', newLine, '</div>'. + equals: '<div style="background-color:#8ebf42"> +<p>We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this +<span style="color:#1c87c9"> +<p> +word +</p> +</span> +we place it within <span> tag.</p> +<p> +Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it. +</p> +</div>' ] @@ -247,13 +256,18 @@ Pay attention, that the <div> tag is a block-level element, so a line brea MicHTMLVisitorTest >> testRawParagraphIframe [ | result | - self skip. self assert: writer contents equals: String empty. result := writer convertMicString: '<iframe src="https://calendar.google.com/calendar/embed?mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=021vq166ioejihr7nsat0pjqic%40group.calendar.google.com&color=%231B887A&ctz=Europe%2FParis" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no"> -</iframe>'. +</iframe> + +Tintin + +'. self assert: result trimBoth equals: '<iframe src="https://calendar.google.com/calendar/embed?mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=021vq166ioejihr7nsat0pjqic%40group.calendar.google.com&color=%231B887A&ctz=Europe%2FParis" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no"> -</iframe>' +</iframe> + +<p>Tintin</p>' ] diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index fe5efda2c..be226c090 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -476,16 +476,20 @@ MicHTMLVisitor >> visitQuote: aQuote [ { #category : 'visiting - html extensions' } MicHTMLVisitor >> visitRawParagraph: aParagraph [ - + canvas newLine; - raw: '<' , aParagraph label , '>'. + raw: '<' , aParagraph label. + aParagraph hasArguments + ifTrue: [ canvas space; raw: aParagraph argumentString ]. + canvas raw: '>' . + (aParagraph children do: [ :each | each accept: self ] separatedBy: [ canvas newLine ]). - self halt. canvas newLine; - raw: aParagraph lineStopMarkup + raw: aParagraph lineStopMarkup; + newLine ] { #category : 'visiting - inline elements' } diff --git a/src/Microdown/MicEnvironmentBlock.class.st b/src/Microdown/MicEnvironmentBlock.class.st index 0a595ad1b..ca94c8fe2 100644 --- a/src/Microdown/MicEnvironmentBlock.class.st +++ b/src/Microdown/MicEnvironmentBlock.class.st @@ -92,6 +92,24 @@ MicEnvironmentBlock >> accept: aVisitor [ ^ aVisitor visitEnvironment: self ] +{ #category : 'parse support' } +MicEnvironmentBlock >> closeMe [ + + "this is a temporary solution because normally the parser should populate body with MicBlocks. + Right now just make sure that we have structured text = inline elements. " + "body ifNotNil: [ + body := self inlineParse: body ]. + children := body" + + "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser + For example the # Header to Slide is a typically case. " + + arguments := MicArgumentList + split: firstLine + defaultArg: #environmentName + defaultValue: ''. +] + { #category : 'accessing' } MicEnvironmentBlock >> extractFirstLineFrom: aLine [ "we got <! env ...x !> foo bar or <! env ...x and we return env ...x " diff --git a/src/Microdown/MicNestedMarkupBlock.class.st b/src/Microdown/MicNestedMarkupBlock.class.st index 013253a90..0af751f7f 100644 --- a/src/Microdown/MicNestedMarkupBlock.class.st +++ b/src/Microdown/MicNestedMarkupBlock.class.st @@ -57,24 +57,6 @@ MicNestedMarkupBlock >> bodyFromLine: line [ ^ newBlock ] -{ #category : 'parse support' } -MicNestedMarkupBlock >> closeMe [ - - "this is a temporary solution because normally the parser should populate body with MicBlocks. - Right now just make sure that we have structured text = inline elements. " - "body ifNotNil: [ - body := self inlineParse: body ]. - children := body" - - "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser - For example the # Header to Slide is a typically case. " - - arguments := MicArgumentList - split: firstLine - defaultArg: #environmentName - defaultValue: ''. -] - { #category : 'accessing' } MicNestedMarkupBlock >> environmentName [ ^ arguments at: #environmentName diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index f295dc427..bee515c21 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -2,7 +2,8 @@ Class { #name : 'MicRawParagraphBlock', #superclass : 'MicNestedMarkupBlock', #instVars : [ - 'label' + 'label', + 'argumentsString' ], #category : 'Microdown-Extensions', #package : 'Microdown', @@ -15,50 +16,40 @@ MicRawParagraphBlock >> accept: aVisitor [ aVisitor visitRawParagraph: self ] -{ #category : 'handle' } -MicRawParagraphBlock >> closeMe [ - - "this is a temporary solution because normally the parser should populate body with MicBlocks. - Right now just make sure that we have structured text = inline elements. " - "body ifNotNil: [ - body := self inlineParse: body ]. - children := body" - - "Pay attention closeMe is invoked during parse time and some conversions are creating environment without going over the parser - For example the # Header to Slide is a typically case. " - | args | - args := (firstLine allButFirst: label size). - args last = $> ifTrue: [ args := args copyFrom: 1 to: args size - 1 ]. - arguments := MicArgumentList - split: args - defaultArg: #environmentName - defaultValue: ''. +{ #category : 'activation' } +MicRawParagraphBlock >> argumentString [ + ^ argumentsString ] { #category : 'handle' } MicRawParagraphBlock >> extractFirstLineFrom: aLine [ "we got < tag ...x > foo bar or < tag ...x and we return tag ...x " + | splits | firstLine := aLine copyFrom: self lineStartMarkup size to: aLine size. firstLine := firstLine trimBoth. - label := firstLine copyUpToSubstring: Character space asString. - "we could do here a split on first space and get the label and the optional args. - and treat here the arguments instead of doing it in the closeMe." - - label last = $> ifTrue: [ label := label allButLast ]. - self halt. + firstLine := firstLine copyFrom: 1 to: firstLine size -1. + splits := firstLine splitOnFirst: Character space. + label := splits first. + splits size = 2 + ifTrue: [ argumentsString := splits second ]. ^ firstLine ] +{ #category : 'testing' } +MicRawParagraphBlock >> hasArguments [ + ^ argumentsString isNotEmpty +] + { #category : 'accessing' } MicRawParagraphBlock >> label [ - ^ firstLine + ^ label ] { #category : 'markups' } MicRawParagraphBlock >> lineStopMarkup [ - ^ '</', self label, '>' + ^ '</', label, '>' ] From a38489279c573445b9cff75e23dab70ebf2c46e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= <stephane.ducasse@inria.fr> Date: Tue, 25 Mar 2025 16:45:07 +0100 Subject: [PATCH 17/67] Still one test not working --- .../MicHTMLVisitorTest.class.st | 60 +++++++++---------- .../MicRawParagraphBlockTest.class.st | 38 +++++++++++- src/Microdown/MicParagraphBlock.class.st | 3 +- src/Microdown/MicRawParagraphBlock.class.st | 16 +++++ src/Microdown/MicSharedPool.class.st | 13 +++- src/Microdown/MicrodownParser.class.st | 10 +++- 6 files changed, 102 insertions(+), 38 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index c7009a591..c6d089436 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -219,37 +219,36 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ | result source | - self skip. + self assert: writer contents equals: String empty. source := -'<div style="background-color:#8ebf42"> -<p>We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this -<span style="color:#1c87c9"> -word -</span> -we place it within <span> tag.</p> -<p> -Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it. -</p> -</div>'. +'<div style="background-color:#8ebf42">', newLine, +'<p>We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'<span style="color:#1c87c9">', newLine, +'word', newLine, +'</span>', newLine, +'we place it within <span> tag.', +'</p>', newLine, +'<p>', newLine, +'Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.', newLine, +'</p>', newLine, +'</div>'. result := writer convertMicString: source. self assert: result trimBoth - equals: '<div style="background-color:#8ebf42"> -<p>We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this -<span style="color:#1c87c9"> -<p> -word -</p> -</span> -we place it within <span> tag.</p> -<p> -Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it. -</p> -</div>' - + equals: '<div style="background-color:#8ebf42">', newLine, +'<p>We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'<span style="color:#1c87c9">', newLine, +'word', newLine, +'</span>', newLine, +'we place it within <span> tag.', +'</p>', newLine, +'<p>', newLine, +'Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.', newLine, +'</p>', newLine, +'</div>'. ] { #category : 'tests' } @@ -258,16 +257,11 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ | result | self assert: writer contents equals: String empty. - result := writer convertMicString: '<iframe src="https://calendar.google.com/calendar/embed?mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=021vq166ioejihr7nsat0pjqic%40group.calendar.google.com&color=%231B887A&ctz=Europe%2FParis" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no"> -</iframe> - -Tintin - -'. - self assert: result trimBoth equals: '<iframe src="https://calendar.google.com/calendar/embed?mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=021vq166ioejihr7nsat0pjqic%40group.calendar.google.com&color=%231B887A&ctz=Europe%2FParis" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no"> -</iframe> + result := writer convertMicString: '<iframe src="https://calendar.google.com/calendar/embed?mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=021vq166ioejihr7nsat0pjqic%40group.calendar.google.com&color=%231B887A&ctz=Europe%2FParis" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no">', newLine, +'</iframe>', newLine, 'Tintin'. -<p>Tintin</p>' + self assert: result trimBoth equals: '<iframe src="https://calendar.google.com/calendar/embed?mode=WEEK&height=600&wkst=1&bgcolor=%23FFFFFF&src=021vq166ioejihr7nsat0pjqic%40group.calendar.google.com&color=%231B887A&ctz=Europe%2FParis" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no">', newLine, +'</iframe>', newLine, newLine, '<p>Tintin</p>' ] diff --git a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st index 7997dc21e..1d4ec8634 100644 --- a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st @@ -69,6 +69,42 @@ hkhkjhkj self assert: children first children second class equals: MicRawParagraphBlock. ] +{ #category : 'tests' } +MicRawParagraphBlockTest >> testRawParagraphForP [ + | children | + children := (parser parse: '<p> +No idea what it is :) +</p>') children. + self assert: children size equals: 1. + self assert: children first class equals: MicRawParagraphBlock. + self assert: children first label equals: 'p'. + +] + +{ #category : 'tests' } +MicRawParagraphBlockTest >> testRawParagraphForPNoSpace [ + | children | + children := (parser parse: '<p>WeDoNotLikeSpace +No idea what it is :) +</p>') children. + self assert: children size equals: 1. + self assert: children first class equals: MicRawParagraphBlock. + self assert: children first label equals: 'p'. + +] + +{ #category : 'tests' } +MicRawParagraphBlockTest >> testRawParagraphForPNoSpaceAndAttributes [ + | children | + children := (parser parse: '<p src=78>WeDoNotLikeSpace +No idea what it is :) +</p>') children. + self assert: children size equals: 1. + self assert: children first class equals: MicRawParagraphBlock. + self assert: children first label equals: 'p'. + +] + { #category : 'tests' } MicRawParagraphBlockTest >> testThereIsNoValidationIfThetagStartWithAKnowHtml [ "for the moment we only check the first couple of characters to start with. @@ -77,6 +113,6 @@ MicRawParagraphBlockTest >> testThereIsNoValidationIfThetagStartWithAKnowHtml [ mic := (parser parse: '<titleunkniw> No idea what it is :) </titleunkniw>') children first. - self assert: mic class equals: MicRawParagraphBlock. + self assert: mic class equals: MicParagraphBlock. ] diff --git a/src/Microdown/MicParagraphBlock.class.st b/src/Microdown/MicParagraphBlock.class.st index 3dea057fa..a4ef8a62a 100644 --- a/src/Microdown/MicParagraphBlock.class.st +++ b/src/Microdown/MicParagraphBlock.class.st @@ -54,7 +54,8 @@ MicParagraphBlock >> canConsumeLine: line [ | unIndented | "if we are closing block that can contain other elements then do not consume their ends." - (line isEmpty or: [ line beginsWith: EnvironmentClosingBlockMarkup]) + + (line isEmpty or: [ (line beginsWith: EnvironmentClosingBlockMarkup) or: [ EndHTMLTags includes: line ]]) ifTrue: [ ^ false ]. (self isRightlyIndented: line) ifFalse: [ ^ false ]. diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index bee515c21..71da97fa8 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -10,6 +10,13 @@ Class { #tag : 'Extensions' } +{ #category : 'public' } +MicRawParagraphBlock class >> alternateBlockClassFor: aLine [ + "We do not want to have extention for MicRawParaphTag" + + ^ self +] + { #category : 'visiting' } MicRawParagraphBlock >> accept: aVisitor [ @@ -53,3 +60,12 @@ MicRawParagraphBlock >> lineStopMarkup [ ^ '</', label, '>' ] + +{ #category : 'printing' } +MicRawParagraphBlock >> printOn: aStream [ + + super printOn: aStream. + aStream << '(' ; + << label ; + << ')' +] diff --git a/src/Microdown/MicSharedPool.class.st b/src/Microdown/MicSharedPool.class.st index e0bc971e2..f6e2bf12a 100644 --- a/src/Microdown/MicSharedPool.class.st +++ b/src/Microdown/MicSharedPool.class.st @@ -21,6 +21,7 @@ Class { 'CodeblockMarkup', 'CommentedLineMarkup', 'Delimiters', + 'EndHTMLTags', 'EnvironmentClosingBlockMarkup', 'EnvironmentOpeningBlockMarkup', 'FigureNameOpenerMarkup', @@ -57,11 +58,18 @@ Class { #tag : 'Parser' } +{ #category : 'class initialization' } +MicSharedPool class >> endHtmlTags [ + "Pay attention that br is not in this list!" + + ^ #('</a>' '</abbr>' '</address>' '</area>' '</article>' '</aside>' '</audio>' '</b>' '</base>' '</bdi>' '</bdo>' '</blockquote>' '</body>' '</button>' '</canvas>' '</caption>' '</cite>' '</code>' '</col>' '</colgroup>' '</data>' '</datalist>' '</dd>' '</del>' '</details>' '</dfn>' '</dialog>' '</div>' '</dl>' '</dt>' '</em>' '</embed>' '</fieldset>' '</figcaption>' '</figure>' '</footer>' '</form>' '</h1>' '</h2>' '</h3>' '</h4>' '</h5>' '</h6>' '</head>' '</header>' '</hgroup>' '</hr>' '</html>' '</i>' '</iframe>' '</img>' '</input>' '</ins>' '</kbd>' '</label>' '</legend>' '</li>' '</link>' '</main>' '</map>' '</mark>' '</menu>' '</meta>' '</meter>' '</nav>' '</noscript>' '</object>' '</ol>' '</optgroup>' '</option>' '</output>' '</p>' '</param>' '</picture>' '</pre>' '</progress>' '</q>' '</rb>' '</rp>' '</rt>' '</rtc>' '</ruby>' '</s>' '</samp>' '</script>' '</section>' '</select>' '</slot>' '</small>' '</source>' '</span>' '</strong>' '</style>' '</sub>' '</summary>' '</sup>' '</table>' '</tbody>' '</td>' '</template>' '</textarea>' '</tfoot>' '</th>' '</thead>' '</time>' '' '' '' '' '' '' '' '') +] + { #category : 'class initialization' } MicSharedPool class >> htmlTags [ "Pay attention that br is not in this list!" - ^ #('!--' 'a' 'abbr' 'address' 'area' 'article' 'aside' 'audio' 'b' 'base' 'bdi' 'bdo' 'blockquote' 'body' 'button' 'canvas' 'caption' 'cite' 'code' 'col' 'colgroup' 'data' 'datalist' 'dd' 'del' 'details' 'dfn' 'dialog' 'div' 'dl' 'dt' 'em' 'embed' 'fieldset' 'figcaption' 'figure' 'footer' 'form' 'h1' 'h2' 'h3' 'h4' 'h5' 'h6' 'head' 'header' 'hgroup' 'hr' 'html' 'i' 'iframe' 'img' 'input' 'ins' 'kbd' 'label' 'legend' 'li' 'link' 'main' 'map' 'mark' 'menu' 'meta' 'meter' 'nav' 'noscript' 'object' 'ol' 'optgroup' 'option' 'output' 'p' 'param' 'picture' 'pre' 'progress' 'q' 'rb' 'rp' 'rt' 'rtc' 'ruby' 's' 'samp' 'script' 'section' 'select' 'slot' 'small' 'source' 'span' 'strong' 'style' 'sub' 'summary' 'sup' 'table' 'tbody' 'td' 'template' 'textarea' 'tfoot' 'th' 'thead' 'time' 'title' 'tr' 'track' 'u' 'ul' 'var' 'video' 'wbr') + ^ #('!--' 'a' 'abbr' 'address' 'area' 'article' 'aside' 'audio' 'b' 'base' 'bdi' 'bdo' 'blockquote' 'body' 'button' 'canvas' 'caption' 'cite' 'code' 'col' 'colgroup' 'data' 'datalist' 'dd' 'del' 'details' 'dfn' 'dialog' 'div' 'dl' 'dt' 'em' 'embed' 'fieldset' 'figcaption' 'figure' 'footer' 'form' 'h1' 'h2' 'h3' 'h4' 'h5' 'h6' 'head' 'header' 'hgroup' 'hr' 'html' 'i' 'iframe' 'img' 'input' 'ins' 'kbd' 'label' 'legend' 'li' 'link' 'main' 'map' 'mark' 'menu' 'meta' 'meter' 'nav' 'noscript' 'object' 'ol' 'optgroup' 'option' 'output' 'p' 'param' 'picture' 'pre' 'progress' 'q' 'rb' 'rp' 'rt' 'rtc' 'ruby' 's' 'samp' 'script' 'section' 'select' 'slot' 'small' 'source' 'span' 'strong' 'style' 'sub' 'summary' 'sup' 'table' 'tbody' 'td' 'template' 'textarea' 'tfoot' 'th' 'thead' 'time' 'title' 'tr' 'track' 'u' 'ul' 'var' 'video' 'wbr') , #('!-->' 'a>' 'abbr>' 'address>' 'area>' 'article>' 'aside>' 'audio>' 'b>' 'base>' 'bdi>' 'bdo>' 'blockquote>' 'body>' 'button>' 'canvas>' 'caption>' 'cite>' 'code>' 'col>' 'colgroup>' 'data>' 'datalist>' 'dd>' 'del>' 'details>' 'dfn>' 'dialog>' 'div>' 'dl>' 'dt>' 'em>' 'embed>' 'fieldset>' 'figcaption>' 'figure>' 'footer>' 'form>' 'h1>' 'h2>' 'h3>' 'h4>' 'h5>' 'h6>' 'head>' 'header>' 'hgroup>' 'hr>' 'html>' 'i>' 'iframe>' 'img>' 'input>' 'ins>' 'kbd>' 'label>' 'legend>' 'li>' 'link>' 'main>' 'map>' 'mark>' 'menu>' 'meta>' 'meter>' 'nav>' 'noscript>' 'object>' 'ol>' 'optgroup>' 'option>' 'output>' 'p>' 'param>' 'picture>' 'pre>' 'progress>' 'q>' 'rb>' 'rp>' 'rt>' 'rtc>' 'ruby>' 's>' 'samp>' 'script>' 'section>' 'select>' 'slot>' 'small>' 'source>' 'span>' 'strong>' 'style>' 'sub>' 'summary>' 'sup>' 'table>' 'tbody>' 'td>' 'template>' 'textarea>' 'tfoot>' 'th>' 'thead>' 'time>' 'title>' 'tr>' 'track>' 'u>' 'ul>' 'var>' 'video>' 'wbr>') ] { #category : 'class initialization' } @@ -177,7 +185,8 @@ MicSharedPool class >> initializeRawParagraph [ "self initializeRawParagraph" HTMLTags := self htmlTags. - ThreeLettersHTMLTags := self threeLetterhtmlTags + ThreeLettersHTMLTags := self threeLetterhtmlTags. + EndHTMLTags := self endHtmlTags. ] { #category : 'class initialization' } diff --git a/src/Microdown/MicrodownParser.class.st b/src/Microdown/MicrodownParser.class.st index 7c90d25a4..60e11c104 100644 --- a/src/Microdown/MicrodownParser.class.st +++ b/src/Microdown/MicrodownParser.class.st @@ -212,8 +212,16 @@ MicrodownParser >> blockStarterClassFrom: line [ but this is to try. Once we understand and probably change the environment syntax for now it is , i and i> + This is working p src=800 + " + + (line includes: Character space) + ifTrue: [ HTMLTags includes: ((line allButFirst splitOnFirst: Character space) first) ] + ifFalse: [ HTMLTags includes: ((line allButFirst splitOnFirst: $>) first) ] + ]) ifTrue: [ "we have a rawparagraph block" ^ MicRawParagraphBlock From 69581d1813ab4649818edcd7f31f1129918b027b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 26 Mar 2025 08:52:36 +0100 Subject: [PATCH 18/67] Fixing the problem is

We --- src/Microdown/MicRawParagraphBlock.class.st | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index 71da97fa8..65638ed63 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -36,13 +36,18 @@ MicRawParagraphBlock >> extractFirstLineFrom: aLine [ firstLine := aLine copyFrom: self lineStartMarkup size to: aLine size. firstLine := firstLine trimBoth. firstLine := firstLine copyFrom: 1 to: firstLine size -1. - splits := firstLine splitOnFirst: Character space. + + splits := firstLine splitOnFirst: $>. + splits second isNotEmpty + ifTrue: [ "here we p>Blo and we discard Blo" + label := splits first ]. + + "now we may have

> hasArguments [ ^ argumentsString isNotEmpty ] +{ #category : 'parse support' } +MicRawParagraphBlock >> initialize [ + + super initialize. + argumentsString := '' +] + { #category : 'accessing' } MicRawParagraphBlock >> label [ ^ label From 4d89a1718116890068d7e47817ab71ebe655d8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 26 Mar 2025 09:23:00 +0100 Subject: [PATCH 19/67] Adding a new test illustrating the problem: now p is ignored. --- .../MicRawParagraphBlockTest.class.st | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st index 1d4ec8634..90a6d804f 100644 --- a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st @@ -93,6 +93,30 @@ No idea what it is :) ] +{ #category : 'tests' } +MicRawParagraphBlockTest >> testRawParagraphForPNoSpace2 [ + | children newLine | + newLine := Character cr asString. + children := (MicrodownParser new parse: '

', newLine, +'

We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'', newLine, +'word', newLine, +'', newLine, +'we place it within <span> tag.', +'

', newLine, +'

', newLine, +'Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.', newLine, +'

', newLine, +'
') children. + self assert: children size equals: 1. + self assert: children first class equals: MicRawParagraphBlock. + self assert: children first label equals: 'div'. + self assert: children first children first class equals: MicRawParagraphBlock. + self assert: children first children first label equals: 'p'. + + +] + { #category : 'tests' } MicRawParagraphBlockTest >> testRawParagraphForPNoSpaceAndAttributes [ | children | From 923674772d75075c50c7b6e3d7b9306b1db19ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 26 Mar 2025 09:50:31 +0100 Subject: [PATCH 20/67] remov MicRawParagraphBlock2 --- .../MicRawParagraphBlockTest.class.st | 3 +- src/Microdown/MicRawParagraphBlock2.class.st | 44 ------------------- 2 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 src/Microdown/MicRawParagraphBlock2.class.st diff --git a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st index 90a6d804f..91175e346 100644 --- a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st @@ -98,7 +98,8 @@ MicRawParagraphBlockTest >> testRawParagraphForPNoSpace2 [ | children newLine | newLine := Character cr asString. children := (MicrodownParser new parse: '
', newLine, -'

We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'

', newLine, +'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, '', newLine, 'word', newLine, '', newLine, diff --git a/src/Microdown/MicRawParagraphBlock2.class.st b/src/Microdown/MicRawParagraphBlock2.class.st deleted file mode 100644 index 53e2ba530..000000000 --- a/src/Microdown/MicRawParagraphBlock2.class.st +++ /dev/null @@ -1,44 +0,0 @@ -Class { - #name : 'MicRawParagraphBlock2', - #superclass : 'MicStartStopMarkupBlock', - #instVars : [ - 'label' - ], - #category : 'Microdown-Extensions', - #package : 'Microdown', - #tag : 'Extensions' -} - -{ #category : 'visiting' } -MicRawParagraphBlock2 >> accept: aVisitor [ - - aVisitor visitRawParagraph: self -] - -{ #category : 'handle' } -MicRawParagraphBlock2 >> bodyFromLine: line [ - - (self doesLineStartWithStopMarkup: line) - ifTrue: [ isClosed := true ] - ifFalse: [ body := body ifNil: [ line ] ifNotNil: [ - body , String cr , line ] ] -] - -{ #category : 'handle' } -MicRawParagraphBlock2 >> extractFirstLineFrom: line [ - "we cannot know in advance the markup so we have to guess and store it for closing." - - label := line allButFirst copyUpToSubstring: '>' - -] - -{ #category : 'accessing' } -MicRawParagraphBlock2 >> label [ - ^ label -] - -{ #category : 'markups' } -MicRawParagraphBlock2 >> lineStopMarkup [ - - ^ '' -] From 1e5a0e7872b21c4de29969011c75ae691f317965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 26 Mar 2025 09:51:22 +0100 Subject: [PATCH 21/67] Change visitPargraph: not to emit

explicitly. This will only be for the MicRawParagraph. --- .../MicHTMLExporterTest.class.st | 36 +++++++++---------- .../MicHTMLVisitorTest.class.st | 30 +++++++++------- .../MicHTMLVisitor.class.st | 5 +-- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st index ad9cf2d42..05eac6c1c 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st @@ -62,7 +62,7 @@ MicHTMLExporterTest >> parser: aParser [ MicHTMLExporterTest >> testAccents [ self parse: 'éà' andCheckWeGet: newLine, -'

éà

' +'éà' ] { #category : 'utilities' } @@ -101,7 +101,7 @@ MicHTMLExporterTest >> testFigure [ self parse: factory figureSample andCheckWeGet: newLine , -'

Foo
Foo

' +'
Foo
Foo
' ] { #category : 'tests - formats' } @@ -110,7 +110,7 @@ MicHTMLExporterTest >> testFigureBold [ self parse: factory figureBoldSample andCheckWeGet: newLine , -'

Foo
Foo

' +'
Foo
Foo
' ] { #category : 'tests' } @@ -119,7 +119,7 @@ MicHTMLExporterTest >> testFigureItalic [ self parse: factory figureItalicSample andCheckWeGet: newLine , -'

Foo
Foo

' +'
Foo
Foo
' ] { #category : 'tests' } @@ -128,7 +128,7 @@ MicHTMLExporterTest >> testFigureNested [ self parse: factory figureNestedSample andCheckWeGet: newLine , -'

Foo_
Foo_

' +'
Foo_
Foo_
' ] { #category : 'tests' } @@ -137,7 +137,7 @@ MicHTMLExporterTest >> testFigureReal [ self parse: factory figureRealSample andCheckWeGet: newLine , -'

A logo png under figures folder
A logo png under figures folder

' +'
A logo png under figures folder
A logo png under figures folder
' ] { #category : 'tests' } @@ -146,7 +146,7 @@ MicHTMLExporterTest >> testFigureStrike [ self parse: factory figureStrikeSample andCheckWeGet: newLine , -'

Foo
Foo

' +'
Foo
Foo
' ] { #category : 'tests' } @@ -155,7 +155,7 @@ MicHTMLExporterTest >> testFigureWithLabelWithoutSize [ self parse: factory figureWithLabelWithoutSizeSample andCheckWeGet: newLine , -'

Foo
Foo

' +'
Foo
Foo
' ] { #category : 'tests' } @@ -164,7 +164,7 @@ MicHTMLExporterTest >> testFigureWithoutCaption [ self parse: factory figureWithoutCaptionSample andCheckWeGet: newLine , -'

' +'
' ] { #category : 'tests' } @@ -173,7 +173,7 @@ MicHTMLExporterTest >> testFigureWithoutSizeAndLabel [ self parse: factory figureSampleWithoutSizeAndLabel andCheckWeGet: newLine , -'

Foo
Foo

' +'
Foo
Foo
' ] { #category : 'tests' } @@ -182,7 +182,7 @@ MicHTMLExporterTest >> testGoutDeFraise [ self parse: factory figureGoutDeFraise andCheckWeGet: newLine , -'

Proposition pour le thème :  Un goût de fraise
Proposition pour le thème : Un goût de fraise

' +'
Proposition pour le thème :  Un goût de fraise
Proposition pour le thème : Un goût de fraise
' ] { #category : 'tests' } @@ -218,21 +218,21 @@ MicHTMLExporterTest >> testMetaDataIsNotIgnored [ { #category : 'tests - paragraph' } MicHTMLExporterTest >> testParagraph [ - self parse: factory paragraphSample andCheckWeGet: newLine ,'

Foo

' + self parse: factory paragraphSample andCheckWeGet: newLine ,'Foo' ] { #category : 'tests' } MicHTMLExporterTest >> testParagraphLongWithAccents [ self parse: factory paragraphOnMultipleLinesSample andCheckWeGet: newLine , -'

Je ne connais pas la peur, car la peur tue l''esprit. La peur est la petite mort qui conduit à l''oblitération totale. J''affonterai ma peur. Je lui permettrais de passer sur moi, au travers de moi. Et lorsqu''elle sera passée, je tournerai mon oeil interieur sur son chemin. Et là où elle sera passée, il n''y aura plus rien, rien que moi.

' +'Je ne connais pas la peur, car la peur tue l''esprit. La peur est la petite mort qui conduit à l''oblitération totale. J''affonterai ma peur. Je lui permettrais de passer sur moi, au travers de moi. Et lorsqu''elle sera passée, je tournerai mon oeil interieur sur son chemin. Et là où elle sera passée, il n''y aura plus rien, rien que moi.' ] { #category : 'tests - formats' } MicHTMLExporterTest >> testParagraphNestedSample [ self parse: factory paragraphNestedSample andCheckWeGet: newLine , -'

this is a paragraph

' +'this is a paragraph' ] { #category : 'tests - formats' } @@ -241,21 +241,21 @@ MicHTMLExporterTest >> testParagraphWithBold [ self parse: factory paragraphBoldSample andCheckWeGet: newLine , -'

this is a paragraph

' +'this is a paragraph' ] { #category : 'tests' } MicHTMLExporterTest >> testParagraphWithItalic [ self parse: factory paragraphItalicSample andCheckWeGet: newLine , -'

this is a paragraph

' +'this is a paragraph' ] { #category : 'tests - formats' } MicHTMLExporterTest >> testParagraphWithMonospace [ self parse: factory paragraphMonospaceSample andCheckWeGet: newLine , -'

this is a paragraph

' +'this is a paragraph' ] { #category : 'tests - formats' } @@ -269,7 +269,7 @@ MicHTMLExporterTest >> testQuote [ MicHTMLExporterTest >> testStrike [ self parse: factory strikethroughFormatSample andCheckWeGet: newLine , -'

Foo

' +'Foo' ] { #category : 'tests' } diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index c6d089436..b011050a1 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -98,7 +98,7 @@ MicHTMLVisitorTest >> testConvertMicFile [ self assert: (fileSystem / 'anExample1.html') asFileReference contents equals: newLine , '

Foo

' , newLine - , '

Pharo is cool

' , newLine + , 'Pharo is cool' , newLine , '
this is a code blu blu
' , newLine ] @@ -140,7 +140,7 @@ MicHTMLVisitorTest >> testCreateAnchorWithLink [ | result | self assert: writer contents equals: String empty. result := writer convertMicString: '[Pharo Website](http://pharo.org target=blank&rel=bookmark)'. - self assert: result trimBoth equals: '

Pharo Website

'. + self assert: result trimBoth equals: 'Pharo Website'. ] { #category : 'tests' } @@ -158,7 +158,7 @@ this is another string'. equals: '

This is a title

' , newLine , 'Body of annotated block' - , newLine , '

this is another string

' + , newLine , 'this is another string' ] { #category : 'tests' } @@ -183,7 +183,7 @@ MicHTMLVisitorTest >> testCreateCitation [ self assert: writer contents equals: String empty. result := writer convertMicString: '{!citation|ref=Duca99a!}'. - self assert: result trimBoth equals: '

Duca99a

'. + self assert: result trimBoth equals: 'Duca99a'. ] @@ -194,7 +194,7 @@ MicHTMLVisitorTest >> testCreateItalic [ self assert: writer contents equals: String empty. result := writer convertMicString: '_Text with italic_'. - self assert: result trimBoth equals: '

Text with italic

'. + self assert: result trimBoth equals: 'Text with italic'. ] @@ -210,7 +210,7 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ result := writer convertMicString: source. self assert: result trimBoth - equals: '
', newLine , '

Tintin

', newLine, + equals: '
', newLine , 'Tintin', newLine, '
'. ] @@ -219,11 +219,13 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ | result source | - + self flag: #tofix. + self assert: writer contents equals: String empty. source := '
', newLine, -'

We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'

', newLine, +'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, '', newLine, 'word', newLine, '', newLine, @@ -239,7 +241,8 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ self assert: result trimBoth equals: '

', newLine, -'

We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'

', +'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, '', newLine, 'word', newLine, '', newLine, @@ -261,7 +264,7 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ '', newLine, 'Tintin'. self assert: result trimBoth equals: '', newLine, newLine, '

Tintin

' +'', newLine, newLine, 'Tintin' ] @@ -269,15 +272,16 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ | result source | + self flag: #tofix. self assert: writer contents equals: String empty. - source := '
', newLine , 'some text', newLine, newLine, + source := '
', newLine , '

', newLine, 'some text', newLine, '<\p>', newLine, 'and', newLine, newLine, '

'. result := writer convertMicString: source. self assert: result trimBoth - equals: '
', newLine , '

some text

', newLine, newLine, -'

and

', newLine, '
'. + equals: '
', newLine , '

', newLine,'some text', newLine, '<\p>', newLine, newLine, +'and', newLine, '

'. ] diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index be226c090..e617dc925 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -456,9 +456,10 @@ MicHTMLVisitor >> visitOrderedListItem: anOrderedListItem [ MicHTMLVisitor >> visitParagraph: aParagraph [ canvas newLine. - canvas tag + super visitParagraph: aParagraph + "canvas tag name: 'p'; - with: [ super visitParagraph: aParagraph ] + with: [ ]" ] { #category : 'visiting' } From 5ca0c0648e763b7585c006cea280724b26af8274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Kljaji=C4=87?= <64456143+matijakljajic@users.noreply.github.com> Date: Fri, 28 Mar 2025 11:51:34 +0100 Subject: [PATCH 22/67] Fix visitRawParagraph so that all tests pass --- .../MicHTMLVisitorTest.class.st | 12 +++++------- src/Microdown-HTMLExporter/MicHTMLVisitor.class.st | 6 ++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index b011050a1..eaafd4bf6 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -219,12 +219,11 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ | result source | - self flag: #tofix. self assert: writer contents equals: String empty. source := '
', newLine, -'

', newLine, +'

', 'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, '', newLine, 'word', newLine, @@ -264,7 +263,7 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ '', newLine, 'Tintin'. self assert: result trimBoth equals: '', newLine, newLine, 'Tintin' +'', newLine, 'Tintin' ] @@ -272,15 +271,14 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ | result source | - self flag: #tofix. self assert: writer contents equals: String empty. - source := '

', newLine , '

', newLine, 'some text', newLine, '<\p>', newLine, -'and', newLine, newLine, '

'. + source := '
', newLine , '

', newLine, 'some text', newLine, '

', newLine, +'and', newLine, '
'. result := writer convertMicString: source. self assert: result trimBoth - equals: '
', newLine , '

', newLine,'some text', newLine, '<\p>', newLine, newLine, + equals: '

', newLine , '

', newLine,'some text', newLine, '

', newLine, 'and', newLine, '
'. ] diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index e617dc925..f40273b92 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -485,12 +485,10 @@ MicHTMLVisitor >> visitRawParagraph: aParagraph [ ifTrue: [ canvas space; raw: aParagraph argumentString ]. canvas raw: '>' . - (aParagraph children do: [ :each | each accept: self ] - separatedBy: [ canvas newLine ]). + aParagraph children do: [ :each | each accept: self ]. canvas newLine; - raw: aParagraph lineStopMarkup; - newLine + raw: aParagraph lineStopMarkup. ] { #category : 'visiting - inline elements' } From e3c3133465e45cfa4f8fe96d33fc4b4d827c230d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sun, 30 Mar 2025 21:22:11 +0200 Subject: [PATCH 23/67] Adding at: API to metadataelement. should deprecated the other one. --- src/Microdown/MicMetaDataBlock.class.st | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Microdown/MicMetaDataBlock.class.st b/src/Microdown/MicMetaDataBlock.class.st index db51c016c..24c7b17ed 100644 --- a/src/Microdown/MicMetaDataBlock.class.st +++ b/src/Microdown/MicMetaDataBlock.class.st @@ -37,6 +37,26 @@ MicMetaDataBlock >> accept: aVisitor [ ^ aVisitor visitMetaData: self ] +{ #category : 'accessing' } +MicMetaDataBlock >> at: aString [ + ^ self body at: aString +] + +{ #category : 'accessing' } +MicMetaDataBlock >> at: aString ifAbsent: aBlock [ + ^ self body at: aString ifAbsent: aBlock +] + +{ #category : 'accessing' } +MicMetaDataBlock >> at: aString ifPresent: aPresentBlock ifAbsent: aBlock [ + ^ self body at: aString ifPresent: aPresentBlock ifAbsent: aBlock +] + +{ #category : 'accessing' } +MicMetaDataBlock >> at: aString put: aString2 [ + self body at: aString put: aString2 +] + { #category : 'accessing' } MicMetaDataBlock >> atKey: aString [ ^ self body at: aString From 820ed45f39d302512a8be13c851c1743753ba66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 2 May 2025 18:18:52 +0300 Subject: [PATCH 24/67] Adding a simple div class= xxx test --- .../MicRawParagraphBlockTest.class.st | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st index 91175e346..fa93526d5 100644 --- a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st @@ -11,6 +11,22 @@ MicRawParagraphBlockTest >> subjectClass [ ^ MicRawParagraphBlock ] +{ #category : 'tests' } +MicRawParagraphBlockTest >> testASimpleDivWithClass [ + | mic | + mic := (parser parse: '
+ +# Contributing to Pharo + +In a giving mood? There are many ways to get involved! + +
+') children first. + self assert: mic class equals: MicRawParagraphBlock. + self assert: mic label equals: 'div'. + +] + { #category : 'tests' } MicRawParagraphBlockTest >> testASimpleRawParagraph [ | mic | From 0a621eb88c77291206755fb03d1120702cccdd48 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Tue, 6 May 2025 09:57:56 +0200 Subject: [PATCH 25/67] Not accessing the class SystemBuildInfo directly --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index 3657a7cca..414aa1d4a 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -162,8 +162,11 @@ BaselineOfMicrodown >> preload: loader package: packageSpec [ forget ] ]" | packagesToUnload | - "If we are building the Pharo image, we do not want to unload packages." - SystemBuildInfo current isBuildFinished ifFalse: [ ^ self ]. + + self flag: 'This is necessary to not break the bootstrapping. Microdown makes a cleaning of classes and as Microdown is loaded in the image it can cause conflits.'. + self flag: 'We do not access the class SystemBuildInfo directly because it is only present in Pharo 13 but Microdown works on different Pharo versions. We can simplifly this when Pharo 13 will be the minimal supported version.'. + self class environment at: #SystemBuildInfo ifPresent: [ :info | info + current isBuildFinished ifFalse: [ ^ self ]. ]. "If it is absent it's because we are in the Pharo bootstrap" self class environment at: #IceRepository ifPresent: [ :iceRepositoryClass | From f13dfd1b97890fedb2b9aa0d71dfbfc4a2f1fb5e Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Tue, 6 May 2025 10:21:55 +0200 Subject: [PATCH 26/67] Not using PackageOrganizer directly --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index 414aa1d4a..84a814f73 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -170,11 +170,13 @@ BaselineOfMicrodown >> preload: loader package: packageSpec [ "If it is absent it's because we are in the Pharo bootstrap" self class environment at: #IceRepository ifPresent: [ :iceRepositoryClass | - packagesToUnload := ((PackageOrganizer default packages select: [ :each | each name beginsWith: 'Microdown' ]) collect: [ :each | each name ]) reject: [ :each | - #( 'Microdown-RichTextPresenter' 'Microdown-RichTextPresenter-Tests' ) includes: each ]. + | packages | + "The same here, not direct access to PackageOrganizer because it is only for Pharo 13." + packages := self class environment allClasses collect: #package as: Set. + packagesToUnload := ((packages select: [ :each | each name beginsWith: 'Microdown' ]) collect: [ :each | each name ]) reject: [ :each | + #( 'Microdown-RichTextPresenter' 'Microdown-RichTextPresenter-Tests' ) includes: each ]. - "these two are not managed by the microdown repo but the documentation. - I should rename them in the future to avoid confusion" + "these two are not managed by the microdown repo but the documentation. We should rename them in the future to avoid confusion" packagesToUnload do: [ :each | ((iceRepositoryClass repositoryNamed: 'Microdown') packageNamed: each) unload ] ] ] From 94694e11b2f796739e0d2c4cfe469e5ad238667f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 9 May 2025 18:14:40 +0200 Subject: [PATCH 27/67] Adding support for raw html handling. --- src/Microdown-HTMLExporter/MicHTMLVisitor.class.st | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index f40273b92..b920045c1 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -159,7 +159,7 @@ MicHTMLVisitor >> crlfAsNewLine [ canvas crlfAsNewLine ] -{ #category : 'as yet unclassified' } +{ #category : 'accessing' } MicHTMLVisitor >> doNotIgnoreMetaData [ ignoresMetaData := false ] @@ -475,6 +475,13 @@ MicHTMLVisitor >> visitQuote: aQuote [ with: [ super visitQuote: aQuote ] ] +{ #category : 'visiting - html extensions' } +MicHTMLVisitor >> visitRaw: aParagraph [ + + canvas raw: aParagraph bodyString. + canvas newLine +] + { #category : 'visiting - html extensions' } MicHTMLVisitor >> visitRawParagraph: aParagraph [ From 0687f61b12dcb6fac0c9646b8494dbfdd1f5eeb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 10 May 2025 22:39:55 +0200 Subject: [PATCH 28/67] Making minimal configuration explicit about the line ending. --- src/Microdown/MicMinimalConfiguration.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microdown/MicMinimalConfiguration.class.st b/src/Microdown/MicMinimalConfiguration.class.st index d34d2b800..33cee302b 100644 --- a/src/Microdown/MicMinimalConfiguration.class.st +++ b/src/Microdown/MicMinimalConfiguration.class.st @@ -40,7 +40,7 @@ MicMinimalConfiguration >> headingLevelOffset: anObject [ { #category : 'initialization' } MicMinimalConfiguration >> initialize [ super initialize. - newLine := String crlf. + self crlfAsNewLine. headingLevelOffset := 0 ] From 19c2b5e93c8e2e449c0356a7764f020cad805984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 27 May 2025 20:49:26 +0200 Subject: [PATCH 29/67] Lousy way of supporting kind of text for every entities. This must be revisited. --- src/Microdown-Tests/MicrodownTest.class.st | 48 ++++++++++++++++++++++ src/Microdown/MicAbstractBlock.class.st | 3 +- src/Microdown/MicListItemBlock.class.st | 6 +++ src/Microdown/MicOrderedListBlock.class.st | 6 +++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/Microdown-Tests/MicrodownTest.class.st b/src/Microdown-Tests/MicrodownTest.class.st index c7e78c0a6..a38985876 100644 --- a/src/Microdown-Tests/MicrodownTest.class.st +++ b/src/Microdown-Tests/MicrodownTest.class.st @@ -13,6 +13,45 @@ Class { #tag : 'Core' } +{ #category : 'tests - replace' } +MicrodownTest >> rawMicrodownSyntax [ + + ^ ' +# Microdown is quite cool +@anchor + +Here is some code + +```language=Pharo&caption=Beautiful&anchor=Fig1 + 1000 factorial / 999 factorial +``` + +Here is a figure and a link: [http://pharo.org](http://pharo.org). + +![Pharologo](https://files.pharo.org/media/logo/logo.png size=80&anchor=figLogo) + +See *@figLogo@* + +## Lists + +Here is a list: +- item 1 + 1. sub item 1 + 3. sub item 2 +- item 2 + + +**Bold**, _italic_, `monospace` + +In Pharo, Microdown supports hyperlinks to: +- classes e.g., `Point`, +- methodes e.g., `Point class`, `Point>>#setX:setY:`, and +- packages e.g., `#''Microdown-Tests''` (for packages). + +You can edit this file clicking on `ClySyntaxHelpMorph>>#rawMicrodownSyntax`. +' +] + { #category : 'running' } MicrodownTest >> setUp [ super setUp. @@ -142,3 +181,12 @@ MicrodownTest >> testParentLinkIsKeptOnReplaceBy [ self assert: new parent equals: h. ] + +{ #category : 'tests - replace' } +MicrodownTest >> testText [ + + | doc | + doc := Microdown parse: self rawMicrodownSyntax. + self shouldnt: [ Character space join: (doc children allButFirst collect: [ :each | each text ]) ] raise: MessageNotUnderstood + +] diff --git a/src/Microdown/MicAbstractBlock.class.st b/src/Microdown/MicAbstractBlock.class.st index 6a16f865c..b20138688 100644 --- a/src/Microdown/MicAbstractBlock.class.st +++ b/src/Microdown/MicAbstractBlock.class.st @@ -186,12 +186,13 @@ MicAbstractBlock >> setParser: aParser [ { #category : 'accessing' } MicAbstractBlock >> text [ + | text | self flag: #todo. "what a terrible idea we concatenate the text of children and store. I could understand that we keep the text of the parser element but then we do not modify it after and certainly not change it." text := ''. - children do: [ :each | text := text , each text ]. + children do: [ :each | text := text , each bodyString ]. ^ text ] diff --git a/src/Microdown/MicListItemBlock.class.st b/src/Microdown/MicListItemBlock.class.st index 85c395b54..b9e1f961e 100644 --- a/src/Microdown/MicListItemBlock.class.st +++ b/src/Microdown/MicListItemBlock.class.st @@ -78,6 +78,12 @@ MicListItemBlock >> addLineAndReturnNextNode: line [ text := text , String cr , normalized ] ] +{ #category : 'accessing' } +MicListItemBlock >> bodyString [ + "I am used to make it easier to write tests" + ^ String streamContents: [ :str | children do: [ :each | str nextPutAll: each bodyString ] ] +] + { #category : 'testing' } MicListItemBlock >> canConsumeLine: line [ "return if this block can consume line" diff --git a/src/Microdown/MicOrderedListBlock.class.st b/src/Microdown/MicOrderedListBlock.class.st index 1ad7d6806..43846ea85 100644 --- a/src/Microdown/MicOrderedListBlock.class.st +++ b/src/Microdown/MicOrderedListBlock.class.st @@ -52,6 +52,12 @@ MicOrderedListBlock >> addLineAndReturnNextNode: line [ ^ super addLineAndReturnNextNode: line ] +{ #category : 'accessing' } +MicOrderedListBlock >> bodyString [ + + ^ String streamContents: [ :str | children do: [ :each | str nextPutAll: each bodyString ] ] +] + { #category : 'testing' } MicOrderedListBlock >> canConsumeLine: line [ "to consume this line there must be a UnorderdListItem start at the right indentation" From 06a90320c57c364509a412ac4721f0e704ab4302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Thu, 29 May 2025 21:19:22 +0200 Subject: [PATCH 30/67] Now using latest version of mustache i.e. v1.3 --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index 84a814f73..cf81c4f25 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -131,7 +131,7 @@ BaselineOfMicrodown >> mustache: spec [ spec baseline: 'Mustache' with: [ spec - repository: 'github://noha/mustache:v1.0/repository'; + repository: 'github://noha/mustache:v1.3/repository'; loads: #( 'Core' 'Tests' ) ] ] From 36dc33e8bb3ad000936ae7c683ef1de5486f152f Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Mon, 23 Jun 2025 12:11:59 +0200 Subject: [PATCH 31/67] Add pillar dependent methods --- .../MicHTMLVisitor.class.st | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index b920045c1..40fc308fe 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -93,6 +93,11 @@ MicHTMLVisitor class >> serializeToHTMLDoc: aMicrodownString withStyle: aStyleNa ] +{ #category : 'accessing' } +MicHTMLVisitor class >> writerName [ + ^ #html +] + { #category : 'initialization' } MicHTMLVisitor >> canvasClass [ @@ -164,6 +169,11 @@ MicHTMLVisitor >> doNotIgnoreMetaData [ ignoresMetaData := false ] +{ #category : 'accessing' } +MicHTMLVisitor >> folderName [ + ^ #html +] + { #category : 'accessing' } MicHTMLVisitor >> ignoreMetaData [ ignoresMetaData := true @@ -185,6 +195,12 @@ MicHTMLVisitor >> lfAsNewLine [ canvas lfAsNewLine ] +{ #category : 'accessing' } +MicHTMLVisitor >> mainDocumentTemplateName [ + + ^ 'template' +] + { #category : 'visiting - list' } MicHTMLVisitor >> metaDataFromAssociations: aDictionary [ "Write the receiver's metadata from aDictionary" @@ -209,6 +225,22 @@ MicHTMLVisitor >> stream: aStream [ canvas := self canvasClass on: stream ] +{ #category : 'templating' } +MicHTMLVisitor >> templateForConfiguration: aConfiguration [ + | inputFile templateName | + configuration := aConfiguration. + inputFile := configuration inputFile. + + (configuration hasProperty: #mainDocument) + ifFalse: [ ^ configuration propertyAt: self mainDocumentTemplateName ifAbsent: [ 'main.mustache' ] ]. + + templateName := inputFile fullName + = ((configuration baseDirectory resolve: configuration mainDocument) , 'pillar') fullName + ifTrue: [ self mainDocumentTemplateName ] + ifFalse: [ self chapterTemplateName ]. + ^ configuration propertyAt: templateName +] + { #category : 'initialization' } MicHTMLVisitor >> usedNewLine [ "Return the encoded new line. Useful for tests." @@ -589,6 +621,13 @@ MicHTMLVisitor >> visitUnorderedListItem: anUnorderedListItem [ ] +{ #category : 'writing' } +MicHTMLVisitor >> write: aMicElement [ + "for now for integration with Pillar." + self visit: aMicElement. + ^ self contents +] + { #category : 'visiting' } MicHTMLVisitor >> writeCounter: aCounter [ From d659047d7793635fcc1ee2e31f6ecc29fc37a163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 19 Jul 2025 14:44:39 +0200 Subject: [PATCH 32/67] Add better test for rawBlock and move test about rawParagraph to the corresponding class. --- .../MicParagraphBlockTest.class.st | 12 ++++++++ src/Microdown-Tests/MicRawBlockTest.class.st | 29 +++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/Microdown-Tests/MicParagraphBlockTest.class.st b/src/Microdown-Tests/MicParagraphBlockTest.class.st index 8aeac048f..143018bb3 100644 --- a/src/Microdown-Tests/MicParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicParagraphBlockTest.class.st @@ -30,6 +30,18 @@ a paragraph on two lines**'. ] +{ #category : 'tests' } +MicParagraphBlockTest >> testASimpleRawParagaaph [ + + | mic | + mic := (parser parse: ' +No idea what it is :) +') children first. + self assert: mic class equals: MicRawParagraphBlock. + self assert: mic label equals: 'title'. + +] + { #category : 'tests' } MicParagraphBlockTest >> testBoldMultipleLinesWithNewLine [ diff --git a/src/Microdown-Tests/MicRawBlockTest.class.st b/src/Microdown-Tests/MicRawBlockTest.class.st index caea092d9..5dc0aa19f 100644 --- a/src/Microdown-Tests/MicRawBlockTest.class.st +++ b/src/Microdown-Tests/MicRawBlockTest.class.st @@ -12,23 +12,34 @@ MicRawBlockTest >> subjectClass [ ] { #category : 'tests' } -MicRawBlockTest >> testASimpleRawParagaaph [ - | mic | - mic := (parser parse: ' -No idea what it is :) -') children first. - self assert: mic class equals: MicRawParagraphBlock. - self assert: mic label equals: 'title'. +MicRawBlockTest >> testRawBeginningOfLine [ + | root | + root := parser parse: '{{ +This is a raw paragraph +On two lines +}}'. + + self + assert: root children first children first class + equals: MicRawBlock. + self + assert: root children first children first bodyString + equals: ' +This is a raw paragraph +On two lines +' ] { #category : 'tests' } -MicRawBlockTest >> testRaw [ +MicRawBlockTest >> testRawDoesNotInterpretContents [ | root | root := parser parse: 'it should be in a paragraph {{_Foo_}}'. self assert: root children first class equals: MicParagraphBlock. self assert: root children first children second class - equals: MicRawBlock + equals: MicRawBlock. + self assert: root children first children second bodyString + equals: '_Foo_' ] From 9cb2386fea8dd0ef95a55c4aaffae05301605942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 2 Aug 2025 17:29:10 +0200 Subject: [PATCH 33/67] Make sure that microdown uses its own method to extract 1 from '1. b' --- src/Microdown/MicOrderedListBlock.class.st | 3 ++- src/Microdown/String.extension.st | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Microdown/MicOrderedListBlock.class.st b/src/Microdown/MicOrderedListBlock.class.st index 43846ea85..152987889 100644 --- a/src/Microdown/MicOrderedListBlock.class.st +++ b/src/Microdown/MicOrderedListBlock.class.st @@ -74,5 +74,6 @@ MicOrderedListBlock >> startIndex [ { #category : 'accessing' } MicOrderedListBlock >> startIndexFrom: line [ startIndex ifNotNil: [ ^self ]. - startIndex := line asInteger + "an ordered list line starts with the index and after a dot '.' " + startIndex := line microdownExtractPartOfInteger ] diff --git a/src/Microdown/String.extension.st b/src/Microdown/String.extension.st index c1a8f8d56..64c10a5e7 100644 --- a/src/Microdown/String.extension.st +++ b/src/Microdown/String.extension.st @@ -15,6 +15,19 @@ String >> escapeAll [ ^ escaped ] +{ #category : '*Microdown' } +String >> microdownExtractPartOfInteger [ + "Do not use. This method should only be used by microdown." + + | start stream | + start := self findFirst: [:char | char isDigit]. + start isZero ifTrue: [^ nil]. + stream := self readStream position: start - 1. + ((stream position ~= 0) and: [stream peekBack = $-]) + ifTrue: [stream back]. + ^ Integer readFrom: stream +] + { #category : '*Microdown' } String >> resolveDocument: document [ ^ self asMicResourceReference resolveDocument: document. From f480ebb96698ddedab7f3bfaec57199887700225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 2 Aug 2025 17:36:09 +0200 Subject: [PATCH 34/67] Fixes: #604 removed unused shared pool subclasses. --- src/Microdown/MicMicrodownSharedPool.class.st | 7 ------- src/Microdown/MicroSharedPool.class.st | 7 ------- 2 files changed, 14 deletions(-) delete mode 100644 src/Microdown/MicMicrodownSharedPool.class.st delete mode 100644 src/Microdown/MicroSharedPool.class.st diff --git a/src/Microdown/MicMicrodownSharedPool.class.st b/src/Microdown/MicMicrodownSharedPool.class.st deleted file mode 100644 index afd96ce2c..000000000 --- a/src/Microdown/MicMicrodownSharedPool.class.st +++ /dev/null @@ -1,7 +0,0 @@ -Class { - #name : 'MicMicrodownSharedPool', - #superclass : 'MicSharedPool', - #category : 'Microdown-Parser', - #package : 'Microdown', - #tag : 'Parser' -} diff --git a/src/Microdown/MicroSharedPool.class.st b/src/Microdown/MicroSharedPool.class.st deleted file mode 100644 index a6dea6eda..000000000 --- a/src/Microdown/MicroSharedPool.class.st +++ /dev/null @@ -1,7 +0,0 @@ -Class { - #name : 'MicroSharedPool', - #superclass : 'MicSharedPool', - #category : 'Microdown-Parser', - #package : 'Microdown', - #tag : 'Parser' -} From 0403938766114b0f3bf8d33be46066715565fe15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 2 Aug 2025 17:42:01 +0200 Subject: [PATCH 35/67] Move gitBridge to Microdown-Blog-Tests --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 4 ++-- src/{Microdown => Microdown-Blog-Tests}/MicBridge.class.st | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/{Microdown => Microdown-Blog-Tests}/MicBridge.class.st (73%) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index cf81c4f25..f4ed3860b 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -31,7 +31,7 @@ BaselineOfMicrodown >> baseline: spec [ spec postLoadDoIt: #'postload:package:'. spec - package: #Microdown with: [ spec requires: #( #GitBridge ) ]; + package: #Microdown; package: #'Microdown-Tests' with: [ spec requires: #( #Microdown ) ]; @@ -91,7 +91,7 @@ BaselineOfMicrodown >> baseline: spec [ package: #'Microdown-Blog' with: [ spec requires: #( #'Microdown' #'Mustache') ]; package: #'Microdown-Blog-Tests' with: [ - spec requires: #( #'Microdown-Blog' ) ]. + spec requires: #( #'Microdown-Blog' 'GitBridge') ]. "I do not want group without tests for now" spec diff --git a/src/Microdown/MicBridge.class.st b/src/Microdown-Blog-Tests/MicBridge.class.st similarity index 73% rename from src/Microdown/MicBridge.class.st rename to src/Microdown-Blog-Tests/MicBridge.class.st index 3fe766d8c..eab3a43b9 100644 --- a/src/Microdown/MicBridge.class.st +++ b/src/Microdown-Blog-Tests/MicBridge.class.st @@ -4,8 +4,8 @@ I am a bridge to access resources from Microdown clone Class { #name : 'MicBridge', #superclass : 'GitBridge', - #category : 'Microdown-Utils', - #package : 'Microdown', + #category : 'Microdown-Blog-Tests-Utils', + #package : 'Microdown-Blog-Tests', #tag : 'Utils' } From 3d38643651caa85dfbe8f34db648d996a3e6ff62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 2 Aug 2025 17:53:24 +0200 Subject: [PATCH 36/67] Fixes: #952 table row ending in with no character after the last Tx Kasper! --- .../MicTableBlockTest.class.st | 50 +++++++++++++++++++ src/Microdown/MicTableBlock.class.st | 16 +++--- 2 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 src/Microdown-Tests/MicTableBlockTest.class.st diff --git a/src/Microdown-Tests/MicTableBlockTest.class.st b/src/Microdown-Tests/MicTableBlockTest.class.st new file mode 100644 index 000000000..9d9f59743 --- /dev/null +++ b/src/Microdown-Tests/MicTableBlockTest.class.st @@ -0,0 +1,50 @@ +Class { + #name : 'MicTableBlockTest', + #superclass : 'MicBlockTest', + #category : 'Microdown-Tests-Parser', + #package : 'Microdown-Tests', + #tag : 'Parser' +} + +{ #category : 'tests' } +MicTableBlockTest >> subjectClass [ + ^ MicTableBlock +] + +{ #category : 'tests' } +MicTableBlockTest >> testExtractLine [ + + | checker | + checker := [ :source | | result | + result := MicTableBlock new extractLine: source. + self assert: result size equals: 3. + self assert: result second equals: 'bbb'. + ]. + checker value: '| aaa | bbb | ccc'. + checker value: '| aaa | bbb | ccc '. + checker value: '| aaa | bbb | ccc |'. + checker value: '| aaa | bbb | ccc | '. +] + +{ #category : 'tests' } +MicTableBlockTest >> testTableNoHeader [ + "A header can only contain --- space and |" + + | source | + source := '| AAA | BBB | CCC '. + self deny: (MicTableBlock new isHeader: source). + source := '| AAA | BBB | CCC |'."Nothing after |" + self deny: (MicTableBlock new isHeader: source). +] + +{ #category : 'tests' } +MicTableBlockTest >> testTableWithHeader [ + + | source | + source := '| --- | --- | ---'. + self assert: (MicTableBlock new isHeader: source). + source := '| --- | --- | --- |'. + self assert: (MicTableBlock new isHeader: source). + source := '| --- | --- | --- | '. + self assert: (MicTableBlock new isHeader: source). +] diff --git a/src/Microdown/MicTableBlock.class.st b/src/Microdown/MicTableBlock.class.st index bca273f0e..9b6115770 100644 --- a/src/Microdown/MicTableBlock.class.st +++ b/src/Microdown/MicTableBlock.class.st @@ -82,17 +82,17 @@ MicTableBlock >> extractLine: line [ For now we have | something | something | or - | something | something" - | unicodeReplacementCharacter | - + | some thing | something" + | unicodeReplacementCharacter backslashLine rowColumn | + "allow pipe symbols to be written as \|" unicodeReplacementCharacter := 16rFFFD asCharacter asString. "By definition this do not appear in any input" - - ^ ((line copyReplaceAll: '\|' with: unicodeReplacementCharacter) findBetweenSubstrings: '|') + + backslashLine := (line copyReplaceAll: '\|' with: unicodeReplacementCharacter) trim. + "remove spaces at the end" + rowColumn := backslashLine findBetweenSubstrings: '|'. + ^ rowColumn collect: [ :each | (each copyReplaceAll: unicodeReplacementCharacter with: '|') trim] - - - ] { #category : 'accessing' } From 81abfa8f1d3ad8ae7277d017848801358542b15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 2 Aug 2025 18:00:49 +0200 Subject: [PATCH 37/67] Fixes: #834 with bad parsing of empty metadata --- src/Microdown-Tests/MicMetaDataBlockTest.class.st | 15 +++++++++++++++ src/Microdown/MicMetaDataBlock.class.st | 1 + 2 files changed, 16 insertions(+) diff --git a/src/Microdown-Tests/MicMetaDataBlockTest.class.st b/src/Microdown-Tests/MicMetaDataBlockTest.class.st index 1fff52a8e..2244e4cca 100644 --- a/src/Microdown-Tests/MicMetaDataBlockTest.class.st +++ b/src/Microdown-Tests/MicMetaDataBlockTest.class.st @@ -40,6 +40,21 @@ MicMetaDataBlockTest >> testAtKeyPut [ self assert: (metadata atKey: 'title') equals: 'Pilote'. ] +{ #category : 'tests - parsing' } +MicMetaDataBlockTest >> testAtNoKey [ + + | source root metadata | + source := '{ }'. + root := parser parse: source. + metadata := root children first. + self assert: metadata body size equals: 0. + source := '{ + }'. + root := parser parse: source. + metadata := root children first. + self assert: metadata body size equals: 0. +] + { #category : 'tests' } MicMetaDataBlockTest >> testCorrectJSONMetaDataProducesDictionary [ diff --git a/src/Microdown/MicMetaDataBlock.class.st b/src/Microdown/MicMetaDataBlock.class.st index 24c7b17ed..b85010cec 100644 --- a/src/Microdown/MicMetaDataBlock.class.st +++ b/src/Microdown/MicMetaDataBlock.class.st @@ -81,6 +81,7 @@ MicMetaDataBlock >> bogusParsing [ { #category : 'markups' } MicMetaDataBlock >> closeMe [ super closeMe. + body ifNil:[ body := '']. body := [ STONJSON fromString: '{', body, '}' ] on: Error do: [ :ex | | dict | bogusParsing := true. From b866f668177695f8caa1c7ec485538575baae76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 2 Aug 2025 18:07:54 +0200 Subject: [PATCH 38/67] Update README.md --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 649eff5db..b2abbf6c4 100644 --- a/README.md +++ b/README.md @@ -212,16 +212,22 @@ Metacello new ## History -We have two sources: Pharo in one hand and Pillar and both are not totally synchronized. +We have two sources: +- Pharo in one hand (a minimal version managed with the pharo* branches) and +- Pillar (eg. all the tools and support for slides and books) and both are not totally synchronized. +Now we also maintain different versions between Pharo versions. Currently the situation is the following: -Using Pharo 13: v2.7.x +Working with Pharo 13: +- v2.9.2 a little release to support Foliage v2.1.0 and two new release of Pillar (probably one for P13 and one for P13 dropping pillar format). +- v2.9.1 provides a better integration with Pillar (the Microdown visitors were not used before even if they worked) +v2.7.x - v2.7.2 merge pharo 13 changes / added gitbridge / OCompiler migration / cleaning syntax description / Ready for Pillar and Foliage - v2.7.1 LatexQuoteblock-should-not-use-verbatim - v2.7.0 Fix some errors and API/clients of the textualbuilder -Using Pharo 12: v2.5.x +Working with Pharo 12: v2.5.x - v2.5.6 - Change html visitor and test for annotated paragraph - v2.5.5 - add support for top-level header as slide definition - v2.5.4 - add backward compatible anchor in caption + tonel V3 format @@ -231,7 +237,8 @@ Using Pharo 12: v2.5.x Watch out v2.6.0 is older than v.2.5.4 -### Pillar History +### Extract of Pillar History + For Pharo 12 - v10.0.0 but with some links problems due to new inline parser using MD v2.5.0 @@ -243,7 +250,10 @@ For Pharo 10 -v8.3.2 fixed baseline and updated readme + + ## Implementation + The parser follows the design mentioned in [https://github.github.com/gfm](https://github.github.com/gfm), in particular the parsing strategy in Appendix A. In short, the strategy is that at any point in time, we might have several children of the root which are ""open"". The deepest in open in the tree is called ""current"". All the parents of the current are open. From 26d0316ffe9fde5d1043cfb6b8fcfdbd14e2f0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Thu, 7 Aug 2025 21:00:24 +0200 Subject: [PATCH 39/67] Started to add printOn: to ease debugging --- src/Microdown-Tests/MicParserTest.class.st | 35 ++++++++++++++++++++++ src/Microdown/MicHeaderBlock.class.st | 7 +++++ src/Microdown/MicParagraphBlock.class.st | 7 +++++ 3 files changed, 49 insertions(+) diff --git a/src/Microdown-Tests/MicParserTest.class.st b/src/Microdown-Tests/MicParserTest.class.st index 4c7078cca..f493af9db 100644 --- a/src/Microdown-Tests/MicParserTest.class.st +++ b/src/Microdown-Tests/MicParserTest.class.st @@ -19,6 +19,41 @@ MicParserTest >> setUp [ parser := MicrodownParser new. ] +{ #category : 'tests' } +MicParserTest >> test [ + + | source root | + source := ' +{ +"title" : "About Pharo", +"layout" : "index", +"publishDate" : "2025-06-01" +} + +# Pharo + +[Pharo](http://www.pharo.org) is a beautiful dynamically-typed reflective pure object-oriented language that we have been developing since 2008. +It is inspired by Smalltalk (I''m extremely grateful to Alan Kay and Dan Ingalls - they were so visionary and right). Now our vision for Pharo is to reinvent Smalltalk and produce a better system. +From that perspective, I''m used to say that Pharo is what we have and not what we want. +In essence, Pharo is the beginning of the journey and not the final goal. And you can change its future. + + +You can check what companies are saying about it: [Video](https://youtu.be/6tdkKNX2g4s) + + +There are many aspects I would like to see being explored either by us or by others. +If you want to explore some of the following aspects, please go and let us know. +I''m really interested in any topics that evolve Pharo into a better Pharo. + +'. + + self halt. + root := parser parse: source. + + self assert: root children size equals: 5. + +] + { #category : 'tests' } MicParserTest >> testEmpty [ | source root | diff --git a/src/Microdown/MicHeaderBlock.class.st b/src/Microdown/MicHeaderBlock.class.st index d87ae9bc7..050fd883a 100644 --- a/src/Microdown/MicHeaderBlock.class.st +++ b/src/Microdown/MicHeaderBlock.class.st @@ -89,3 +89,10 @@ MicHeaderBlock >> level: anInteger [ ] + +{ #category : 'printing' } +MicHeaderBlock >> printOn: aStream [ + + super printOn: aStream. + aStream nextPutAll: ' - ', self header +] diff --git a/src/Microdown/MicParagraphBlock.class.st b/src/Microdown/MicParagraphBlock.class.st index a4ef8a62a..a37348a6b 100644 --- a/src/Microdown/MicParagraphBlock.class.st +++ b/src/Microdown/MicParagraphBlock.class.st @@ -80,6 +80,13 @@ MicParagraphBlock >> isRightlyIndented: line [ ^ line beginsWith: (' ' repeat: self indent) ] +{ #category : 'printing' } +MicParagraphBlock >> printOn: aStream [ + + super printOn: aStream. + aStream nextPutAll: ' - ', self text +] + { #category : 'accessing' } MicParagraphBlock >> text [ ^ text From f175de805b129b8ab9b3ae7302ae3d3af547cb4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Thu, 7 Aug 2025 21:29:28 +0200 Subject: [PATCH 40/67] getting started. Commit so that we can test with Foliage --- .../MicHTMLExporterTest.class.st | 34 +++++++++++++++++++ .../MicHTMLVisitor.class.st | 3 +- src/Microdown-Tests/MicParserTest.class.st | 1 - 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st index 05eac6c1c..a9b45cc8a 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st @@ -58,6 +58,33 @@ MicHTMLExporterTest >> parser: aParser [ parser := aParser new ] +{ #category : 'tests - paragraph' } +MicHTMLExporterTest >> pharoPage [ + + ^ + ' + { +"title" : "About Pharo", +"layout" : "index", +"publishDate" : "2025-06-01" +} + +# Pharo + +[Pharo](http://www.pharo.org) is a beautiful dynamically-typed reflective pure object-oriented language that we have been developing since 2008. +It is inspired by Smalltalk (I''m extremely grateful to Alan Kay and Dan Ingalls - they were so visionary and right). Now our vision for Pharo is to reinvent Smalltalk and produce a better system. +From that perspective, I''m used to say that Pharo is what we have and not what we want. +In essence, Pharo is the beginning of the journey and not the final goal. And you can change its future. + +You can check what companies are saying about it: [Video](https://youtu.be/6tdkKNX2g4s) + +There are many aspects I would like to see being explored either by us or by others. +If you want to explore some of the following aspects, please go and let us know. +I''m really interested in any topics that evolve Pharo into a better Pharo. + +' +] + { #category : 'tests - paragraph' } MicHTMLExporterTest >> testAccents [ @@ -258,6 +285,13 @@ MicHTMLExporterTest >> testParagraphWithMonospace [ 'this is a paragraph' ] +{ #category : 'tests - paragraph' } +MicHTMLExporterTest >> testPharoPage [ + + self halt. + self parse: self pharoPage andCheckWeGet: '' +] + { #category : 'tests - formats' } MicHTMLExporterTest >> testQuote [ diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index 40fc308fe..792b64873 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -488,7 +488,8 @@ MicHTMLVisitor >> visitOrderedListItem: anOrderedListItem [ MicHTMLVisitor >> visitParagraph: aParagraph [ canvas newLine. - super visitParagraph: aParagraph + super visitParagraph: aParagraph. + canvas newLine. "canvas tag name: 'p'; with: [ ]" diff --git a/src/Microdown-Tests/MicParserTest.class.st b/src/Microdown-Tests/MicParserTest.class.st index f493af9db..4f566b2b8 100644 --- a/src/Microdown-Tests/MicParserTest.class.st +++ b/src/Microdown-Tests/MicParserTest.class.st @@ -47,7 +47,6 @@ I''m really interested in any topics that evolve Pharo into a better Pharo. '. - self halt. root := parser parse: source. self assert: root children size equals: 5. From 00bd69e4353821015a7a1e0105705451cafb9b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 8 Aug 2025 09:07:25 +0200 Subject: [PATCH 41/67] Better parse:andCheck: --- .../MicHTMLExporterTest.class.st | 6 +++--- .../MicAbstractLaTexWriterTest.class.st | 6 ++++-- src/Microdown-PrettyPrinter-Tests/MicDumperTest.class.st | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st index a9b45cc8a..578cc355b 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st @@ -41,11 +41,11 @@ MicHTMLExporterTest >> newLine: aNewLine [ { #category : 'utilities' } MicHTMLExporterTest >> parse: aString andCheckWeGet: aResultingString [ - | mic | - + | mic c | mic := parser parse: aString. writer visit: mic. - self assert: writer contents equals: aResultingString + c := writer contents. + self assert: c equals: aResultingString ] { #category : 'utilities' } diff --git a/src/Microdown-LaTeXExporter-Tests/MicAbstractLaTexWriterTest.class.st b/src/Microdown-LaTeXExporter-Tests/MicAbstractLaTexWriterTest.class.st index 877d88098..f45bfdc87 100644 --- a/src/Microdown-LaTeXExporter-Tests/MicAbstractLaTexWriterTest.class.st +++ b/src/Microdown-LaTeXExporter-Tests/MicAbstractLaTexWriterTest.class.st @@ -76,10 +76,12 @@ MicAbstractLaTexWriterTest >> newLine: aNewLine [ { #category : 'tests - formats' } MicAbstractLaTexWriterTest >> parse: aString andCheckWeGet: aResultingString [ - | mic | + | mic c | mic := parser parse: aString. writer visit: mic. - self assert: writer contents equals: aResultingString + c := writer contents. + self assert: c equals: aResultingString. + ^ c ] { #category : 'tests - formats' } diff --git a/src/Microdown-PrettyPrinter-Tests/MicDumperTest.class.st b/src/Microdown-PrettyPrinter-Tests/MicDumperTest.class.st index 9585badb6..30aa05a44 100644 --- a/src/Microdown-PrettyPrinter-Tests/MicDumperTest.class.st +++ b/src/Microdown-PrettyPrinter-Tests/MicDumperTest.class.st @@ -13,10 +13,12 @@ Class { { #category : 'tests - section' } MicDumperTest >> parse: aString andCheckWeGet: anExpectedString [ - | mic | + | mic c | mic := parser parse: aString. visitor visit: mic children first. - self assert: visitor contents equals: anExpectedString + c := visitor contents. + self assert: c equals: anExpectedString. + ^ c ] { #category : 'running' } From a0e6179600186512a103aef5e5e07b0d3275ff80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 8 Aug 2025 09:47:45 +0200 Subject: [PATCH 42/67] Fixing paragraph with an extra new lines for now (instead of the

because we should investigate why this

was disabled) --- .../MicHTMLExporterTest.class.st | 78 ++++++++++--------- .../MicHTMLVisitorTest.class.st | 18 ++--- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st index 578cc355b..03d81a4ec 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st @@ -38,6 +38,12 @@ MicHTMLExporterTest >> newLine: aNewLine [ newLine := aNewLine ] +{ #category : 'tests - paragraph' } +MicHTMLExporterTest >> newLines: aString [ + + ^ newLine, aString, newLine +] + { #category : 'utilities' } MicHTMLExporterTest >> parse: aString andCheckWeGet: aResultingString [ @@ -88,8 +94,8 @@ I''m really interested in any topics that evolve Pharo into a better Pharo. { #category : 'tests - paragraph' } MicHTMLExporterTest >> testAccents [ - self parse: 'éà' andCheckWeGet: newLine, -'éà' + self parse: 'éà' andCheckWeGet: (self newLines: +'éà') ] { #category : 'utilities' } @@ -127,8 +133,8 @@ MicHTMLExporterTest >> testFigure [ self parse: factory figureSample - andCheckWeGet: newLine , -'

Foo
Foo
' + andCheckWeGet: (self newLines: +'
Foo
Foo
') ] { #category : 'tests - formats' } @@ -136,8 +142,8 @@ MicHTMLExporterTest >> testFigureBold [ self parse: factory figureBoldSample - andCheckWeGet: newLine , -'
Foo
Foo
' + andCheckWeGet: (self newLines: +'
Foo
Foo
' ) ] { #category : 'tests' } @@ -145,8 +151,8 @@ MicHTMLExporterTest >> testFigureItalic [ self parse: factory figureItalicSample - andCheckWeGet: newLine , -'
Foo
Foo
' + andCheckWeGet: (self newLines: +'
Foo
Foo
') ] { #category : 'tests' } @@ -154,8 +160,8 @@ MicHTMLExporterTest >> testFigureNested [ self parse: factory figureNestedSample - andCheckWeGet: newLine , -'
Foo_
Foo_
' + andCheckWeGet: (self newLines: +'
Foo_
Foo_
') ] { #category : 'tests' } @@ -163,8 +169,8 @@ MicHTMLExporterTest >> testFigureReal [ self parse: factory figureRealSample - andCheckWeGet: newLine , -'
A logo png under figures folder
A logo png under figures folder
' + andCheckWeGet: (self newLines: +'
A logo png under figures folder
A logo png under figures folder
') ] { #category : 'tests' } @@ -172,8 +178,8 @@ MicHTMLExporterTest >> testFigureStrike [ self parse: factory figureStrikeSample - andCheckWeGet: newLine , -'
Foo
Foo
' + andCheckWeGet: (self newLines: +'
Foo
Foo
') ] { #category : 'tests' } @@ -181,8 +187,8 @@ MicHTMLExporterTest >> testFigureWithLabelWithoutSize [ self parse: factory figureWithLabelWithoutSizeSample - andCheckWeGet: newLine , -'
Foo
Foo
' + andCheckWeGet: (self newLines: +'
Foo
Foo
') ] { #category : 'tests' } @@ -190,8 +196,8 @@ MicHTMLExporterTest >> testFigureWithoutCaption [ self parse: factory figureWithoutCaptionSample - andCheckWeGet: newLine , -'
' + andCheckWeGet: (self newLines: +'
') ] { #category : 'tests' } @@ -199,8 +205,8 @@ MicHTMLExporterTest >> testFigureWithoutSizeAndLabel [ self parse: factory figureSampleWithoutSizeAndLabel - andCheckWeGet: newLine , -'
Foo
Foo
' + andCheckWeGet: (self newLines: +'
Foo
Foo
') ] { #category : 'tests' } @@ -208,8 +214,8 @@ MicHTMLExporterTest >> testGoutDeFraise [ self parse: factory figureGoutDeFraise - andCheckWeGet: newLine , -'
Proposition pour le thème :  Un goût de fraise
Proposition pour le thème : Un goût de fraise
' + andCheckWeGet: (self newLines: +'
Proposition pour le thème :  Un goût de fraise
Proposition pour le thème : Un goût de fraise
') ] { #category : 'tests' } @@ -245,21 +251,21 @@ MicHTMLExporterTest >> testMetaDataIsNotIgnored [ { #category : 'tests - paragraph' } MicHTMLExporterTest >> testParagraph [ - self parse: factory paragraphSample andCheckWeGet: newLine ,'Foo' + self parse: factory paragraphSample andCheckWeGet: (self newLines: 'Foo') ] { #category : 'tests' } MicHTMLExporterTest >> testParagraphLongWithAccents [ - self parse: factory paragraphOnMultipleLinesSample andCheckWeGet: newLine , -'Je ne connais pas la peur, car la peur tue l''esprit. La peur est la petite mort qui conduit à l''oblitération totale. J''affonterai ma peur. Je lui permettrais de passer sur moi, au travers de moi. Et lorsqu''elle sera passée, je tournerai mon oeil interieur sur son chemin. Et là où elle sera passée, il n''y aura plus rien, rien que moi.' + self parse: factory paragraphOnMultipleLinesSample andCheckWeGet: (self newLines: +'Je ne connais pas la peur, car la peur tue l''esprit. La peur est la petite mort qui conduit à l''oblitération totale. J''affonterai ma peur. Je lui permettrais de passer sur moi, au travers de moi. Et lorsqu''elle sera passée, je tournerai mon oeil interieur sur son chemin. Et là où elle sera passée, il n''y aura plus rien, rien que moi.') ] { #category : 'tests - formats' } MicHTMLExporterTest >> testParagraphNestedSample [ - self parse: factory paragraphNestedSample andCheckWeGet: newLine , -'this is a paragraph' + self parse: factory paragraphNestedSample andCheckWeGet: (self newLines: +'this is a paragraph') ] { #category : 'tests - formats' } @@ -267,28 +273,28 @@ MicHTMLExporterTest >> testParagraphWithBold [ self parse: factory paragraphBoldSample - andCheckWeGet: newLine , -'this is a paragraph' + andCheckWeGet: (self newLines: +'this is a paragraph') ] { #category : 'tests' } MicHTMLExporterTest >> testParagraphWithItalic [ - self parse: factory paragraphItalicSample andCheckWeGet: newLine , -'this is a paragraph' + self parse: factory paragraphItalicSample andCheckWeGet: (self newLines: +'this is a paragraph') ] { #category : 'tests - formats' } MicHTMLExporterTest >> testParagraphWithMonospace [ - self parse: factory paragraphMonospaceSample andCheckWeGet: newLine , -'this is a paragraph' + self parse: factory paragraphMonospaceSample andCheckWeGet: (self newLines: +'this is a paragraph') ] { #category : 'tests - paragraph' } MicHTMLExporterTest >> testPharoPage [ - self halt. + self flag: #todo. self parse: self pharoPage andCheckWeGet: '' ] @@ -302,8 +308,8 @@ MicHTMLExporterTest >> testQuote [ { #category : 'tests - formats' } MicHTMLExporterTest >> testStrike [ - self parse: factory strikethroughFormatSample andCheckWeGet: newLine , -'Foo' + self parse: factory strikethroughFormatSample andCheckWeGet: (self newLines: +'Foo') ] { #category : 'tests' } diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index eaafd4bf6..a777644ea 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -98,7 +98,7 @@ MicHTMLVisitorTest >> testConvertMicFile [ self assert: (fileSystem / 'anExample1.html') asFileReference contents equals: newLine , '

Foo

' , newLine - , 'Pharo is cool' , newLine + , 'Pharo is cool' , newLine, newLine , '
this is a code blu blu
' , newLine ] @@ -210,7 +210,7 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ result := writer convertMicString: source. self assert: result trimBoth - equals: '
', newLine , 'Tintin', newLine, + equals: '
', newLine , 'Tintin', newLine, newLine, '
'. ] @@ -224,7 +224,7 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ source := '
', newLine, '

', -'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, newLine, '', newLine, 'word', newLine, '', newLine, @@ -241,14 +241,14 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ assert: result trimBoth equals: '

', newLine, '

', -'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, +'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, newLine, '', newLine, -'word', newLine, +'word', newLine, newLine, '', newLine, 'we place it within <span> tag.', -'

', newLine, +'

', newLine, newLine, '

', newLine, -'Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.', newLine, +'Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.', newLine, newLine, '

', newLine, '
'. ] @@ -278,8 +278,8 @@ MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ result := writer convertMicString: source. self assert: result trimBoth - equals: '
', newLine , '

', newLine,'some text', newLine, '

', newLine, -'and', newLine, '
'. + equals: '
', newLine , '

', newLine,'some text', newLine, newLine, '

', newLine, +'and', newLine, newLine, '
'. ] From 361f0c338765f67f370aae5dd3d8f0f3e35494f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 8 Aug 2025 09:55:58 +0200 Subject: [PATCH 43/67] adding comments and more tests --- .../MicHTMLExporterTest.class.st | 16 +++++++++++----- .../MicHTMLVisitor.class.st | 8 ++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st index 03d81a4ec..53f69fea0 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st @@ -51,7 +51,8 @@ MicHTMLExporterTest >> parse: aString andCheckWeGet: aResultingString [ mic := parser parse: aString. writer visit: mic. c := writer contents. - self assert: c equals: aResultingString + self assert: c equals: aResultingString. + ^ c ] { #category : 'utilities' } @@ -68,8 +69,7 @@ MicHTMLExporterTest >> parser: aParser [ MicHTMLExporterTest >> pharoPage [ ^ - ' - { + '{ "title" : "About Pharo", "layout" : "index", "publishDate" : "2025-06-01" @@ -294,8 +294,14 @@ MicHTMLExporterTest >> testParagraphWithMonospace [ { #category : 'tests - paragraph' } MicHTMLExporterTest >> testPharoPage [ - self flag: #todo. - self parse: self pharoPage andCheckWeGet: '' + self parse: self pharoPage andCheckWeGet: ' +

Pharo

+Pharo is a beautiful dynamically-typed reflective pure object-oriented language that we have been developing since 2008.
It is inspired by Smalltalk (I''m extremely grateful to Alan Kay and Dan Ingalls - they were so visionary and right). Now our vision for Pharo is to reinvent Smalltalk and produce a better system.
From that perspective, I''m used to say that Pharo is what we have and not what we want.
In essence, Pharo is the beginning of the journey and not the final goal. And you can change its future. + +You can check what companies are saying about it: Video + +There are many aspects I would like to see being explored either by us or by others.
If you want to explore some of the following aspects, please go and let us know.
I''m really interested in any topics that evolve Pharo into a better Pharo. +' ] { #category : 'tests - formats' } diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index 792b64873..de4f125ef 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -489,6 +489,14 @@ MicHTMLVisitor >> visitParagraph: aParagraph [ canvas newLine. super visitParagraph: aParagraph. + "Introduce an extra new line to address problem of merged rendered paragraph. + I did not reintroduce the

below because I do not remember why it was + cancel. May be it was generating too many

+ Now it may happen that for intra block element tests

was generated + while in a normal setup (since the intrablock elements will be inside + a large paragraph) it will not be a problem. + + So this issue should be further investigated." canvas newLine. "canvas tag name: 'p'; From ab63540d5566ea63941d974f7d0afa8601cdc945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 8 Aug 2025 10:00:56 +0200 Subject: [PATCH 44/67] Adding log --- src/Microdown/MyLog.class.st | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/Microdown/MyLog.class.st diff --git a/src/Microdown/MyLog.class.st b/src/Microdown/MyLog.class.st new file mode 100644 index 000000000..249d6e71d --- /dev/null +++ b/src/Microdown/MyLog.class.st @@ -0,0 +1,47 @@ +" +I'm responsible for keeping a log of the development actions at the design level. +Too many times I do not remember what I did and why. +" +Class { + #name : 'MyLog', + #superclass : 'Object', + #category : 'Microdown', + #package : 'Microdown' +} + +{ #category : 'as yet unclassified' } +MyLog >> l2025_08_08 [ + + ^ ' +## 2025 08 08 + +#### Started this log +#### Fix the rendering of paragraphs. + +The problem was that when two consecutive paragraphs were rendered we could not see the split. +https://github.com/pillar-markup/Microdown/issues/957 +It was due to a lack of

or newline. + +I decided to go for an extra newLine but it can be a bad choice. + +``` +visitParagraph: aParagraph + + canvas newLine. + super visitParagraph: aParagraph. + "Introduce an extra new line to address problem of merged rendered paragraph. + I did not reintroduce the

below because I do not remember why it was + cancel. May be it was generating too many

+ Now it may happen that for intra block element tests

was generated + while in a normal setup (since the intrablock elements will be inside + a large paragraph) it will not be a problem. + + So this issue should be further investigated." + canvas newLine. + "canvas tag + name: ''p''; + with: [ ]" +``` + + ' +] From 8c01937513ad4efb370eb0830f667934644deaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 8 Aug 2025 11:31:37 +0200 Subject: [PATCH 45/67] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2abbf6c4..16fb07758 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ You can also execute the script provided below. ```Smalltalk Metacello new baseline: 'Microdown'; - repository: 'github://pillar-markup/Microdown:v2.7.2/src'; + repository: 'github://pillar-markup/Microdown:v2.7.3/src'; load. ``` From 841ecb63c52100f383281030ca016b28800ff143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 8 Aug 2025 11:33:40 +0200 Subject: [PATCH 46/67] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 16fb07758..a346c9dbf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,16 @@ Microdown is a smaller markdown but it is more extensible. It contains a nice bu Microdown is now the default markup for the Pillar document compilation chain. +## Instal + +```Smalltalk +Metacello new + baseline: 'Microdown'; + repository: 'github://pillar-markup/Microdown:v2.9.3/src'; + load. +``` + + ## Why should you use Microdown? Microdown is a smaller markdown but it is more extensible. @@ -174,7 +184,7 @@ You can also execute the script provided below. ```Smalltalk Metacello new baseline: 'Microdown'; - repository: 'github://pillar-markup/Microdown:v2.7.3/src'; + repository: 'github://pillar-markup/Microdown:master/src'; load. ``` From 508f090459c8958eee17d8a1f4371ae5feb36fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 11 Aug 2025 14:32:42 +0200 Subject: [PATCH 47/67] Fix visitParagraph: to emit

. Half of the tests are fixed. --- .../MicHTMLVisitorTest.class.st | 33 +++++++++++-------- .../MicHTMLVisitor.class.st | 15 ++------- src/Microdown/MyLog.class.st | 12 +++++++ 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index a777644ea..b989d7ab4 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -93,12 +93,11 @@ MicHTMLVisitorTest >> testContents [ MicHTMLVisitorTest >> testConvertMicFile [ writer convertMicFile: (fileSystem / 'anExample1.md') asFileReference. - self assert: (fileSystem / 'anExample1.html') asFileReference exists. self assert: (fileSystem / 'anExample1.html') asFileReference contents equals: newLine , '

Foo

' , newLine - , 'Pharo is cool' , newLine, newLine + , (self wrapP: 'Pharo is cool'), newLine , '
this is a code blu blu
' , newLine ] @@ -140,7 +139,7 @@ MicHTMLVisitorTest >> testCreateAnchorWithLink [ | result | self assert: writer contents equals: String empty. result := writer convertMicString: '[Pharo Website](http://pharo.org target=blank&rel=bookmark)'. - self assert: result trimBoth equals: 'Pharo Website'. + self assert: result trimBoth , newLine equals: (self wrapP: 'Pharo Website'). ] { #category : 'tests' } @@ -154,11 +153,11 @@ MicHTMLVisitorTest >> testCreateAnnotationCompound [ this is another string'. self - assert: result trimBoth + assert: result trimBoth, newLine equals: '

This is a title

' , newLine , 'Body of annotated block' - , newLine , 'this is another string' + , newLine , (self wrapP: 'this is another string') ] { #category : 'tests' } @@ -183,7 +182,7 @@ MicHTMLVisitorTest >> testCreateCitation [ self assert: writer contents equals: String empty. result := writer convertMicString: '{!citation|ref=Duca99a!}'. - self assert: result trimBoth equals: 'Duca99a'. + self assert: result trimBoth, newLine equals: (self wrapP: 'Duca99a'). ] @@ -194,7 +193,7 @@ MicHTMLVisitorTest >> testCreateItalic [ self assert: writer contents equals: String empty. result := writer convertMicString: '_Text with italic_'. - self assert: result trimBoth equals: 'Text with italic'. + self assert: result trimBoth, newLine equals: (self wrapP: 'Text with italic'). ] @@ -209,9 +208,9 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgs [ result := writer convertMicString: source. self - assert: result trimBoth - equals: '
', newLine , 'Tintin', newLine, newLine, - '
'. + assert: result trimBoth , newLine + equals: '
', newLine , (self wrapP:'Tintin'), newLine, + '
', newLine. ] @@ -262,8 +261,8 @@ MicHTMLVisitorTest >> testRawParagraphIframe [ result := writer convertMicString: '', newLine, 'Tintin'. - self assert: result trimBoth equals: '', newLine, 'Tintin' + self assert: result trimBoth, newLine equals: '', newLine, (self wrapP: 'Tintin') ] @@ -278,8 +277,8 @@ MicHTMLVisitorTest >> testRawParagraphSimpleDiv [ result := writer convertMicString: source. self assert: result trimBoth - equals: '
', newLine , '

', newLine,'some text', newLine, newLine, '

', newLine, -'and', newLine, newLine, '
'. + equals: '
', newLine , '

', newLine, (self wrapP: 'some text'), newLine, '

', newLine, +(self wrapP: 'and'), newLine, '
'. ] @@ -304,6 +303,12 @@ MicHTMLVisitorTest >> testVisitAnchor [ ] +{ #category : 'tests' } +MicHTMLVisitorTest >> wrapP: aString [ + + ^ '

', aString , '

', newLine +] + { #category : 'accessing' } MicHTMLVisitorTest >> writer: aWriter [ writer := aWriter new diff --git a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st index de4f125ef..ad4f30669 100644 --- a/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st +++ b/src/Microdown-HTMLExporter/MicHTMLVisitor.class.st @@ -488,19 +488,10 @@ MicHTMLVisitor >> visitOrderedListItem: anOrderedListItem [ MicHTMLVisitor >> visitParagraph: aParagraph [ canvas newLine. - super visitParagraph: aParagraph. - "Introduce an extra new line to address problem of merged rendered paragraph. - I did not reintroduce the

below because I do not remember why it was - cancel. May be it was generating too many

- Now it may happen that for intra block element tests

was generated - while in a normal setup (since the intrablock elements will be inside - a large paragraph) it will not be a problem. - - So this issue should be further investigated." - canvas newLine. - "canvas tag + canvas tag name: 'p'; - with: [ ]" + with: [ super visitParagraph: aParagraph. ]. + canvas newLine. ] { #category : 'visiting' } diff --git a/src/Microdown/MyLog.class.st b/src/Microdown/MyLog.class.st index 249d6e71d..ea3d05364 100644 --- a/src/Microdown/MyLog.class.st +++ b/src/Microdown/MyLog.class.st @@ -45,3 +45,15 @@ visitParagraph: aParagraph ' ] + +{ #category : 'as yet unclassified' } +MyLog >> l2025_08_11 [ + + ^ ' +## 2025 08 11 + +#### Fix the visit of the paragraph + Now it uses

as before. Foliage generation is working. + + ' +] From 5095e6ccc97c211d239e797aaaa9f616e225dab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 11 Aug 2025 15:13:25 +0200 Subject: [PATCH 48/67] All tests pass + new tests --- .../MicHTMLExporterTest.class.st | 12 +++++------- .../MicHTMLVisitorTest.class.st | 11 +++++------ .../MicRawParagraphBlockTest.class.st | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st index 53f69fea0..7755fa651 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLExporterTest.class.st @@ -41,7 +41,7 @@ MicHTMLExporterTest >> newLine: aNewLine [ { #category : 'tests - paragraph' } MicHTMLExporterTest >> newLines: aString [ - ^ newLine, aString, newLine + ^ newLine, '

', aString, '

', newLine ] { #category : 'utilities' } @@ -294,14 +294,12 @@ MicHTMLExporterTest >> testParagraphWithMonospace [ { #category : 'tests - paragraph' } MicHTMLExporterTest >> testPharoPage [ - self parse: self pharoPage andCheckWeGet: ' -

Pharo

-Pharo is a beautiful dynamically-typed reflective pure object-oriented language that we have been developing since 2008.
It is inspired by Smalltalk (I''m extremely grateful to Alan Kay and Dan Ingalls - they were so visionary and right). Now our vision for Pharo is to reinvent Smalltalk and produce a better system.
From that perspective, I''m used to say that Pharo is what we have and not what we want.
In essence, Pharo is the beginning of the journey and not the final goal. And you can change its future. + self parse: self pharoPage andCheckWeGet: newLine, '

Pharo

', newLine, +'

Pharo is a beautiful dynamically-typed reflective pure object-oriented language that we have been developing since 2008.
It is inspired by Smalltalk (I''m extremely grateful to Alan Kay and Dan Ingalls - they were so visionary and right). Now our vision for Pharo is to reinvent Smalltalk and produce a better system.
From that perspective, I''m used to say that Pharo is what we have and not what we want.
In essence, Pharo is the beginning of the journey and not the final goal. And you can change its future.

', newLine, newLine, -You can check what companies are saying about it: Video +'

You can check what companies are saying about it: Video

', newLine, newLine, -There are many aspects I would like to see being explored either by us or by others.
If you want to explore some of the following aspects, please go and let us know.
I''m really interested in any topics that evolve Pharo into a better Pharo. -' +'

There are many aspects I would like to see being explored either by us or by others.
If you want to explore some of the following aspects, please go and let us know.
I''m really interested in any topics that evolve Pharo into a better Pharo.

', newLine ] { #category : 'tests - formats' } diff --git a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st index b989d7ab4..f963f2ba0 100644 --- a/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st +++ b/src/Microdown-HTMLExporter-Tests/MicHTMLVisitorTest.class.st @@ -234,20 +234,19 @@ MicHTMLVisitorTest >> testRawParagraphDivWithArgsAndNested [ '

', newLine, '
'. - result := writer convertMicString: source. self assert: result trimBoth equals: '
', newLine, -'

', -'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this', newLine, newLine, +'

', +'We use the <div> tag to group two paragraphs for applying a background to the text, and to add color to this

', newLine, newLine, '', newLine, -'word', newLine, newLine, +'

word

', newLine, newLine, '
', newLine, -'we place it within <span> tag.', +'

we place it within <span> tag.

', '

', newLine, newLine, '

', newLine, -'Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.', newLine, newLine, +'

Pay attention, that the <div> tag is a block-level element, so a line break is placed before and after it.

', newLine, newLine, '

', newLine, '
'. ] diff --git a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st index fa93526d5..815c40540 100644 --- a/src/Microdown-Tests/MicRawParagraphBlockTest.class.st +++ b/src/Microdown-Tests/MicRawParagraphBlockTest.class.st @@ -24,6 +24,8 @@ In a giving mood? There are many ways to get involved! ') children first. self assert: mic class equals: MicRawParagraphBlock. self assert: mic label equals: 'div'. + self assert: mic children first class equals: MicHeaderBlock. + self assert: mic children second class equals: MicParagraphBlock ] @@ -35,6 +37,7 @@ No idea what it is :) ') children first. self assert: mic class equals: MicRawParagraphBlock. self assert: mic label equals: 'title'. + self assert: mic children first class equals: MicParagraphBlock ] @@ -66,6 +69,20 @@ And after we get a paragraph') children. ] +{ #category : 'tests' } +MicRawParagraphBlockTest >> testParagrapWithP [ + | mic | + mic := (parser parse: ' +

+This is a paragraph started normally with

+

+') children first. + self assert: mic class equals: MicRawParagraphBlock. + self assert: mic label equals: 'p'. + self assert: mic children first class equals: MicParagraphBlock + +] + { #category : 'tests' } MicRawParagraphBlockTest >> testRawParagraphCanBeNested [ | children | From 73b2b345dafb45f3c21a6c08309379bdd8260721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 12 Aug 2025 18:09:40 +0200 Subject: [PATCH 49/67] commenting a bit the codeblock evaluator waiting for github issues to restart to work --- .../MicBookTesterStrategy.class.st | 22 ----------- .../MicCodeBlockTesterStrategy.class.st | 37 +++++++++++++++++++ .../MicCodeBlockValidator.class.st | 11 +++++- .../MicExampleTesterStrategy.class.st | 13 ++++++- ...lass.st => MicNullTesterStrategy.class.st} | 8 ++-- .../MicSyncTesterStrategy.class.st | 2 +- 6 files changed, 63 insertions(+), 30 deletions(-) delete mode 100644 src/Microdown-BookTester/MicBookTesterStrategy.class.st create mode 100644 src/Microdown-BookTester/MicCodeBlockTesterStrategy.class.st rename src/Microdown-BookTester/{MicBookTesterNullStrategy.class.st => MicNullTesterStrategy.class.st} (60%) diff --git a/src/Microdown-BookTester/MicBookTesterStrategy.class.st b/src/Microdown-BookTester/MicBookTesterStrategy.class.st deleted file mode 100644 index 48aa31092..000000000 --- a/src/Microdown-BookTester/MicBookTesterStrategy.class.st +++ /dev/null @@ -1,22 +0,0 @@ -Class { - #name : 'MicBookTesterStrategy', - #superclass : 'Object', - #instVars : [ - 'results' - ], - #category : 'Microdown-BookTester-Analysis', - #package : 'Microdown-BookTester', - #tag : 'Analysis' -} - -{ #category : 'hook' } -MicBookTesterStrategy class >> handleKey [ - - ^ self subclassResponsibility - -] - -{ #category : 'accessing' } -MicBookTesterStrategy >> results: aCollection [ - results := aCollection -] diff --git a/src/Microdown-BookTester/MicCodeBlockTesterStrategy.class.st b/src/Microdown-BookTester/MicCodeBlockTesterStrategy.class.st new file mode 100644 index 000000000..2f4f30119 --- /dev/null +++ b/src/Microdown-BookTester/MicCodeBlockTesterStrategy.class.st @@ -0,0 +1,37 @@ +" +I'm the root of book validation strategy. +A strategy is attached to a tag in a codeblock. + +For example, when a codeblock contains the example tag as defined below, then the CodeBlockValidator will execute the strategy associated with it (using handleKey). + +```example + +3 + 2 +>>> 5 + +``` + + +" +Class { + #name : 'MicCodeBlockTesterStrategy', + #superclass : 'Object', + #instVars : [ + 'results' + ], + #category : 'Microdown-BookTester-Analysis', + #package : 'Microdown-BookTester', + #tag : 'Analysis' +} + +{ #category : 'hook' } +MicCodeBlockTesterStrategy class >> handleKey [ + + ^ self subclassResponsibility + +] + +{ #category : 'accessing' } +MicCodeBlockTesterStrategy >> results: aCollection [ + results := aCollection +] diff --git a/src/Microdown-BookTester/MicCodeBlockValidator.class.st b/src/Microdown-BookTester/MicCodeBlockValidator.class.st index 95d98abce..114ffe012 100644 --- a/src/Microdown-BookTester/MicCodeBlockValidator.class.st +++ b/src/Microdown-BookTester/MicCodeBlockValidator.class.st @@ -1,5 +1,12 @@ " -i visit code blocks and make sure that evaluation is correct +I visit code blocks and make sure that their 'evaluation' is correct. +I generate a list of analysis results (subclasses of `MicResult`) that then will be consumed by the `MicAnalysisReportBuilder`. +This evaluation is specified by a tag. + +- 'example' tag verifies that the code is returning the expected result. +- 'sync' verifies if the code is in sync with the one in the image. + +New code block validation can easily be added by adding subclasses to `MicCodeBlockTesterStrategy`. " Class { #name : 'MicCodeBlockValidator', @@ -23,7 +30,7 @@ MicCodeBlockValidator class >> isAbstract [ { #category : 'initialization' } MicCodeBlockValidator >> collectStrategies [ - MicBookTesterStrategy allSubclasses do: [ :each | + MicCodeBlockTesterStrategy allSubclasses do: [ :each | | strat | strat := each new. strat results: results. diff --git a/src/Microdown-BookTester/MicExampleTesterStrategy.class.st b/src/Microdown-BookTester/MicExampleTesterStrategy.class.st index c392bc69d..a59c909c9 100644 --- a/src/Microdown-BookTester/MicExampleTesterStrategy.class.st +++ b/src/Microdown-BookTester/MicExampleTesterStrategy.class.st @@ -1,6 +1,17 @@ +" +I'm responsible to validate that an example in a code block is correct. + +```example +3 + 2 +>>> 5 +``` + +The checking logic should probably be improved looking at the old book tester in old Pillar. +See [PDF explaining book tester](https://github.com/pillar-markup/BookTester/tree/main/ressources/OldBookTester) +" Class { #name : 'MicExampleTesterStrategy', - #superclass : 'MicBookTesterStrategy', + #superclass : 'MicCodeBlockTesterStrategy', #category : 'Microdown-BookTester-Analysis', #package : 'Microdown-BookTester', #tag : 'Analysis' diff --git a/src/Microdown-BookTester/MicBookTesterNullStrategy.class.st b/src/Microdown-BookTester/MicNullTesterStrategy.class.st similarity index 60% rename from src/Microdown-BookTester/MicBookTesterNullStrategy.class.st rename to src/Microdown-BookTester/MicNullTesterStrategy.class.st index 435668ce5..71f78a544 100644 --- a/src/Microdown-BookTester/MicBookTesterNullStrategy.class.st +++ b/src/Microdown-BookTester/MicNullTesterStrategy.class.st @@ -2,22 +2,22 @@ When there is no tag other than none or language, does not verify the code block. " Class { - #name : 'MicBookTesterNullStrategy', - #superclass : 'MicBookTesterStrategy', + #name : 'MicNullTesterStrategy', + #superclass : 'MicCodeBlockTesterStrategy', #category : 'Microdown-BookTester-Analysis', #package : 'Microdown-BookTester', #tag : 'Analysis' } { #category : 'hook' } -MicBookTesterNullStrategy class >> handleKey [ +MicNullTesterStrategy class >> handleKey [ ^ #language ] { #category : 'main API' } -MicBookTesterNullStrategy >> verify: aMicCodeBlock [ +MicNullTesterStrategy >> verify: aMicCodeBlock [ diff --git a/src/Microdown-BookTester/MicSyncTesterStrategy.class.st b/src/Microdown-BookTester/MicSyncTesterStrategy.class.st index d2cc97934..5fd3233b6 100644 --- a/src/Microdown-BookTester/MicSyncTesterStrategy.class.st +++ b/src/Microdown-BookTester/MicSyncTesterStrategy.class.st @@ -1,6 +1,6 @@ Class { #name : 'MicSyncTesterStrategy', - #superclass : 'MicBookTesterStrategy', + #superclass : 'MicCodeBlockTesterStrategy', #category : 'Microdown-BookTester-Analysis', #package : 'Microdown-BookTester', #tag : 'Analysis' From 6a00886095cfc8a00e1fa54a85ed6c3f59187e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 12 Aug 2025 21:43:45 +0200 Subject: [PATCH 50/67] Renamed MicBookTesterVisitorTest --- ...ss.st => MicCodeBlockValitorTest.class.st} | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) rename src/Microdown-BookTester-Tests/{MicBookTesterVisitorTest.class.st => MicCodeBlockValitorTest.class.st} (81%) diff --git a/src/Microdown-BookTester-Tests/MicBookTesterVisitorTest.class.st b/src/Microdown-BookTester-Tests/MicCodeBlockValitorTest.class.st similarity index 81% rename from src/Microdown-BookTester-Tests/MicBookTesterVisitorTest.class.st rename to src/Microdown-BookTester-Tests/MicCodeBlockValitorTest.class.st index 7952601d3..693202946 100644 --- a/src/Microdown-BookTester-Tests/MicBookTesterVisitorTest.class.st +++ b/src/Microdown-BookTester-Tests/MicCodeBlockValitorTest.class.st @@ -1,12 +1,12 @@ Class { - #name : 'MicBookTesterVisitorTest', + #name : 'MicCodeBlockValitorTest', #superclass : 'TestCase', #category : 'Microdown-BookTester-Tests', #package : 'Microdown-BookTester-Tests' } { #category : 'utilities' } -MicBookTesterVisitorTest >> parseAndTest: docText [ +MicCodeBlockValitorTest >> parseAndTest: docText [ | doc bTester | doc := Microdown parse: docText. bTester := MicCodeBlockValidator new. @@ -15,7 +15,7 @@ MicBookTesterVisitorTest >> parseAndTest: docText [ ] { #category : 'tests - valid book tests' } -MicBookTesterVisitorTest >> testExampleCodeblock [ +MicCodeBlockValitorTest >> testExampleCodeblock [ | docText bTester | docText := '```example=true 3 + 4 @@ -27,7 +27,7 @@ MicBookTesterVisitorTest >> testExampleCodeblock [ ] { #category : 'tests - failing book tests' } -MicBookTesterVisitorTest >> testExampleCodeblockWithFailingTest [ +MicCodeBlockValitorTest >> testExampleCodeblockWithFailingTest [ | docText bTester | docText := '```example=true 3 + ''12'' @@ -40,7 +40,7 @@ MicBookTesterVisitorTest >> testExampleCodeblockWithFailingTest [ ] { #category : 'tests - failing book tests' } -MicBookTesterVisitorTest >> testExampleCodeblockWithFalseTest [ +MicCodeBlockValitorTest >> testExampleCodeblockWithFalseTest [ | docText bTester | docText := '```example=true @@ -54,7 +54,7 @@ MicBookTesterVisitorTest >> testExampleCodeblockWithFalseTest [ ] { #category : 'tests - failing book tests' } -MicBookTesterVisitorTest >> testExampleCodeblockWithNoBrakets [ +MicCodeBlockValitorTest >> testExampleCodeblockWithNoBrakets [ | docText bTester | docText := '```example=true @@ -68,7 +68,7 @@ MicBookTesterVisitorTest >> testExampleCodeblockWithNoBrakets [ ] { #category : 'tests - strange codeblock' } -MicBookTesterVisitorTest >> testExampleCodeblockWithTwoBrackets [ +MicCodeBlockValitorTest >> testExampleCodeblockWithTwoBrackets [ ">> instead of > > > should not work so there is one failed test" | docText bTester | @@ -83,7 +83,7 @@ MicBookTesterVisitorTest >> testExampleCodeblockWithTwoBrackets [ ] { #category : 'tests - strange codeblock' } -MicBookTesterVisitorTest >> testExampleEmptyCodeblockWithTwoBrackets [ +MicCodeBlockValitorTest >> testExampleEmptyCodeblockWithTwoBrackets [ | docText bTester | docText := '```example=true @@ -99,7 +99,7 @@ MicBookTesterVisitorTest >> testExampleEmptyCodeblockWithTwoBrackets [ ] { #category : 'tests - valid book tests' } -MicBookTesterVisitorTest >> testExpectedFailureForAFailure [ +MicCodeBlockValitorTest >> testExpectedFailureForAFailure [ | docText bTester | docText := '```example=true&expectedFailure=true 3 + 4 @@ -112,7 +112,7 @@ MicBookTesterVisitorTest >> testExpectedFailureForAFailure [ ] { #category : 'tests - valid book tests' } -MicBookTesterVisitorTest >> testExpectedFailureForARaisedException [ +MicCodeBlockValitorTest >> testExpectedFailureForARaisedException [ | docText bTester | docText := '```example=true&expectedFailure=true 3 + ''a'' @@ -125,7 +125,7 @@ MicBookTesterVisitorTest >> testExpectedFailureForARaisedException [ ] { #category : 'tests - valid book tests' } -MicBookTesterVisitorTest >> testExplanationIsExceptionCatchedInFailingTest [ +MicCodeBlockValitorTest >> testExplanationIsExceptionCatchedInFailingTest [ | docText bTester | docText := '```example=true 3 + ''12'' @@ -140,7 +140,7 @@ MicBookTesterVisitorTest >> testExplanationIsExceptionCatchedInFailingTest [ ] { #category : 'tests - valid book tests' } -MicBookTesterVisitorTest >> testExplanationIsTestFailedWithoutException [ +MicCodeBlockValitorTest >> testExplanationIsTestFailedWithoutException [ | docText bTester | docText := '```example=true @@ -155,7 +155,7 @@ MicBookTesterVisitorTest >> testExplanationIsTestFailedWithoutException [ ] { #category : 'tests - valid book tests' } -MicBookTesterVisitorTest >> testExplanationIsTestPassed [ +MicCodeBlockValitorTest >> testExplanationIsTestPassed [ | docText bTester | docText := '```example=true @@ -170,7 +170,7 @@ MicBookTesterVisitorTest >> testExplanationIsTestPassed [ ] { #category : 'tests - no example' } -MicBookTesterVisitorTest >> testNoExampleCodeblock [ +MicCodeBlockValitorTest >> testNoExampleCodeblock [ | docText bTester | docText := '``` 3 + 4 @@ -183,7 +183,7 @@ MicBookTesterVisitorTest >> testNoExampleCodeblock [ ] { #category : 'tests - no example' } -MicBookTesterVisitorTest >> testThreeCodeBlocksWithTwoExamples [ +MicCodeBlockValitorTest >> testThreeCodeBlocksWithTwoExamples [ | docText bTester | docText := From 2b8f221f8967d97f428c6045c033d1ed1eb52296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 12 Aug 2025 21:44:20 +0200 Subject: [PATCH 51/67] Change fileSystem: into rootDirectory: duh! --- .../MicReferenceCheckerTest.class.st | 2 +- .../MicAnalysisReportWriter.class.st | 19 ++++++++++++ .../MicCodeBlockValidator.class.st | 30 ++++++++++++++++++- .../MicReferenceChecker.class.st | 4 +-- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st b/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st index de434de30..915d0a8f2 100644 --- a/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st +++ b/src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st @@ -16,7 +16,7 @@ Class { #package : 'Microdown-BookTester-Tests' } -{ #category : 'as yet unclassified' } +{ #category : 'helpers - anchors & references' } MicReferenceCheckerTest >> anchorNames: checker [ ^ checker results diff --git a/src/Microdown-BookTester/MicAnalysisReportWriter.class.st b/src/Microdown-BookTester/MicAnalysisReportWriter.class.st index e8111e53d..a08c991ad 100644 --- a/src/Microdown-BookTester/MicAnalysisReportWriter.class.st +++ b/src/Microdown-BookTester/MicAnalysisReportWriter.class.st @@ -12,6 +12,25 @@ Class { #tag : 'Analysis' } +{ #category : 'instance creation' } +MicAnalysisReportWriter class >> reportForFolder: parent startingFrom: file [ + + | reporter checker validator | + reporter := self new. + + checker := MicReferenceChecker new. + checker fileSystem: parent. + checker checkProject: file. + + reporter addResults: checker results. + + validator := MicCodeBlockValidator new. + checker fileSystem: parent. + checker checkProject: file. + + reporter addResults: validator results +] + { #category : 'adding' } MicAnalysisReportWriter >> addResults: aCollection [ diff --git a/src/Microdown-BookTester/MicCodeBlockValidator.class.st b/src/Microdown-BookTester/MicCodeBlockValidator.class.st index 114ffe012..8a39ae253 100644 --- a/src/Microdown-BookTester/MicCodeBlockValidator.class.st +++ b/src/Microdown-BookTester/MicCodeBlockValidator.class.st @@ -14,7 +14,8 @@ Class { #instVars : [ 'strategies', 'results', - 'reportWriter' + 'reportWriter', + 'rootDirectory' ], #category : 'Microdown-BookTester-Analysis', #package : 'Microdown-BookTester', @@ -27,6 +28,19 @@ MicCodeBlockValidator class >> isAbstract [ ^ false ] +{ #category : 'main API' } +MicCodeBlockValidator >> checkProject: aFileReference [ + + | mainMic collector | + mainMic := Microdown parseFile: aFileReference. + collector := MicFileCollector new. + collector + rootDirectory: rootDirectory; + visit: mainMic. + collector visitedFiles do: [ :each | self start: each ]. + +] + { #category : 'initialization' } MicCodeBlockValidator >> collectStrategies [ @@ -43,6 +57,14 @@ MicCodeBlockValidator >> failedTests [ ^ results select: [ :each | each isFailed ] ] +{ #category : 'accessing' } +MicCodeBlockValidator >> fileSystem: aFileReference [ + + self deprecated: 'use rootDirectory' + transformWith: '`@receiver fileSystem: `@arg' -> '`@receiver rootDirectory: `@arg'. + self rootDirectory: aFileReference. +] + { #category : 'initialization' } MicCodeBlockValidator >> initialize [ @@ -84,6 +106,12 @@ MicCodeBlockValidator >> results: anObject [ results := anObject ] +{ #category : 'accessing' } +MicCodeBlockValidator >> rootDirectory: aFileReference [ + + rootDirectory := aFileReference +] + { #category : 'accessing' } MicCodeBlockValidator >> start: anObject [ anObject accept: self diff --git a/src/Microdown-BookTester/MicReferenceChecker.class.st b/src/Microdown-BookTester/MicReferenceChecker.class.st index 7b88031cc..178469d9a 100644 --- a/src/Microdown-BookTester/MicReferenceChecker.class.st +++ b/src/Microdown-BookTester/MicReferenceChecker.class.st @@ -262,9 +262,9 @@ MicReferenceChecker >> results: anObject [ ] { #category : 'accessing' } -MicReferenceChecker >> rootDirectory: aFileReferemce [ +MicReferenceChecker >> rootDirectory: aFileReference [ - rootDirectory := aFileReferemce + rootDirectory := aFileReference ] { #category : 'internal' } From d0c970678c8851db6e9f6a5d8d94f1ab7b17b083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 12 Aug 2025 22:25:57 +0200 Subject: [PATCH 52/67] Just better parameter names - does not hurt! --- .../MicAnalysisReportWriter.class.st | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microdown-BookTester/MicAnalysisReportWriter.class.st b/src/Microdown-BookTester/MicAnalysisReportWriter.class.st index a08c991ad..4ab66b99f 100644 --- a/src/Microdown-BookTester/MicAnalysisReportWriter.class.st +++ b/src/Microdown-BookTester/MicAnalysisReportWriter.class.st @@ -13,20 +13,20 @@ Class { } { #category : 'instance creation' } -MicAnalysisReportWriter class >> reportForFolder: parent startingFrom: file [ +MicAnalysisReportWriter class >> reportForFolder: folderReference startingFrom: fileReference [ | reporter checker validator | reporter := self new. checker := MicReferenceChecker new. - checker fileSystem: parent. - checker checkProject: file. + checker fileSystem: folderReference. + checker checkProject: fileReference. reporter addResults: checker results. validator := MicCodeBlockValidator new. - checker fileSystem: parent. - checker checkProject: file. + checker fileSystem: folderReference. + checker checkProject: fileReference. reporter addResults: validator results ] From 3f7097af7d997e846c87b28ba03951e031c51327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Tue, 12 Aug 2025 22:27:50 +0200 Subject: [PATCH 53/67] Return the reporter. --- src/Microdown-BookTester/MicAnalysisReportWriter.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microdown-BookTester/MicAnalysisReportWriter.class.st b/src/Microdown-BookTester/MicAnalysisReportWriter.class.st index 4ab66b99f..e98dd3aa8 100644 --- a/src/Microdown-BookTester/MicAnalysisReportWriter.class.st +++ b/src/Microdown-BookTester/MicAnalysisReportWriter.class.st @@ -28,7 +28,8 @@ MicAnalysisReportWriter class >> reportForFolder: folderReference startingFrom: checker fileSystem: folderReference. checker checkProject: fileReference. - reporter addResults: validator results + reporter addResults: validator results. + ^ reporter ] { #category : 'adding' } From 81a217ed71ef968107ea16af42de7352b0345dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 15 Aug 2025 10:52:31 +0200 Subject: [PATCH 54/67] Fixing inspector extension :( --- src/Microdown-Pharo-Tools/MicElement.extension.st | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Microdown-Pharo-Tools/MicElement.extension.st b/src/Microdown-Pharo-Tools/MicElement.extension.st index 14a675813..1445312a0 100644 --- a/src/Microdown-Pharo-Tools/MicElement.extension.st +++ b/src/Microdown-Pharo-Tools/MicElement.extension.st @@ -14,3 +14,18 @@ Yes microdown is cool') inspect String streamContents: [ :stream | each displayStringOn: stream ] ]; yourself ] + +{ #category : '*Microdown-Pharo-Tools' } +MicElement >> inspectionMicTree: aBuilder [ + " + (MicroDownParser parse: '# hello +Yes microdown is cool') inspect + " + + ^ aBuilder newTree + roots: { self }; + children: [ :aNode | aNode children ]; + display: [ :each | + String streamContents: [ :stream | each displayStringOn: stream ] ]; + yourself +] From e52a2a3ba881c32f15c00b795077a1c583915d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 15 Aug 2025 17:21:25 +0200 Subject: [PATCH 55/67] Adding a simple debugId into MicRootElement to help debugging. --- src/Microdown-Tests/MicRootBlockTest.class.st | 12 +++++ src/Microdown/MicRootBlock.class.st | 50 +++++++++++++++++++ src/Microdown/Microdown.class.st | 3 +- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/Microdown-Tests/MicRootBlockTest.class.st b/src/Microdown-Tests/MicRootBlockTest.class.st index d11ce66d9..d6262d044 100644 --- a/src/Microdown-Tests/MicRootBlockTest.class.st +++ b/src/Microdown-Tests/MicRootBlockTest.class.st @@ -24,6 +24,18 @@ MicRootBlockTest >> testRootCanConsumeLine [ self assert: (rootNode canConsumeLine: '- ') ] +{ #category : 'tests' } +MicRootBlockTest >> testRootDebugInfo [ + + | rootNode first | + MicRootBlock resetDebugId. + first := MicRootBlock nextDebugId. + rootNode := MicRootBlock new. + self assert: rootNode debugId equals: first + 1. + rootNode := MicRootBlock new. + self assert: rootNode debugId equals: first + 2. +] + { #category : 'tests - metadata' } MicRootBlockTest >> testRootDoesNotHaveMetaDataElement [ diff --git a/src/Microdown/MicRootBlock.class.st b/src/Microdown/MicRootBlock.class.st index 146a8167b..7d8affe28 100644 --- a/src/Microdown/MicRootBlock.class.st +++ b/src/Microdown/MicRootBlock.class.st @@ -4,11 +4,34 @@ I am the root of the markup tree. Class { #name : 'MicRootBlock', #superclass : 'MicAbstractBlock', + #instVars : [ + 'debugId' + ], + #classVars : [ + 'DebugId' + ], + #classInstVars : [ + 'debugId' + ], #category : 'Microdown-Model', #package : 'Microdown', #tag : 'Model' } +{ #category : 'accessing' } +MicRootBlock class >> nextDebugId [ + + DebugId ifNil: [ DebugId := 0]. + DebugId := DebugId + 1. + ^ DebugId +] + +{ #category : 'accessing' } +MicRootBlock class >> resetDebugId [ + + DebugId := 0 +] + { #category : 'visiting' } MicRootBlock >> accept: aVisitor [ ^ aVisitor visitRoot: self @@ -32,6 +55,17 @@ MicRootBlock >> canConsumeLine: line [ ^ true ] +{ #category : 'debugging' } +MicRootBlock >> debugId [ + ^ debugId +] + +{ #category : 'debugging' } +MicRootBlock >> debugIdGenerator [ + + ^ self class nextDebugId +] + { #category : 'accessing' } MicRootBlock >> fromFile [ ^ self propertyAt: #file ifAbsent: [ 'fakedFile' ] @@ -67,6 +101,13 @@ MicRootBlock >> indent [ ^0 ] +{ #category : 'initialization' } +MicRootBlock >> initialize [ + + super initialize. + debugId := self class nextDebugId. +] + { #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." @@ -81,6 +122,15 @@ MicRootBlock >> metaDataElement [ ^ children first ] +{ #category : 'printing' } +MicRootBlock >> printOn: aStream [ + + super printOn: aStream. + debugId ifNotNil: [ + aStream << '[ id:'; <> properties: aConfigurationForPillar [ "Pay attention the strong hypothesis here is that keys of microdown properties and pillar configuration should not overlap. A possible solution would be to have clever at: and at:put: that check for example for a prefix for microdown properties. diff --git a/src/Microdown/Microdown.class.st b/src/Microdown/Microdown.class.st index 509de398f..530ff3afb 100644 --- a/src/Microdown/Microdown.class.st +++ b/src/Microdown/Microdown.class.st @@ -153,8 +153,9 @@ Microdown >> parse: aStreamOrString [ { #category : 'facade' } Microdown >> parseFile: aFile [ + "Parse and return a document from the argument marking it with the file it is contained in. This is important for path resolution." - |root| + | root | root := MicrodownParser parse: aFile contents. root fromFile: aFile. ^ root From 27d85457fa57d6f8beec5f3de462aa2f7e36be9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 15 Aug 2025 17:21:52 +0200 Subject: [PATCH 56/67] Formatting code --- src/Microdown/MicZincPathResolver.class.st | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microdown/MicZincPathResolver.class.st b/src/Microdown/MicZincPathResolver.class.st index b5c1edbd0..7c053dbf1 100644 --- a/src/Microdown/MicZincPathResolver.class.st +++ b/src/Microdown/MicZincPathResolver.class.st @@ -38,6 +38,7 @@ MicZincPathResolver class >> resolve: document withBase: aRef [ { #category : 'accessing' } MicZincPathResolver >> absoluteReference: aReferenceOrString [ + absoluteReference := aReferenceOrString isString ifTrue: [ MicResourceReference fromUri: aReferenceOrString ] ifFalse: [ aReferenceOrString ] @@ -45,17 +46,20 @@ MicZincPathResolver >> absoluteReference: aReferenceOrString [ { #category : 'visiting' } MicZincPathResolver >> resolveDocument: document [ + self visit: document ] { #category : 'private' } MicZincPathResolver >> resolveReferenceIn: aNode [ "currently links, figures and input nodes need to be resolved" + | resolvedUri resolvedReference | aNode reference isRelative ifFalse: [ ^ self ]. resolvedUri := absoluteReference uri withRelativeReference: aNode reference relativePath. resolvedReference := MicResourceReference fromUri: resolvedUri printString. - resolvedReference isMicrodownResourceFileReference ifTrue: [ resolvedReference fileSystem: absoluteReference fileSystem ]. + resolvedReference isMicrodownResourceFileReference + ifTrue: [ resolvedReference fileSystem: absoluteReference fileSystem ]. aNode reference: resolvedReference ] @@ -68,11 +72,11 @@ MicZincPathResolver >> visitFigure: aFigure [ { #category : 'visiting' } MicZincPathResolver >> visitInputFile: anInputFile [ - self resolveReferenceIn: anInputFile ] { #category : 'visiting' } MicZincPathResolver >> visitLink: aLink [ + self resolveReferenceIn: aLink ] From f342823bc13c872227a6639f5816e432190ce035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 15 Aug 2025 17:22:54 +0200 Subject: [PATCH 57/67] introduce better API to MicFileIncluder --- .../MicFileIncluder.class.st | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/Microdown-Transformer/MicFileIncluder.class.st b/src/Microdown-Transformer/MicFileIncluder.class.st index 5c79aaaa8..176cc82ac 100644 --- a/src/Microdown-Transformer/MicFileIncluder.class.st +++ b/src/Microdown-Transformer/MicFileIncluder.class.st @@ -37,17 +37,47 @@ Class { #package : 'Microdown-Transformer' } -{ #category : 'initialization' } +{ #category : 'accessing' } MicFileIncluder >> beRelaxed [ isStrict := false ] +{ #category : 'validation' } +MicFileIncluder >> checkCyclicIncludeOfFile: aFileReference [ + + aFileReference = topFile ifTrue: [ + MicCyclicFileInclusionError new + files: { topFile }; + signal + ]. + + (inProcessFiles includes: aFileReference) + ifTrue: [ MicCyclicFileInclusionError new + files: (inProcessFiles copyWith: aFileReference); + signal ] +] + { #category : 'configuration' } MicFileIncluder >> doNotTransform [ shouldTransform := false ] +{ #category : 'accessing' } +MicFileIncluder >> expandAllInputOf: ast [ + "The argument should know the file it comes from. Usually using fromFile:, or using the topFile: API. + This is important since we need to resolve the path using such an information." + + | path | + path := ast fromFile = 'fakedFile' + ifTrue: [ path := topFile ] + ifFalse: [path := ast fromFile]. + path ifNil: [ self error: 'base is not set for resolution. Please use either parseFile: or topFile: to specificy a file reference' ]. + path asMicResourceReference resolveDocument: ast. + self visit: ast. + +] + { #category : 'accessing' } MicFileIncluder >> inProcessFiles: aCollection [ inProcessFiles := aCollection @@ -74,23 +104,9 @@ MicFileIncluder >> shouldTransform [ { #category : 'accessing' } MicFileIncluder >> topFile: aFileReference [ - - topFile := aFileReference -] - -{ #category : 'validation' } -MicFileIncluder >> validateInclusionOfFile: aFileReference [ + "You may use this API if the document was not created using parseFile: or that its fromFile is empty." - aFileReference = topFile ifTrue: [ - MicCyclicFileInclusionError new - files: { topFile }; - signal - ]. - - (inProcessFiles includes: aFileReference) - ifTrue: [ MicCyclicFileInclusionError new - files: (inProcessFiles copyWith: aFileReference); - signal ] + topFile := aFileReference ] { #category : 'visiting-document' } @@ -104,6 +120,7 @@ MicFileIncluder >> visitInputFile: anInputFileAnnotation [ do: [ :error | isStrict ifFalse: [ ^ self ] ifTrue: [ error pass ]]. + self replaceCurrentNodeBy: inputDoc children ] From 12ef258995f0f7643cd3ebfb7e69263bd69fe372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 15 Aug 2025 17:24:00 +0200 Subject: [PATCH 58/67] Introduce a better API to latex writer to input all files before generating LaTeX --- src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st b/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st index a124a6110..c953b602e 100644 --- a/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st +++ b/src/Microdown-LaTeXExporter/MicLaTeXWriter.class.st @@ -85,6 +85,17 @@ MicLaTeXWriter >> getStringForAll: aCollection [ ^ visitor contents ] +{ #category : 'public api' } +MicLaTeXWriter >> includeFilesAndVisit: ast [ + "Includes all the input file and convert to LaTeX the resulting document. + Note that to be correctly included the file includer requires ast to know their fromFile. + Please use parseFile: to correctly set that information or set it manually." + + MicFileIncluder new expandAllInputOf: ast. + self visit: ast. + ^ self contents +] + { #category : 'visiting-document' } MicLaTeXWriter >> includeGraphicsFor: aFigure [ From c6db80745d68a472c0fff2ac7950b464d26f186e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Fri, 15 Aug 2025 18:06:36 +0200 Subject: [PATCH 59/67] remove write: specialization since pillar already does it. --- .../MicDocumentWriter.class.st | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Microdown-LaTeXExporter/MicDocumentWriter.class.st b/src/Microdown-LaTeXExporter/MicDocumentWriter.class.st index e81d7d802..1a8ac12c3 100644 --- a/src/Microdown-LaTeXExporter/MicDocumentWriter.class.st +++ b/src/Microdown-LaTeXExporter/MicDocumentWriter.class.st @@ -70,7 +70,19 @@ MicDocumentWriter >> visit: aMicElement [ { #category : 'writing' } MicDocumentWriter >> write: aMicElement [ - "for now for integration with Pillar." + "Pillar API. + Notice that Pillar is doing the resolution of paths before calling write: + + So there is no need to define write: to call such explicit phase + as includeFilesAndVisit: does it + + includeFilesAndVisit: ast + MicFileIncluder new expandAllInputOf: ast. + self visit: ast. + ^ self contents + + " + self visit: aMicElement. ^ self contents ] From 52bcc012245e7bfefb390fdc655d26dc8651df3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 16 Aug 2025 14:47:03 +0200 Subject: [PATCH 60/67] Creating a new group. --- .../BaselineOfMicrodown.class.st | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index f4ed3860b..1819370ae 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -19,15 +19,9 @@ BaselineOfMicrodown >> baseline: spec [ xmlParserHtml: spec; mustache: spec; gitBridge: spec. - " I disable this because against all my best effort, I cannot avoid the fucking pop up to raise - even if I unload all the packages. I get the Microdown-RichTextComposer in conflict." - + spec preLoadDoIt: #'preload:package:'. - - - "I disable this because in a postload - (IceRepository repositoryNamed: 'microdown') is nil and I do not get why" - + spec postLoadDoIt: #'postload:package:'. spec @@ -43,6 +37,7 @@ BaselineOfMicrodown >> baseline: spec [ package: #'Microdown-RichTextComposer' with: [ spec requires: #( #Microdown ) ]; + package: #'Microdown-RichTextComposer-Tests' with: [ spec requires: #( #'Microdown-RichTextComposer' ) ]; @@ -65,12 +60,13 @@ BaselineOfMicrodown >> baseline: spec [ with: [ spec requires: #( #'Microdown-HTMLExporter' 'Microdown-Tests' 'XMLParserHTML') ]; package: #'Microdown-LaTeXExporter' - with: [ spec requires: #( #Microdown ) ]; + with: [ spec requires: #( #Microdown ) ]; package: #'Microdown-LaTeXExporter-Tests' with: [ spec requires: #( #'Microdown-LaTeXExporter' #'Microdown-Tests') ]; - + package: #'Microdown-BeamerExporter' with: [ spec requires: #( #'Microdown-LaTeXExporter' ) ]; + package: #'Microdown-BeamerExporter-Tests' with: [ spec requires: #( #'Microdown-LaTeXExporter-Tests') ]; @@ -95,10 +91,10 @@ BaselineOfMicrodown >> baseline: spec [ "I do not want group without tests for now" spec - group: 'Core' with: #('Microdown'); + group: 'Core' with: #('Microdown' 'Microdown-Tests'); group: 'ForPharo' with: #('Microdown' #'Microdown-BrowserExtensions'); - group: 'Tests' with: #('Core' 'Microdown-Tests'); group: 'RichText' with: #('Core' 'Microdown-RichTextComposer' ); + group: 'LaTeX' with: #('Core' #'Microdown-LaTeXExporter' #'Microdown-LaTeXExporter-Tests'); group: 'Extensions' with: #( #'Microdown-Evaluator' #'Microdown-Evaluator-Tests' @@ -115,9 +111,15 @@ BaselineOfMicrodown >> baseline: spec [ #'Microdown-BookTester-Tests' #'Microdown-Blog' #'Microdown-Blog-Tests' - ); - group: 'All' with: #('Core' #'Microdown-BrowserExtensions' 'Tests' 'Extensions' 'Microdown-Pharo-Tools' 'RichText') ] + group: 'All' with: #('Core' #'Microdown-BrowserExtensions' 'LaTeX' 'Extensions' 'Microdown-Pharo-Tools' 'RichText') + ] + + + + + + ] { #category : 'baselines' } From a1a8879dd4213627ce7c0a3807327bae1846e771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sat, 16 Aug 2025 14:58:45 +0200 Subject: [PATCH 61/67] Adding explicitly group for editor --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index 1819370ae..cccaefc7d 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -94,6 +94,8 @@ BaselineOfMicrodown >> baseline: spec [ group: 'Core' with: #('Microdown' 'Microdown-Tests'); group: 'ForPharo' with: #('Microdown' #'Microdown-BrowserExtensions'); group: 'RichText' with: #('Core' 'Microdown-RichTextComposer' ); + group: 'Editor' with: #('RichText' #'Microdown-PrettyPrinter' + #'Microdown-PrettyPrinter-Tests'); group: 'LaTeX' with: #('Core' #'Microdown-LaTeXExporter' #'Microdown-LaTeXExporter-Tests'); group: 'Extensions' with: #( #'Microdown-Evaluator' From 3861121f456ab3ab2d34311b9fc7911f399b71bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sun, 17 Aug 2025 17:00:16 +0200 Subject: [PATCH 62/67] working on the templated writer --- .../MicAbstractOutputDocumentMaker.class.st | 8 +- .../MicLaTeXMaker.class.st | 18 --- .../MicTemplatedWriter.class.st | 119 +++++++----------- .../MicTemplatedWriterTest.class.st | 80 ++++++------ src/Microdown/MicRawParagraphBlock.class.st | 4 +- src/Microdown/MyLog.class.st | 30 ++++- 6 files changed, 127 insertions(+), 132 deletions(-) delete mode 100644 src/Microdown-Templated/MicLaTeXMaker.class.st diff --git a/src/Microdown-Templated/MicAbstractOutputDocumentMaker.class.st b/src/Microdown-Templated/MicAbstractOutputDocumentMaker.class.st index 4c4253843..cf8d0a634 100644 --- a/src/Microdown-Templated/MicAbstractOutputDocumentMaker.class.st +++ b/src/Microdown-Templated/MicAbstractOutputDocumentMaker.class.st @@ -29,10 +29,16 @@ MicAbstractOutputDocumentMaker >> basicWriter [ ^ self subclassResponsibility ] +{ #category : 'accessing' } +MicAbstractOutputDocumentMaker >> pathString [ + + ^ Path * '_support' / 'templates' +] + { #category : 'accessing' } MicAbstractOutputDocumentMaker >> templateDirectory [ - ^ self baseDirectory / '_support' / 'templates' / self writer folderName + ^ self baseDirectory / self writer folderName ] { #category : 'accessing' } diff --git a/src/Microdown-Templated/MicLaTeXMaker.class.st b/src/Microdown-Templated/MicLaTeXMaker.class.st deleted file mode 100644 index ea0f790bd..000000000 --- a/src/Microdown-Templated/MicLaTeXMaker.class.st +++ /dev/null @@ -1,18 +0,0 @@ -Class { - #name : 'MicLaTeXMaker', - #superclass : 'MicAbstractOutputDocumentMaker', - #category : 'Microdown-Templated', - #package : 'Microdown-Templated' -} - -{ #category : 'accessing' } -MicLaTeXMaker >> basicWriter [ - - ^ MicLaTeXWriter new -] - -{ #category : 'accessing' } -MicLaTeXMaker >> extension [ - - ^ 'tex' -] diff --git a/src/Microdown-Templated/MicTemplatedWriter.class.st b/src/Microdown-Templated/MicTemplatedWriter.class.st index 7ae2fcad4..8a8ced55a 100644 --- a/src/Microdown-Templated/MicTemplatedWriter.class.st +++ b/src/Microdown-Templated/MicTemplatedWriter.class.st @@ -1,9 +1,9 @@ " -I am a pillar document writer that wraps a normal wrapper. +I am document writer that wraps a default writer. When writing one element, I first check if there is a file in the current template that overrides the default writing. If so, I use that file to template the contents. -Otherwise I simply delegate the writing to the wrapped one. +Otherwise I simply delegate the writing to the default one. -I am carefully designed so if an element X is delegated to the wrapped writer, it should delegate the writing of X's children back to myself. +I am carefully designed so if an element X is delegated to the default writer, it should delegate the writing of X's children back to myself. " Class { #name : 'MicTemplatedWriter', @@ -31,7 +31,7 @@ MicTemplatedWriter class >> boldTemplateFileName [ { #category : 'templates' } MicTemplatedWriter class >> codeBlockTemplateFileName [ - + ^ 'codeBlock.mustache' ] @@ -41,12 +41,6 @@ MicTemplatedWriter class >> commentedLineTemplateFileName [ ^ 'commentedLine.mustache' ] -{ #category : 'templates' } -MicTemplatedWriter class >> dataItemTemplateFileName [ - - ^ 'dataItem.mustache' -] - { #category : 'templates' } MicTemplatedWriter class >> defaultAnnotatedParagraphTemplateFileName [ @@ -84,9 +78,9 @@ MicTemplatedWriter class >> headerTemplateFileName [ ] { #category : 'templates' } -MicTemplatedWriter class >> horizontalRuleTemplateFileName [ +MicTemplatedWriter class >> horizontalLineTemplateFileName [ - ^ 'horizontalRule.mustache' + ^ 'horizontalLine.mustache' ] { #category : 'templates' } @@ -197,12 +191,6 @@ MicTemplatedWriter >> currentEnvironmentPath [ ^ RelativePath withAll: (environmentStack collect: [:each | each name]) reversed ] -{ #category : 'accessing - templates' } -MicTemplatedWriter >> dataItemTemplateFileName [ - - ^ self class dataItemTemplateFileName -] - { #category : 'accessing - templates' } MicTemplatedWriter >> defaultAnnotatedParagraphTemplateFileName [ @@ -261,9 +249,9 @@ MicTemplatedWriter >> headerTemplateFileName [ ] { #category : 'accessing - templates' } -MicTemplatedWriter >> horizontalRuleTemplateFileName [ +MicTemplatedWriter >> horizontalLineTemplateFileName [ - ^ self class horizontalRuleTemplateFileName + ^ self class horizontalLineTemplateFileName ] { #category : 'initialization' } @@ -367,7 +355,7 @@ MicTemplatedWriter >> unorderedListTemplateFileName [ ^ self class unorderedListTemplateFileName ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitAnchor: aPRAnchor [ self @@ -377,7 +365,7 @@ MicTemplatedWriter >> visitAnchor: aPRAnchor [ ifAbsent: [ defaultWriter visitAnchor: aPRAnchor ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitAnnotatedParagraph: anAnnotatedParagraph [ | arguments | @@ -395,7 +383,7 @@ MicTemplatedWriter >> visitAnnotatedParagraph: anAnnotatedParagraph [ ] { #category : 'visiting' } -MicTemplatedWriter >> visitBoldFormat: aPRBoldFormat [ +MicTemplatedWriter >> visitBold: aPRBoldFormat [ self write: aPRBoldFormat @@ -404,16 +392,16 @@ MicTemplatedWriter >> visitBoldFormat: aPRBoldFormat [ ] { #category : 'visiting' } -MicTemplatedWriter >> visitCodeblock: aPRCodeblock [ - +MicTemplatedWriter >> visitCode: aCodeBlock [ + self - writeRawText: aPRCodeblock text + writeRawText: aCodeBlock body withTemplateFileName: self codeBlockTemplateFileName - extraArguments: { 'language' -> (defaultWriter languageForScript: aPRCodeblock) } - ifAbsent: [ defaultWriter visitCodeblock: aPRCodeblock ] + extraArguments: { 'language' -> defaultWriter class name } + ifAbsent: [ defaultWriter visitCode: aCodeBlock ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitCommentedLine: aPRText [ self @@ -422,16 +410,7 @@ MicTemplatedWriter >> visitCommentedLine: aPRText [ ifAbsent: [ defaultWriter visitCommentedLine: aPRText ] ] -{ #category : 'visiting' } -MicTemplatedWriter >> visitDataItem: aPRListItem [ - - self - write: aPRListItem - withTemplateFileName: self dataItemTemplateFileName - ifAbsent: [ defaultWriter visitDataItem: aPRListItem ] -] - -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitDefinitionList: aPRList [ self @@ -440,7 +419,7 @@ MicTemplatedWriter >> visitDefinitionList: aPRList [ ifAbsent: [ defaultWriter visitDefinitionList: aPRList ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitEmptyParagraph: anEmptyParagraph [ self @@ -449,7 +428,7 @@ MicTemplatedWriter >> visitEmptyParagraph: anEmptyParagraph [ ifAbsent: [ defaultWriter visitEmptyParagraph: anEmptyParagraph ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitEnvironment: anEnvironment [ self pushEnvironment: anEnvironment. @@ -461,16 +440,6 @@ MicTemplatedWriter >> visitEnvironment: anEnvironment [ self popEnvironment. ] -{ #category : 'visiting' } -MicTemplatedWriter >> visitExternalLink: aPRExternalLink [ - - self - write: aPRExternalLink - withTemplateFileName: self externalLinkTemplateFileName - extraArguments: { 'reference' -> aPRExternalLink reference } - ifAbsent: [ defaultWriter visitExternalLink: aPRExternalLink ] -] - { #category : 'visiting' } MicTemplatedWriter >> visitFigure: aFigure [ @@ -493,8 +462,8 @@ MicTemplatedWriter >> visitHeader: aHeader [ ifAbsent: [ defaultWriter visitHeader: aHeader ] ] -{ #category : 'visiting' } -MicTemplatedWriter >> visitHorizontalRule: aPRHorizontalRule [ +{ #category : 'old visiting' } +MicTemplatedWriter >> visitHorizontalLine: aPRHorizontalRule [ self writeRawText: '' @@ -502,17 +471,25 @@ MicTemplatedWriter >> visitHorizontalRule: aPRHorizontalRule [ ifAbsent: [ defaultWriter visitHorizontalRule: aPRHorizontalRule ] ] -{ #category : 'visiting' } -MicTemplatedWriter >> visitInternalLink: aPRInternalLink [ +{ #category : 'old visiting' } +MicTemplatedWriter >> visitHorizontalRule: aPRHorizontalRule [ self - write: aPRInternalLink - withTemplateFileName: self internalLinkTemplateFileName - extraArguments: { 'reference' -> aPRInternalLink reference } - ifAbsent: [ defaultWriter visitInternalLink: aPRInternalLink ] + writeRawText: '' + withTemplateFileName: self horizontalRuleTemplateFileName + ifAbsent: [ defaultWriter visitHorizontalRule: aPRHorizontalRule ] ] { #category : 'visiting' } +MicTemplatedWriter >> visitItalic: aPRItalicFormat [ + + self + write: aPRItalicFormat + withTemplateFileName: self italicTemplateFileName + ifAbsent: [ defaultWriter visitItalicFormat: aPRItalicFormat ] +] + +{ #category : 'old visiting' } MicTemplatedWriter >> visitItalicFormat: aPRItalicFormat [ self @@ -521,7 +498,7 @@ MicTemplatedWriter >> visitItalicFormat: aPRItalicFormat [ ifAbsent: [ defaultWriter visitItalicFormat: aPRItalicFormat ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitLineBreak: aPRLineBreak [ self @@ -530,7 +507,7 @@ MicTemplatedWriter >> visitLineBreak: aPRLineBreak [ ifAbsent: [ defaultWriter visitLineBreak: aPRLineBreak ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitListItem: aPRListItem [ self @@ -539,7 +516,7 @@ MicTemplatedWriter >> visitListItem: aPRListItem [ ifAbsent: [ defaultWriter visitListItem: aPRListItem ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitMailLink: aPRMailLink [ self @@ -549,16 +526,16 @@ MicTemplatedWriter >> visitMailLink: aPRMailLink [ ifAbsent: [ defaultWriter visitExternalLink: aPRMailLink ] ] -{ #category : 'visiting' } -MicTemplatedWriter >> visitMonospaceFormat: aPRMonospaceFormat [ +{ #category : 'old visiting' } +MicTemplatedWriter >> visitMonospace: aPRMonospaceFormat [ self write: aPRMonospaceFormat withTemplateFileName: self monospaceTemplateFileName - ifAbsent: [ defaultWriter visitMonospaceFormat: aPRMonospaceFormat ] + ifAbsent: [ defaultWriter visitMonospace: aPRMonospaceFormat ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitOrderedList: aPROrderedList [ self @@ -567,7 +544,7 @@ MicTemplatedWriter >> visitOrderedList: aPROrderedList [ ifAbsent: [ defaultWriter visitOrderedList: aPROrderedList ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitParagraph: aParagraph [ self @@ -576,7 +553,7 @@ MicTemplatedWriter >> visitParagraph: aParagraph [ ifAbsent: [ defaultWriter visitParagraph: aParagraph ] ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitPreformatted: aPRPreformatted [ self @@ -591,7 +568,7 @@ MicTemplatedWriter >> visitRaw: aPRRaw [ defaultWriter visitRaw: aPRRaw ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitSection: aPRSection [ self @@ -606,7 +583,7 @@ MicTemplatedWriter >> visitText: aPRText [ defaultWriter visitText: aPRText ] -{ #category : 'visiting' } +{ #category : 'old visiting' } MicTemplatedWriter >> visitUnorderedList: aPRUnorderedList [ self @@ -662,7 +639,7 @@ MicTemplatedWriter >> writeRawText: aText withTemplateFileName: templateFileName templateFile := outputDocument templateDirectory resolve: foundPath / templateFileName. result := templateFile asMustacheTemplate value: ({ 'contents' -> aText value }, arguments) asDictionary. - self visitRaw: (PRRaw content: result type: defaultWriter writerName) + self visitText: (MicTextBlock new bodyString: result) ] { #category : 'writing' } diff --git a/src/Microdown-Templated/MicTemplatedWriterTest.class.st b/src/Microdown-Templated/MicTemplatedWriterTest.class.st index e59deb977..04098ab61 100644 --- a/src/Microdown-Templated/MicTemplatedWriterTest.class.st +++ b/src/Microdown-Templated/MicTemplatedWriterTest.class.st @@ -2,12 +2,19 @@ Class { #name : 'MicTemplatedWriterTest', #superclass : 'TestCase', #instVars : [ - 'textDocument' + 'textDocument', + 'fileSystem' ], #category : 'Microdown-Templated', #package : 'Microdown-Templated' } +{ #category : 'running' } +MicTemplatedWriterTest >> addTemplateFiles [ + + fileSystem / 'codeBlock.mustache' writeStreamDo: [ :s | s << self codeBlockContents ]. +] + { #category : 'helpers' } MicTemplatedWriterTest >> assertTemplate: template writesValue: value forNode: node [ @@ -28,16 +35,26 @@ MicTemplatedWriterTest >> assertWritingNode: node writes: contents [ document := MicRootBlock new addChild: node; yourself. - result := textDocument writer write: document. self assert: result equals: contents ] +{ #category : 'running' } +MicTemplatedWriterTest >> codeBlockContents [ + + ^ ' + +{{{contents}}} + +' +] + { #category : 'helpers' } MicTemplatedWriterTest >> createTemplateFileAt: aPath withContents: contents [ | templateFileReference | + templateFileReference := textDocument templateDirectory resolve: aPath. templateFileReference parent ensureCreateDirectory. templateFileReference writeStreamDo: [ :stream | stream nextPutAll: contents ]. @@ -47,18 +64,22 @@ MicTemplatedWriterTest >> createTemplateFileAt: aPath withContents: contents [ MicTemplatedWriterTest >> setUp [ super setUp. + fileSystem := FileSystem memory. textDocument := MicTextDocumentMaker new - baseDirectory: FileSystem memory; + baseDirectory: fileSystem; yourself. + self addTemplateFiles. ] -{ #category : 'tests-templatefiles' } -MicTemplatedWriterTest >> testWriteAnchorUsesAnchorTemplate [ - - self - assertTemplate: 'todo.mustache' - writesValue: 'annotated paragraph' - forNode: (PRAnnotatedParagraph withAll: #() annotation: 'todo') +{ #category : 'tests - setup' } +MicTemplatedWriterTest >> testDirectory [ + + self flag: #comeBack. + "it sucks but I'm always lost in file API" + self + assert: textDocument templateDirectory printString + equals: 'memory:///mic'. + self assert: (fileSystem / 'codeBlock.mustache') exists ] { #category : 'tests-templatefiles' } @@ -85,8 +106,11 @@ MicTemplatedWriterTest >> testWriteCodeBlockUsesCodeBlockTemplate [ self assertTemplate: MicTemplatedWriter codeBlockTemplateFileName - writesValue: 'codeBlockTemplate' - forNode: (PRCodeblock content: '^ self') + writesValue: ' + +^ self +' + forNode: (MicCodeBlock new body: '^ self'; yourself) ] { #category : 'tests-templatefiles' } @@ -98,24 +122,6 @@ MicTemplatedWriterTest >> testWriteCommentedLineUsesCommentedLineTemplate [ forNode: (PRCommentedLine content: 'some comment') ] -{ #category : 'tests-templatefiles' } -MicTemplatedWriterTest >> testWriteDataItemUsesDataItemTemplate [ - - self - assertTemplate: MicTemplatedWriter dataItemTemplateFileName - writesValue: 'dataitem' - forNode: PRDataItem new -] - -{ #category : 'tests-templatefiles' } -MicTemplatedWriterTest >> testWriteDefinitionListUsesDefinitionListTemplate [ - - self - assertTemplate: MicTemplatedWriter definitionListTemplateFileName - writesValue: 'definitionList' - forNode: PRDefinitionList new -] - { #category : 'tests-templatefiles' } MicTemplatedWriterTest >> testWriteEmptyParagraphsUsesEmptyParagraphTemplate [ @@ -176,9 +182,9 @@ MicTemplatedWriterTest >> testWriteHeaderUsesHeaderTemplate [ self assertTemplate: MicTemplatedWriter headerTemplateFileName writesValue: 'aHeader' - forNode: (PRHeader new + forNode: (MicHeaderBlock new level: 2; - add: (PRText content: 'foo')) + add: (MicTextBlock new bodyString: 'foo'; yourself)) ] { #category : 'tests-templatefiles' } @@ -205,7 +211,9 @@ MicTemplatedWriterTest >> testWriteItalicUsesItalicTemplate [ self assertTemplate: MicTemplatedWriter italicTemplateFileName writesValue: 'italicTemplate' - forNode: (PRItalicFormat with: (PRText content: 'Bar')) + forNode: (MicItalicFormatBlock new + children: { (MicTextBlock new bodyString: 'Bar') }; + yourself ) ] { #category : 'tests-templatefiles' } @@ -223,7 +231,7 @@ MicTemplatedWriterTest >> testWriteListItemUsesListItemTemplate [ self assertTemplate: MicTemplatedWriter listItemTemplateFileName writesValue: 'list item' - forNode: PRListItem new + forNode: MicListItemBlock new ] { #category : 'tests-templatefiles' } @@ -241,7 +249,7 @@ MicTemplatedWriterTest >> testWriteMonospaceUsesMonospaceTemplate [ self assertTemplate: MicTemplatedWriter monospaceTemplateFileName writesValue: 'monospace' - forNode: (PRMonospaceFormat with: (PRText content: 'Bar')) + forNode: (MicMonospaceFormatBlock new bodyString: 'Bar') ] { #category : 'tests-templatefiles' } @@ -283,7 +291,7 @@ MicTemplatedWriterTest >> testWriteOrderedListUsesOrderedListTemplate [ self assertTemplate: MicTemplatedWriter orderedListTemplateFileName writesValue: 'ordered list' - forNode: PROrderedList new + forNode: MicOrderedListBlock new ] { #category : 'tests-templatefiles' } diff --git a/src/Microdown/MicRawParagraphBlock.class.st b/src/Microdown/MicRawParagraphBlock.class.st index 65638ed63..8fa6464c0 100644 --- a/src/Microdown/MicRawParagraphBlock.class.st +++ b/src/Microdown/MicRawParagraphBlock.class.st @@ -5,9 +5,9 @@ Class { 'label', 'argumentsString' ], - #category : 'Microdown-Extensions', + #category : 'Microdown-Model', #package : 'Microdown', - #tag : 'Extensions' + #tag : 'Model' } { #category : 'public' } diff --git a/src/Microdown/MyLog.class.st b/src/Microdown/MyLog.class.st index ea3d05364..ecbdf1d0f 100644 --- a/src/Microdown/MyLog.class.st +++ b/src/Microdown/MyLog.class.st @@ -5,11 +5,12 @@ Too many times I do not remember what I did and why. Class { #name : 'MyLog', #superclass : 'Object', - #category : 'Microdown', - #package : 'Microdown' + #category : 'Microdown-DevLog', + #package : 'Microdown', + #tag : 'DevLog' } -{ #category : 'as yet unclassified' } +{ #category : 'ui - dialogs' } MyLog >> l2025_08_08 [ ^ ' @@ -46,7 +47,7 @@ visitParagraph: aParagraph ' ] -{ #category : 'as yet unclassified' } +{ #category : 'ui - dialogs' } MyLog >> l2025_08_11 [ ^ ' @@ -57,3 +58,24 @@ MyLog >> l2025_08_11 [ ' ] + +{ #category : 'possible todos' } +MyLog >> pt2025_08_16 [ + + ^ ' +## 2025 08 16 + +- Anchor Linker Use - Investigate why it is not used. +- Check with HTML exporter does not inherit from `MicDocumentWriter` +- Check with textualexport does not inherit from `MicDocumentWriter` +- MicCodeBlock API does not support the setting of text +- body: set does not set the lement as children in a parent children relation +- we should revisit all the parent/children and named instance variables + - we have caption and captionElements. This would indicate that + elements are returned using xxxElements + - code:/body: is then expecting a string + - It means that bodyString: and bodyString are not good API. + + +' +] From c9432a04074e1bc2a050367a4d18714e85fe25ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sun, 17 Aug 2025 19:00:44 +0200 Subject: [PATCH 63/67] Fixing printString of Figure --- .../MicTemplatedWriter.class.st | 2 +- .../MicTemplatedWriterTest.class.st | 32 ++++--------------- .../MicFigureBlockTest.class.st | 8 +++++ src/Microdown/MicBlockQuoteBlock.class.st | 3 +- src/Microdown/MicCommentBlock.class.st | 1 + src/Microdown/MicEnvironmentBlock.class.st | 2 +- src/Microdown/MicInlineBlockWithUrl.class.st | 4 ++- src/Microdown/MicNestedMarkupBlock.class.st | 2 +- 8 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/Microdown-Templated/MicTemplatedWriter.class.st b/src/Microdown-Templated/MicTemplatedWriter.class.st index 8a8ced55a..61e63b13a 100644 --- a/src/Microdown-Templated/MicTemplatedWriter.class.st +++ b/src/Microdown-Templated/MicTemplatedWriter.class.st @@ -467,7 +467,7 @@ MicTemplatedWriter >> visitHorizontalLine: aPRHorizontalRule [ self writeRawText: '' - withTemplateFileName: self horizontalRuleTemplateFileName + withTemplateFileName: self horizontalLineTemplateFileName ifAbsent: [ defaultWriter visitHorizontalRule: aPRHorizontalRule ] ] diff --git a/src/Microdown-Templated/MicTemplatedWriterTest.class.st b/src/Microdown-Templated/MicTemplatedWriterTest.class.st index 04098ab61..3e9755335 100644 --- a/src/Microdown-Templated/MicTemplatedWriterTest.class.st +++ b/src/Microdown-Templated/MicTemplatedWriterTest.class.st @@ -71,7 +71,7 @@ MicTemplatedWriterTest >> setUp [ self addTemplateFiles. ] -{ #category : 'tests - setup' } +{ #category : 'tests-setup' } MicTemplatedWriterTest >> testDirectory [ self flag: #comeBack. @@ -173,7 +173,7 @@ MicTemplatedWriterTest >> testWriteFigureUsesFigureTemplate [ self assertTemplate: MicTemplatedWriter figureTemplateFileName writesValue: 'figure' - forNode: (PRFigure reference: 'bla.png') + forNode: (MicFigureBlock new reference: 'bla.png') ] { #category : 'tests-templatefiles' } @@ -191,9 +191,9 @@ MicTemplatedWriterTest >> testWriteHeaderUsesHeaderTemplate [ MicTemplatedWriterTest >> testWriteHorizontalRuleUsesHorizontalRuleTemplate [ self - assertTemplate: MicTemplatedWriter horizontalRuleTemplateFileName + assertTemplate: MicTemplatedWriter horizontalLineTemplateFileName writesValue: '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=' - forNode: PRHorizontalRule new + forNode: MicHorizontalLineBlock new ] { #category : 'tests-templatefiles' } @@ -216,15 +216,6 @@ MicTemplatedWriterTest >> testWriteItalicUsesItalicTemplate [ yourself ) ] -{ #category : 'tests-templatefiles' } -MicTemplatedWriterTest >> testWriteLineBreakUsesLineBreakTemplate [ - - self - assertTemplate: MicTemplatedWriter lineBreakTemplateFileName - writesValue: 'line break' - forNode: PRLineBreak new -] - { #category : 'tests-templatefiles' } MicTemplatedWriterTest >> testWriteListItemUsesListItemTemplate [ @@ -312,15 +303,6 @@ MicTemplatedWriterTest >> testWritePreformattedUsesPreformattedTemplate [ forNode: (PRPreformatted with: (PRText content: 'Bar')) ] -{ #category : 'tests-templatefiles' } -MicTemplatedWriterTest >> testWriteSectionUsesSectionTemplate [ - - self - assertTemplate: MicTemplatedWriter sectionTemplateFileName - writesValue: 'section' - forNode: PRSection new -] - { #category : 'tests-templatefiles' } MicTemplatedWriterTest >> testWriteTextInsideEnvironmentLooksUpOutsideEnvironment [ @@ -340,9 +322,9 @@ MicTemplatedWriterTest >> testWriteTextInsideEnvironmentUsesTemplateInsideEnviro self assertTemplatePath: (Path * 'card' / 'paragraph.mustache') writesValue: 'Paragraph in card' - forNode: ((PREnvironment named: 'card') - add: (PRParagraph new - add: (PRText content: 'Foo'); + forNode: ((MicEnvironmentBlock named: 'card') + add: (MicParagraphBlock new + add: (MicTextBlock content: 'Foo'); yourself); yourself) ] diff --git a/src/Microdown-Tests/MicFigureBlockTest.class.st b/src/Microdown-Tests/MicFigureBlockTest.class.st index 38b70d130..dbd8ca7dc 100644 --- a/src/Microdown-Tests/MicFigureBlockTest.class.st +++ b/src/Microdown-Tests/MicFigureBlockTest.class.st @@ -145,6 +145,14 @@ MicFigureBlockTest >> testFigureCaptionIsReifiedWithNewFormat [ self assert: (fig arguments at: #width) equals: '666' ] +{ #category : 'tests' } +MicFigureBlockTest >> testFigureNoCaption [ + + | figure | + figure := MicFigureBlock new reference: 'bla.png'. + self shouldnt: [ figure printString ] raise: Error +] + { #category : 'tests' } MicFigureBlockTest >> testHasArguments [ | figure | diff --git a/src/Microdown/MicBlockQuoteBlock.class.st b/src/Microdown/MicBlockQuoteBlock.class.st index b9d41f6ea..5f4fff11e 100644 --- a/src/Microdown/MicBlockQuoteBlock.class.st +++ b/src/Microdown/MicBlockQuoteBlock.class.st @@ -18,13 +18,14 @@ Class { { #category : 'visiting' } MicBlockQuoteBlock >> accept: aVisitor [ + ^ aVisitor visitQuote: self ] { #category : 'visiting' } MicBlockQuoteBlock >> closeMe [ + super closeMe. - children := self inlineParse: text ] diff --git a/src/Microdown/MicCommentBlock.class.st b/src/Microdown/MicCommentBlock.class.st index b3284b318..597a350ca 100644 --- a/src/Microdown/MicCommentBlock.class.st +++ b/src/Microdown/MicCommentBlock.class.st @@ -15,6 +15,7 @@ Class { { #category : 'visiting' } MicCommentBlock >> accept: aVisitor [ + ^ aVisitor visitComment: self ] diff --git a/src/Microdown/MicEnvironmentBlock.class.st b/src/Microdown/MicEnvironmentBlock.class.st index ca94c8fe2..b99009d9b 100644 --- a/src/Microdown/MicEnvironmentBlock.class.st +++ b/src/Microdown/MicEnvironmentBlock.class.st @@ -89,6 +89,7 @@ MicEnvironmentBlock class >> buildMicroDownUsing: aBuilder withComment: aString { #category : 'visiting' } MicEnvironmentBlock >> accept: aVisitor [ + ^ aVisitor visitEnvironment: self ] @@ -115,7 +116,6 @@ MicEnvironmentBlock >> extractFirstLineFrom: aLine [ "we got foo bar or > hasLabel [ { #category : 'initialization' } MicInlineBlockWithUrl >> initialize [ super initialize. + children := #(). arguments := OrderedDictionary new. ] @@ -184,7 +185,8 @@ MicInlineBlockWithUrl >> printOn: stream [ ch printOn: stream. stream nextPut: Character space ]. stream << $]. - stream << $( << url << $) + url ifNotNil: [ + stream << $( << url << $) ] ] { #category : 'accessing' } diff --git a/src/Microdown/MicNestedMarkupBlock.class.st b/src/Microdown/MicNestedMarkupBlock.class.st index 0af751f7f..1245e49cd 100644 --- a/src/Microdown/MicNestedMarkupBlock.class.st +++ b/src/Microdown/MicNestedMarkupBlock.class.st @@ -52,7 +52,7 @@ MicNestedMarkupBlock >> bodyElements [ MicNestedMarkupBlock >> bodyFromLine: line [ | newBlock | - newBlock := (self newBlockFor: line parent: self). + newBlock := self newBlockFor: line parent: self. self parser setCurrent: newBlock. ^ newBlock ] From 0d9aa2ba2551a56052cbccdb02ebf15f45e4da3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 20 Aug 2025 19:07:43 +0200 Subject: [PATCH 64/67] Added Editor to all --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index cccaefc7d..1bff6ae45 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -114,7 +114,7 @@ BaselineOfMicrodown >> baseline: spec [ #'Microdown-Blog' #'Microdown-Blog-Tests' ); - group: 'All' with: #('Core' #'Microdown-BrowserExtensions' 'LaTeX' 'Extensions' 'Microdown-Pharo-Tools' 'RichText') + group: 'All' with: #('Core' #'Microdown-BrowserExtensions' 'Editor' 'LaTeX' 'Extensions' 'Microdown-Pharo-Tools' 'RichText') ] From cea9f1fea4b680056c92d81190c4e3a2448ca3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 20 Aug 2025 19:15:28 +0200 Subject: [PATCH 65/67] Trying again --- src/BaselineOfMicrodown/BaselineOfMicrodown.class.st | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st index 1bff6ae45..dcb65a28a 100644 --- a/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st +++ b/src/BaselineOfMicrodown/BaselineOfMicrodown.class.st @@ -89,13 +89,11 @@ BaselineOfMicrodown >> baseline: spec [ package: #'Microdown-Blog-Tests' with: [ spec requires: #( #'Microdown-Blog' 'GitBridge') ]. - "I do not want group without tests for now" spec group: 'Core' with: #('Microdown' 'Microdown-Tests'); group: 'ForPharo' with: #('Microdown' #'Microdown-BrowserExtensions'); group: 'RichText' with: #('Core' 'Microdown-RichTextComposer' ); - group: 'Editor' with: #('RichText' #'Microdown-PrettyPrinter' - #'Microdown-PrettyPrinter-Tests'); + group: 'Editor' with: #('RichText' #'Microdown-PrettyPrinter' #'Microdown-PrettyPrinter-Tests'); group: 'LaTeX' with: #('Core' #'Microdown-LaTeXExporter' #'Microdown-LaTeXExporter-Tests'); group: 'Extensions' with: #( #'Microdown-Evaluator' From b98fcc1d1cd9a7677e10a36dff87ba9f9fcdbe64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Thu, 28 Aug 2025 17:41:12 +0200 Subject: [PATCH 66/67] Update README.md --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a346c9dbf..40794b886 100644 --- a/README.md +++ b/README.md @@ -200,13 +200,7 @@ The process is the following: The following script loads all groups in the Baseline: ```Smalltalk -#( 'Microdown' 'BeautifulComments' 'DocumentBrowser' ) do: [ :name | - (IceRepository repositoryNamed: name) - ifNil: [ self inform: 'Project not found: ' , name ] - ifNotNil: [ :found | - found - unload; - forget ] ]. + Smalltalk globals at: #BaselineOfMicrodown @@ -218,7 +212,18 @@ Metacello new onConflict: [ :ex | ex useIncoming ]; onUpgrade: [ :ex | ex useIncoming ]; load: #('All'). - ``` +``` + +In addition you may want to execute this before. +``` +#( 'Microdown' ) do: [ :name | + (IceRepository repositoryNamed: name) + ifNil: [ self inform: 'Project not found: ' , name ] + ifNotNil: [ :found | + found + unload; + forget ] ]. +``` ## History From 11f6c9392a246a129a15e7e19c4d6c5226519fd6 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Fri, 29 Aug 2025 15:18:04 +0200 Subject: [PATCH 67/67] Frivolous commit just ot re launcht eh CI --- src/Microdown/Microdown.class.st | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Microdown/Microdown.class.st b/src/Microdown/Microdown.class.st index 530ff3afb..6eeaaff92 100644 --- a/src/Microdown/Microdown.class.st +++ b/src/Microdown/Microdown.class.st @@ -153,13 +153,12 @@ Microdown >> parse: aStreamOrString [ { #category : 'facade' } Microdown >> parseFile: aFile [ - "Parse and return a document from the argument marking it with the file it is contained in. This is important for path resolution." - - | root | - root := MicrodownParser parse: aFile contents. - root fromFile: aFile. - ^ root - + "Parse and return a document from the argument marking it with the file it is contained in. This is important for path resolution." + + | root | + root := MicrodownParser parse: aFile contents. + root fromFile: aFile. + ^ root ] { #category : 'facade' }