From a5fc210776cc34ed5fe1e17e5d93f71b2b6f5de8 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 3 Nov 2022 20:07:06 -0500 Subject: [PATCH] Extending PubPubGrammar syntax and test. --- src/MiniDocs/PubPubGrammar.class.st | 8 +++++-- src/MiniDocs/PubPubGrammarTest.class.st | 28 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/MiniDocs/PubPubGrammar.class.st b/src/MiniDocs/PubPubGrammar.class.st index 7372c09..cf4d335 100644 --- a/src/MiniDocs/PubPubGrammar.class.st +++ b/src/MiniDocs/PubPubGrammar.class.st @@ -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 } diff --git a/src/MiniDocs/PubPubGrammarTest.class.st b/src/MiniDocs/PubPubGrammarTest.class.st index 1f9c3ef..87e352b 100644 --- a/src/MiniDocs/PubPubGrammarTest.class.st +++ b/src/MiniDocs/PubPubGrammarTest.class.st @@ -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 +]