Skip to content

Commit

Permalink
Adding code block anchor to the anchors that exist! Fix #871
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Sep 4, 2024
1 parent 4d2aaca commit a8c7db6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
'defAndRefFig1',
'defFig1AndRefToAnsC0',
'defFig1AndRefToAncUnkS0',
'refToUnkS1'
'refToUnkS1',
'defCode1AndReferToCode1'
],
#category : 'Microdown-BookTester-Tests',
#package : 'Microdown-BookTester-Tests'
Expand Down Expand Up @@ -99,6 +100,23 @@ See *@ancS1@* and *@ancS0@*
^ defAncS0TripleAncS1RefAncS1AncS0
]

{ #category : 'helpers - anchors & references' }
MicReferenceCheckerTest >> defCode1AndReferToCode1 [

defCode1AndReferToCode1 := fs / 'defCode1AndReferToCode1.md'.
defCode1AndReferToCode1 writeStreamDo: [ :stream |
stream nextPutAll: '# Section 1
```language=pharo&anchor=Code1
balbalbalb!
```
See *@Code1@*
' ].
defCode1AndReferToCode1 ensureCreateFile
]

{ #category : 'helpers - anchors & references' }
MicReferenceCheckerTest >> defEq1AndReferToEq1 [

Expand Down Expand Up @@ -294,6 +312,18 @@ See *@ancS1@*
' ]
]

{ #category : 'tests - single file ok references' }
MicReferenceCheckerTest >> testDefAndReferToACodeAnchorInFile [

| visitor |
self defCode1AndReferToCode1.
visitor := MicReferenceChecker new.
visitor rootDirectory: dir.
visitor checkProject: defCode1AndReferToCode1.
self assert: visitor isOkay.
self assert: visitor results isEmpty
]

{ #category : 'tests - single file ok references' }
MicReferenceCheckerTest >> testDefAndReferToAMathEquationInFile [

Expand Down
6 changes: 6 additions & 0 deletions src/Microdown-BookTester/MicReferenceChecker.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ MicReferenceChecker >> visitAnchorReference: anAnchorReference [
references add: anAnchorReference
]

{ #category : 'visiting' }
MicReferenceChecker >> visitCode: aCodeBlock [

self handleAnchorOf: aCodeBlock
]

{ #category : 'visiting' }
MicReferenceChecker >> visitFigure: aFigure [

Expand Down
6 changes: 6 additions & 0 deletions src/Microdown/MicCodeBlock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ MicCodeBlock >> anchor: aString [
self arguments at: #anchor put: aString
]

{ #category : 'accessing' }
MicCodeBlock >> anchorLabel [
"This should only be invoked when checking references"
^ self anchor
]

{ #category : 'public' }
MicCodeBlock >> closeMe [
"adjust prefix tabs based on first line
Expand Down

0 comments on commit a8c7db6

Please sign in to comment.