Skip to content
Open
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 @@ -51,22 +51,6 @@ MicAnchoredSectionTableFigureChecker >> addErrorDetail: detailString on: aTextBl
yourself)
]

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> analyzeWords: words inTextBlock: aTextBlock inParagraph: aParagraph anchorBlock: anchorBlock [

anchoredElements do: [ :ref |
self checkNamingFor: words
reference: ref
anchorBlock: anchorBlock
inTextBlock: aTextBlock
inParagraph: aParagraph.
self checkMissingAnchorsFor: words
reference: ref
anchorBlock: anchorBlock
inTextBlock: aTextBlock
inParagraph: aParagraph ]
]

{ #category : 'accessing' }
MicAnchoredSectionTableFigureChecker >> anchoredElements [

Expand All @@ -75,7 +59,6 @@ MicAnchoredSectionTableFigureChecker >> anchoredElements [

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> checkMissingAnchorsFor: words reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph [

| lastWord |
lastWord := words last.
words do: [ :word |
Expand All @@ -85,30 +68,25 @@ MicAnchoredSectionTableFigureChecker >> checkMissingAnchorsFor: words reference:

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> checkNamingFor: words reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph [

| lastWord anchorString |
anchorBlock ifNil: [ ^ self ].
lastWord := words last.
lastWord asLowercase = ref ifFalse: [ ^ self ].

(words size > 1 and: [
(words at: words size - 1) asLowercase = 'the' ])
(words size > 1 and: [ (words at: words size - 1) asLowercase = 'the' ])
ifTrue: [
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ])
, '@*'.
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ]) , '@*'.
self
addErrorDetail: (words at: words size - 1) , ' ' , lastWord , anchorString
on: aTextBlock
inParagraph: aParagraph ]
ifFalse: [
lastWord = ref ifTrue: [
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ]) , '@*'.
self
addErrorDetail:
(words at: words size - 1) , ' ' , lastWord , anchorString
addErrorDetail: lastWord , anchorString
on: aTextBlock
inParagraph: aParagraph ]
ifFalse: [
lastWord = ref ifTrue: [
anchorString := ' *@' , (anchorBlock bodyString ifNil: [ '' ])
, '@*'.
self
addErrorDetail: lastWord , anchorString
on: aTextBlock
inParagraph: aParagraph ] ]
inParagraph: aParagraph ] ]
]

{ #category : 'configuration' }
Expand All @@ -131,14 +109,16 @@ MicAnchoredSectionTableFigureChecker >> initialize [

{ #category : 'checking' }
MicAnchoredSectionTableFigureChecker >> processTextBlock: aTextBlock atIndex: index withChildren: children inParagraph: aParagraph [
| words anchorBlock |
words := aTextBlock bodyString substrings.
words isEmpty ifTrue: [ ^ self ].
anchorBlock := (index < children size and: [ (children at: index + 1) isKindOf: MicAnchorReferenceBlock ])
| anchorBlock |
aTextBlock bodyString substrings isEmpty ifTrue: [ ^ self ].

anchorBlock := (index < children size and: [ (children at: index + 1) isAnchorReferenceBlock ])
ifTrue: [ children at: index + 1 ]
ifFalse: [ nil ].

self analyzeWords: words inTextBlock: aTextBlock inParagraph: aParagraph anchorBlock: anchorBlock
anchoredElements do: [ :ref |
self checkNamingFor: aTextBlock bodyString substrings reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph.
self checkMissingAnchorsFor: aTextBlock bodyString substrings reference: ref anchorBlock: anchorBlock inTextBlock: aTextBlock inParagraph: aParagraph ]
]

{ #category : 'visiting' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Class {
#superclass : 'TestCase',
#instVars : [
'fileSystem',
'checker'
'checker',
'inFile'
],
#category : 'Microdown-BookTester-Checker-BookTester',
#package : 'Microdown-BookTester',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MicWrongReferenceToFigSectTableAnchorResult >> detail: anObject [
]

{ #category : 'accessing' }
MicWrongReferenceToFigSectTableAnchorResult >> explanation [
MicWrongReferenceToFigSectTableAnchorResult >> explanation [
| words expected |
words := detail substrings.

Expand All @@ -37,3 +37,8 @@ MicWrongReferenceToFigSectTableAnchorResult >> explanation [
, '] should be capitalized as ['
, expected , '].'
]

{ #category : 'accessing' }
MicWrongReferenceToFigSectTableAnchorResult >> micElement: anObject [
micElement := anObject
]
5 changes: 5 additions & 0 deletions src/Microdown/MicAbstractBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ MicAbstractBlock >> initialize [
children := OrderedCollection new.
]

{ #category : 'initialization' }
MicAbstractBlock >> isAnchorReferenceBlock [
^ false
]

{ #category : 'testing' }
MicAbstractBlock >> isHeader [
^ false
Expand Down
5 changes: 5 additions & 0 deletions src/Microdown/MicAnchorReferenceBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ MicAnchorReferenceBlock >> anchorLabel [
^ bodyString
]

{ #category : 'accessing' }
MicAnchorReferenceBlock >> isAnchorReferenceBlock [
^ true
]

{ #category : 'accessing' }
MicAnchorReferenceBlock >> reference [

Expand Down
Loading