Add new checker : MicFigureCaption#1070
Add new checker : MicFigureCaption#1070AntoineUsal wants to merge 10 commits intopillar-markup:devfrom
Conversation
|
Tx! I will have a look |
|
Ok c'est un bon debut. Des captions il peut y en avoir dans les codeBlock et les equations donc est ce que tu peux regarder la logique dans LastPeriodInCaption |
|
Hi I realized that I did not implement the choice of checking in LastPeriodInCaption. I got confused by the logic of |
| { #category : 'visiting - inline elements' } | ||
| MicFigureCaptionChecker >> visitCode: aCode [ | ||
| | captionText | | ||
| captionText := ' ' join: (aCode captionElements collect: [ :each | each text ]). |
There was a problem hiding this comment.
I saw that there is a method caption in the superclass.
Can you check if it is what you need?
| | captionText | | ||
| captionText := ' ' join: (aCode captionElements collect: [ :each | each text ]). | ||
| (captionText isEmpty or: [ (captionText anySatisfy: #isAlphaNumeric) not ]) ifTrue: [ | ||
| self results add: (MicMissingFigureCaptionResult new |
There was a problem hiding this comment.
Since we should check the caption for code, figure, equation can you create an helper method to define the logic of the test hasCorrectCaption: in a single place?
| { #category : 'visiting - inline elements' } | ||
| MicFigureCaptionChecker >> visitMath: aMath [ | ||
| | captionText | | ||
| captionText := ' ' join: (aMath captionElements collect: [ :each | each text ]). |
| | captionText | | ||
|
|
||
| self checkCode ifTrue: [ | ||
| captionText := ' ' join: (aCode captionElements collect: [ :each | each text ]). |
|
|
||
|
|
||
| self checkFigure ifTrue: [ | ||
| captionText := String streamContents: [ :stream | |
There was a problem hiding this comment.
If there is no method caption in the class MicFigure then we should define one there and add tests for it.
|
|
||
|
|
||
| self checkMath ifTrue: [ | ||
| captionText := ' ' join: (aMath captionElements collect: [ :each | each text ]). |
| MicFigureCaptionCheckerTest >> testCodeBlockCaptionIsOnlySpaces [ | ||
| | visitor mdFile mem | | ||
| mem := FileSystem memory root. | ||
| mdFile := mem / 'test.md'. |
There was a problem hiding this comment.
can you rename the test.md to convey if the file contains a correct or bogus caption?
| MicFigureCaptionCheckerTest >> testMathBlockCaptionIsEmpty [ | ||
| | visitor mdFile mem | | ||
| mem := FileSystem memory root. | ||
| mdFile := mem / 'test.md'. |
| MicFigureCaptionCheckerTest >> testMathBlockCaptionIsEmpty [ | ||
| | visitor mdFile mem | | ||
| mem := FileSystem memory root. | ||
| mdFile := mem / 'test.md'. |
|
We should add support for configureFrom: and explanationForConfiguration |
By default,
In the example above the author only wants to validate code and figure captions (should not be empty) |
Fix #1065