Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ MicAnchoredSectionTableFigureCheckerTest >> testFigureCorrect [
MicAnchoredSectionTableFigureCheckerTest >> testFigureExplanation [
checker checkProject: fileSystem / 'figureWrong.md'.
self assert: checker results first explanation
equals: 'Text: "figure " in file/figureWrong.md contains a mistake: [figure *@figbla@*] should be capitalized as [figure *@figbla@*].'
equals: 'Text: "figure " in file /figureWrong.md contains a mistake: [figure *@figbla@*] should be capitalized as [figure *@figbla@*].'
]

{ #category : 'tests - flagged violations' }
Expand Down Expand Up @@ -186,7 +186,7 @@ MicAnchoredSectionTableFigureCheckerTest >> testTableLowercaseDetectedWithSometh
self assert: checker results first detail equals: 'table *@tabbla@*'.
self
assert: checker results first explanation
equals: 'Text: "in table " in file/theTableWrongNoTheButIn.md contains a mistake: [table *@tabbla@*] should be capitalized as [table *@tabbla@*].'
equals: 'Text: "in table " in file /theTableWrongNoTheButIn.md contains a mistake: [table *@tabbla@*] should be capitalized as [table *@tabbla@*].'
]

{ #category : 'tests - flagged violations' }
Expand All @@ -198,7 +198,7 @@ MicAnchoredSectionTableFigureCheckerTest >> testTableLowercaseDetectedWithThe [
self assert: checker results first detail equals: 'The table *@tabbla@*'.
self
assert: checker results first explanation
equals: 'Text: "The table " in file/theTableWrongWithThe.md contains a mistake: [The table *@tabbla@*] should be capitalized as [The *@tabbla@*].'
equals: 'Text: "The table " in file /theTableWrongWithThe.md contains a mistake: [The table *@tabbla@*] should be capitalized as [The *@tabbla@*].'
]

{ #category : 'tests - configure' }
Expand All @@ -218,7 +218,7 @@ MicAnchoredSectionTableFigureCheckerTest >> testTextWithoutAnchorWithUppercase [

self deny: checker isOkay.
self assert: checker results size equals: 1.
self assert: checker results first explanation equals: 'Text: "in Figure without anchor" in file/noAnchorUppercase.md contains a mistake: [missing anchor for Figure] should be capitalized as [missing Figure].'.
self assert: checker results first explanation equals: 'Text: "in Figure without anchor" in file /noAnchorUppercase.md contains a mistake: [missing anchor for Figure] should be capitalized as [missing Figure].'.
]

{ #category : 'tests - flagged violations' }
Expand All @@ -230,7 +230,7 @@ MicAnchoredSectionTableFigureCheckerTest >> testTheFigureDetected [

self
assert: checker results first explanation
equals: 'Text: "the figure " in file/theFigureWrong.md contains a mistake: [the figure *@figbla@*] should be capitalized as [the *@figbla@*].'
equals: 'Text: "the figure " in file /theFigureWrong.md contains a mistake: [the figure *@figbla@*] should be capitalized as [the *@figbla@*].'

]

Expand All @@ -242,7 +242,7 @@ MicAnchoredSectionTableFigureCheckerTest >> testTheSectionDetected [

self
assert: checker results first explanation
equals: 'Text: "the section " in file/theSectionWrong.md contains a mistake: [the section *@seclab@*] should be capitalized as [the *@seclab@*].'
equals: 'Text: "the section " in file /theSectionWrong.md contains a mistake: [the section *@seclab@*] should be capitalized as [the *@seclab@*].'

]

Expand All @@ -254,6 +254,6 @@ MicAnchoredSectionTableFigureCheckerTest >> testTheTableDetected [

self
assert: checker results first explanation
equals: 'Text: "the table " in file/theTableWrong.md contains a mistake: [the table *@tabbla@*] should be capitalized as [the *@tabbla@*].'
equals: 'Text: "the table " in file /theTableWrong.md contains a mistake: [the table *@tabbla@*] should be capitalized as [the *@tabbla@*].'

]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {

{ #category : 'accessing' }
MicElementOfHeaderIsNotCapitalizedResult >> explanation [
^ 'Header: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: ' , detail , ' should be capitalized.'
^ 'Header: "' , micElement text , '" in file ' , self inFile fullName , ' contains a mistake: ' , detail , ' should be capitalized.'
]

{ #category : 'kinds' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ MicLastPeriodInCaptionCheckerTest >> testCodeCheckerIdentifyCorrectlyExtraPeriod
self
assert: checker results first explanation
equals:
'Text: "This is the famous correctly ending period." in file/codeCaptionEndingWithPeriod.md contains a mistake: Captions should not be terminated with a period (.).'
'Text: "This is the famous correctly ending period." in file /codeCaptionEndingWithPeriod.md contains a mistake: Captions should not be terminated with a period (.).'
]

{ #category : 'tests - missing period' }
Expand All @@ -116,7 +116,7 @@ MicLastPeriodInCaptionCheckerTest >> testCodeCheckerIdentifyCorrectlyMissingExtr
self
assert: checker results first explanation
equals:
'Text: "This is the famous missing period" in file/codeCaptionMissingPeriod.md contains a mistake: Captions should be terminated with a period (.).'
'Text: "This is the famous missing period" in file /codeCaptionMissingPeriod.md contains a mistake: Captions should be terminated with a period (.).'
]

{ #category : 'tests - explanation' }
Expand Down Expand Up @@ -193,7 +193,7 @@ MicLastPeriodInCaptionCheckerTest >> testFigureCheckerIdentifyCorrectlyExtraPeri

self
assert: checker results first explanation
equals: 'Text: "![This is the famous correctly ending period.](figures/f.png)" in file/figureCaptionEndingWithPeriod.md contains a mistake: Captions should not be terminated with a period (.).'
equals: 'Text: "![This is the famous correctly ending period.](figures/f.png)" in file /figureCaptionEndingWithPeriod.md contains a mistake: Captions should not be terminated with a period (.).'

]

Expand All @@ -206,7 +206,7 @@ MicLastPeriodInCaptionCheckerTest >> testFigureCheckerIdentifyCorrectlyMissingEx

self
assert: checker results first explanation
equals: 'Text: "![This is the famous missing period](figures/f.png)" in file/figureCaptionMissingPeriod.md contains a mistake: Captions should be terminated with a period (.).'
equals: 'Text: "![This is the famous missing period](figures/f.png)" in file /figureCaptionMissingPeriod.md contains a mistake: Captions should be terminated with a period (.).'

]

Expand Down Expand Up @@ -236,7 +236,7 @@ MicLastPeriodInCaptionCheckerTest >> testMathCheckerIdentifyCorrectlyExtraPeriod
self
assert: checker results first explanation
equals:
'Text: "This is the famous correctly ending period." in file/equationCaptionEndingWithPeriod.md contains a mistake: Captions should not be terminated with a period (.).'
'Text: "This is the famous correctly ending period." in file /equationCaptionEndingWithPeriod.md contains a mistake: Captions should not be terminated with a period (.).'
]

{ #category : 'tests - missing period' }
Expand All @@ -249,5 +249,5 @@ MicLastPeriodInCaptionCheckerTest >> testMathCheckerIdentifyCorrectlyMissingExtr
self
assert: checker results first explanation
equals:
'Text: "This is the famous missing period" in file/equationCaptionMissingPeriod.md contains a mistake: Captions should be terminated with a period (.).'
'Text: "This is the famous missing period" in file /equationCaptionMissingPeriod.md contains a mistake: Captions should be terminated with a period (.).'
]
2 changes: 1 addition & 1 deletion src/Microdown-BookTester/MicPeriodInCaptionResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MicPeriodInCaptionResult >> explanation [
"not sure that text is ok
we should have a common way to express caption between block, figure, and math"

^ 'Text: "' , micElement text , '" in file' , self inFile fullName , ' contains a mistake: Captions should'
^ 'Text: "' , micElement text , '" in file ' , self inFile fullName , ' contains a mistake: Captions should'
, (codeShouldEndWithPeriod
ifFalse: [ ' not ' ]
ifTrue: [ ' ' ]) , 'be terminated with a period (.).'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MicUseofWrongVocabularyResult >> explanation [
| wrongWord goodWord |
wrongWord := patternPair key allButFirst allButLast.
goodWord := patternPair value.
^ 'Text: "' , micElement bodyString , '" in file' , self inFile fullName , ' contains a mistake: [' , wrongWord
^ 'Text: "' , micElement bodyString , '" in file ' , self inFile fullName , ' contains a mistake: [' , wrongWord
, '] should not be used. We should use ' , goodWord
]

Expand Down
24 changes: 12 additions & 12 deletions src/Microdown-BookTester/MicVocabularyCheckerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ MicVocabularyCheckerTest >> testCheckerFindsAllowToMistake [
self
assert: checker results first explanation
equals:
'Text: "We allow to edit the file." in file/mistakeAllowTo.md contains a mistake: [allow to] should not be used. We should use allow one to'
'Text: "We allow to edit the file." in file /mistakeAllowTo.md contains a mistake: [allow to] should not be used. We should use allow one to'
]

{ #category : 'tests' }
Expand All @@ -137,7 +137,7 @@ checker checkProject: fileSystem / 'mistakeAllowedTo.md'.
self
assert: checker results first explanation
equals:
'Text: "You are allowed to enter." in file/mistakeAllowedTo.md contains a mistake: [allowed to] should not be used. We should use allowed one to'
'Text: "You are allowed to enter." in file /mistakeAllowedTo.md contains a mistake: [allowed to] should not be used. We should use allowed one to'
]

{ #category : 'tests' }
Expand All @@ -149,7 +149,7 @@ MicVocabularyCheckerTest >> testCheckerFindsAllowsToMistake [
self
assert: checker results first explanation
equals:
'Text: "The system allows to change settings." in file/mistakeAllowsTo.md contains a mistake: [allows to] should not be used. We should use allows one to'
'Text: "The system allows to change settings." in file /mistakeAllowsTo.md contains a mistake: [allows to] should not be used. We should use allows one to'
]

{ #category : 'tests' }
Expand All @@ -161,7 +161,7 @@ MicVocabularyCheckerTest >> testCheckerFindsBehaviourMistake [
self
assert: checker results first explanation
equals:
'Text: "Pharo has interesting behaviour." in file/mistakeBehaviour.md contains a mistake: [behaviour] should not be used. We should use behavior'
'Text: "Pharo has interesting behaviour." in file /mistakeBehaviour.md contains a mistake: [behaviour] should not be used. We should use behavior'
]

{ #category : 'tests' }
Expand All @@ -173,7 +173,7 @@ MicVocabularyCheckerTest >> testCheckerFindsCentreMistake [
self
assert: checker results first explanation
equals:
'Text: "The centre of the universe." in file/mistakeCentre.md contains a mistake: [centre] should not be used. We should use center'
'Text: "The centre of the universe." in file /mistakeCentre.md contains a mistake: [centre] should not be used. We should use center'
]

{ #category : 'tests' }
Expand All @@ -185,7 +185,7 @@ MicVocabularyCheckerTest >> testCheckerFindsColourMistake [
self
assert: checker results first explanation
equals:
'Text: "The colour of the sky is blue." in file/mistakeColour.md contains a mistake: [colour] should not be used. We should use color'
'Text: "The colour of the sky is blue." in file /mistakeColour.md contains a mistake: [colour] should not be used. We should use color'
]

{ #category : 'tests' }
Expand All @@ -196,7 +196,7 @@ MicVocabularyCheckerTest >> testCheckerFindsColoursMistake [

self
assert: checker results first explanation
equals:'Text: "Colours are beautiful." in file/mistakeColours.md contains a mistake: [colour] should not be used. We should use color'
equals:'Text: "Colours are beautiful." in file /mistakeColours.md contains a mistake: [colour] should not be used. We should use color'

]

Expand All @@ -210,7 +210,7 @@ MicVocabularyCheckerTest >> testCheckerFindsMistakeInFigure [
self
assert: checker results first explanation
equals:
'Text: "sub-presenter is not correct even in caption" in file/mistakeInFigure.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
'Text: "sub-presenter is not correct even in caption" in file /mistakeInFigure.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
]

{ #category : 'tests' }
Expand All @@ -222,7 +222,7 @@ MicVocabularyCheckerTest >> testCheckerFindsMistakeInHeader [
self
assert: checker results first explanation
equals:
'Text: "sub-presenter is not correct." in file/mistakeInHeader.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
'Text: "sub-presenter is not correct." in file /mistakeInHeader.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
]

{ #category : 'tests' }
Expand All @@ -234,7 +234,7 @@ MicVocabularyCheckerTest >> testCheckerFindsMistakeInParagraph [
self
assert: checker results first explanation
equals:
'Text: "Spec uses a sub presenter. And there is a mistake in the previous sentence." in file/mistakeInParagraph.md contains a mistake: [sub presenter] should not be used. We should use subpresenter'
'Text: "Spec uses a sub presenter. And there is a mistake in the previous sentence." in file /mistakeInParagraph.md contains a mistake: [sub presenter] should not be used. We should use subpresenter'
]

{ #category : 'tests' }
Expand All @@ -246,7 +246,7 @@ MicVocabularyCheckerTest >> testCheckerFindsMistakeInUppercasedText [
self
assert: checker results first explanation
equals:
'Text: "sub-Presenter is not correct. The checker should pay attention that the text may use a different case than the pattern." in file/mistakeInUppercase.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
'Text: "sub-Presenter is not correct. The checker should pay attention that the text may use a different case than the pattern." in file /mistakeInUppercase.md contains a mistake: [sub-presenter] should not be used. We should use subpresenter'
]

{ #category : 'tests' }
Expand All @@ -258,7 +258,7 @@ MicVocabularyCheckerTest >> testCheckerFindsVisualiseMistake [
self
assert: checker results first explanation
equals:
'Text: "We will visualise the results." in file/mistakeVisualise.md contains a mistake: [visualise] should not be used. We should use visualize'
'Text: "We will visualise the results." in file /mistakeVisualise.md contains a mistake: [visualise] should not be used. We should use visualize'
]

{ #category : 'tests - configuration' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MicWrongReferenceToFigSectTableAnchorResult >> explanation [
ifFalse: [ words first , ' ' , words last capitalized ].

^ 'Text: "' , micElement bodyString
, '" in file' , self inFile fullName
, '" in file ' , self inFile fullName
, ' contains a mistake: ['
, detail
, '] should be capitalized as ['
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ MicRichTextComposerTest >> testFigureCaptionRemote [
| source richText |
source := 'See ![SomeText](https://pharo.org/web/files/pharo.png)'.
richText := self composerClass asRichText: source.

self assert: (richText asString includesSubstring: 'SomeText')
]

Expand Down
14 changes: 8 additions & 6 deletions src/Microdown-RichTextComposer/MicRichTextComposer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,16 @@ MicRichTextComposer >> visitFigure: aFigure [

| image anchor |
[
[
image := aFigure reference loadImage.
[ image := aFigure reference loadImage.
anchor := self anchorFor: image of: aFigure.
canvas << (self textWithImage: image usingAnchor: anchor) ]
canvas << (self textWithImage: image usingAnchor: anchor).
"for the caption"
canvas tab.
self visitChildrenOf: aFigure ]
on: MicResourceReferenceError , UnrecognizedImageFormatError
do: [ self visitChildrenOf: aFigure ] ]
on: Error
do: [ :error | canvas << ('>>> ' , error printString , ' <<<') ]
do: [ self visitChildrenOf: aFigure ] ]
on: Error
do: [ :error | canvas << ('>>> ' , error printString , ' <<<') ]
]

{ #category : 'visiting' }
Expand Down
Loading