Improving PubPub documents management. A clearer grammar could replace the original one, now that Markdown parser has been ported.
This commit is contained in:
parent
daef3951b7
commit
91e92c3e6a
|
@ -0,0 +1,30 @@
|
|||
Class {
|
||||
#name : #PubPub,
|
||||
#superclass : #Markdown,
|
||||
#instVars : [
|
||||
'url'
|
||||
],
|
||||
#category : #'MiniDocs-Core'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPub >> detectImageLinkPositions [
|
||||
| docNodes response |
|
||||
docNodes := self documentTree allChildren.
|
||||
response := OrderedCollection new.
|
||||
docNodes doWithIndex: [:each :i|
|
||||
((each className = 'PPCMLink') and: [ (docNodes at: i - 1) text = '!' ]) ifTrue:
|
||||
[ response add: {i -> each } ]
|
||||
].
|
||||
^ response
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPub >> linksWithTreePosition [
|
||||
| response |
|
||||
response := OrderedCollection new.
|
||||
self documentTree allChildren doWithIndex: [:each :i |
|
||||
each className = 'PPCMLink' ifTrue: [ response add: { i -> each }]
|
||||
].
|
||||
^ response
|
||||
]
|
|
@ -36,9 +36,10 @@ PubPubGrammar >> imageLinkContent [
|
|||
|
||||
{ #category : #links }
|
||||
PubPubGrammar >> imageLinkLabel [
|
||||
|
||||
| label |
|
||||
label := ($] asPParser not / #any asPParser) starLazy flatten.
|
||||
^ '![' asPParser, label, $] asPParser ==> #second
|
||||
label := ("$] asPParser not /" #any asPParser) starLazy flatten.
|
||||
^ '![' asPParser, label, ']' asPParser ==> #second.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
Class {
|
||||
#name : #PubPubGrammar2,
|
||||
#superclass : #PP2CompositeNode,
|
||||
#instVars : [
|
||||
'imageLabel',
|
||||
'imageLink',
|
||||
'imagesArray',
|
||||
'imageLocation',
|
||||
'document'
|
||||
],
|
||||
#category : #MiniDocs
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammar2 >> document [
|
||||
^ imageLink islandInSea star
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammar2 >> imageLabel [
|
||||
^ '![' asPParser, #any asPParser starLazy flatten, ']' asPParser ==> #second
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammar2 >> imageLink [
|
||||
^ imageLabel, imageLocation, imagesArray
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammar2 >> imageLocation [
|
||||
^ '(' asPParser, #any asPParser starLazy flatten, ')' asPParser ==> #second
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammar2 >> imagesArray [
|
||||
^ '{srcset=' asPParser, #any asPParser starLazy flatten, '}' asPParser ==> #second
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammar2 >> start [
|
||||
^ document
|
||||
]
|
|
@ -16,6 +16,13 @@ PubPubGrammarTest >> testComposedImageLink [
|
|||
rule: #imageLink
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammarTest >> testImageLabel: label [
|
||||
self
|
||||
parse: label
|
||||
rule: #imageLinkLabel
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
PubPubGrammarTest >> testImageLink [
|
||||
self
|
||||
|
|
Loading…
Reference in New Issue