PetitCommonMark/software/PetitMarkdown/PPCMList.class.st

90 lines
1.6 KiB
Smalltalk

Class {
#name : 'PPCMList',
#superclass : 'PPCMDelegateNode',
#instVars : [
'type',
'start'
],
#category : 'PetitMarkdown-AST'
}
{ #category : 'visiting' }
PPCMList >> accept: visitor [
^ visitor visitList: self
]
{ #category : 'accessing' }
PPCMList >> isBlockLevel [
^ true
]
{ #category : 'as yet unclassified' }
PPCMList >> isLooseItem: item [
| document size |
"empty item case"
(item children size == 0) ifTrue: [ ^ false ].
document := item child.
size := document children size.
size < 3 ifTrue: [ ^ false ].
(1 to: size - 2) do: [ :idx |
((document children at: idx) isBlockLevel and:
[(document children at: idx + 1) isBlankLine and:
[(document children at: idx + 2) isBlockLevel] ]) ifTrue: [ ^ true ]
].
^ false
]
{ #category : 'as yet unclassified' }
PPCMList >> isLooseList [
| size |
size := children size.
size < 3 ifTrue: [ ^ false ].
(1 to: size - 2) do: [ :idx |
((children at: idx) isBlockLevel and:
[(children at: idx + 1) isBlankLine and:
[(children at: idx + 2) isBlockLevel] ]) ifTrue: [ ^ true ]
].
^ false
]
{ #category : 'as yet unclassified' }
PPCMList >> isTight [
"blanks in the list?"
self isLooseList ifTrue: [
^ false
].
"blanks in the items?"
self children do: [ :listItem |
(self isLooseItem: listItem) ifTrue: [
^ false
]
].
^ true
]
{ #category : 'accessing' }
PPCMList >> start [
^ start
]
{ #category : 'accessing' }
PPCMList >> start: anObject [
start := anObject
]
{ #category : 'accessing' }
PPCMList >> type [
^ type
]
{ #category : 'accessing' }
PPCMList >> type: string [
type := string
]