Extending PubPubGrammar syntax and test.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-11-03 20:07:06 -05:00
parent 77404b9b31
commit a5fc210776
2 changed files with 34 additions and 2 deletions

View File

@ -36,7 +36,9 @@ PubPubGrammar >> imageLinkContent [
{ #category : #links }
PubPubGrammar >> imageLinkLabel [
^ '![' asPParser, #any asPParser starLazy flatten, $] asPParser ==> #second
| label |
label := ($] asPParser not / #any asPParser) starLazy flatten.
^ '![' asPParser, label, $] asPParser ==> #second
]
{ #category : #accessing }
@ -56,7 +58,9 @@ PubPubGrammar >> linkContent [
{ #category : #links }
PubPubGrammar >> linkLabel [
^ $[ asPParser, #any asPParser starLazy flatten, $] asPParser ==> #second.
| label |
label := ("$] asPParser not /" #any asPParser) starLazy flatten.
^ $[ asPParser, label, $] asPParser ==> #second.
]
{ #category : #accessing }

View File

@ -9,6 +9,13 @@ PubPubGrammarTest >> parserClass [
^ PubPubGrammar
]
{ #category : #accessing }
PubPubGrammarTest >> testComposedImageLink [
self
parse: '![This is an image label with sublinks (bla bl)[blog]](this/is/an/image/link){this are alternate image sizes}'
rule: #imageLink
]
{ #category : #accessing }
PubPubGrammarTest >> testImageLink [
self
@ -16,9 +23,30 @@ PubPubGrammarTest >> testImageLink [
rule: #imageLink
]
{ #category : #accessing }
PubPubGrammarTest >> testLabel: label [
self
parse: label
rule: #linkLabel
]
{ #category : #accessing }
PubPubGrammarTest >> testLink [
self
parse: '[This is a label]{this/is/a/link}'
rule: #link
]
{ #category : #accessing }
PubPubGrammarTest >> testNestedLabel [
self
parse: '[This is a label with [sublabels]]'
rule: #linkLabel
]
{ #category : #accessing }
PubPubGrammarTest >> testSimpleLabel [
self
parse: '[This is a label]'
rule: #linkLabel
]