From a3741918c97891ce44ab3991b19f4a1e74c506b7 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Tue, 9 May 2023 18:18:39 -0500 Subject: [PATCH] Starting support for footnotes in the new parser. --- src/MiniDocs/Markdeep.class.st | 7 +++---- src/MiniDocs/PubPubGrammar2.class.st | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/MiniDocs/Markdeep.class.st b/src/MiniDocs/Markdeep.class.st index 26e4c4b..13a02d2 100644 --- a/src/MiniDocs/Markdeep.class.st +++ b/src/MiniDocs/Markdeep.class.st @@ -389,16 +389,15 @@ Markdeep >> pubPubImagesToMarkdeep [ { #category : #accessing } Markdeep >> pubPubRawLinks [ | parser | - parser := PubPubGrammar new document. + parser := PubPubGrammar2 new document. ^ (parser parse: self body) ] { #category : #accessing } Markdeep >> removeAlternativeImagesArray [ - | parser replacements | + | replacements | self body ifNil: [^ self]. - parser := PubPubGrammar2 new. - replacements := parser parse: body. + replacements := self selectPubPubLinksWithSize: 3. replacements ifEmpty: [^self]. replacements do: [:replacement | self body: diff --git a/src/MiniDocs/PubPubGrammar2.class.st b/src/MiniDocs/PubPubGrammar2.class.st index a5014c2..a2a065c 100644 --- a/src/MiniDocs/PubPubGrammar2.class.st +++ b/src/MiniDocs/PubPubGrammar2.class.st @@ -6,14 +6,32 @@ Class { 'imageLink', 'imagesArray', 'imageLocation', - 'document' + 'document', + 'footnote', + 'footnoteLabel', + 'footnoteContent' ], #category : #MiniDocs } { #category : #accessing } PubPubGrammar2 >> document [ - ^ imageLink islandInSea star + ^ (imageLink / footnote) islandInSea star +] + +{ #category : #accessing } +PubPubGrammar2 >> footnote [ + ^ footnoteLabel, footnoteContent +] + +{ #category : #accessing } +PubPubGrammar2 >> footnoteContent [ + ^ '{#' asPParser, #any asPParser starLazy flatten, '}' asPParser ==> #second +] + +{ #category : #accessing } +PubPubGrammar2 >> footnoteLabel [ + ^ '[' asPParser, #any asPParser starLazy flatten, ']' asPParser ==> #second ] { #category : #accessing } @@ -36,6 +54,11 @@ PubPubGrammar2 >> imagesArray [ ^ '{srcset=' asPParser, #any asPParser starLazy flatten, '}' asPParser ==> #second ] +{ #category : #accessing } +PubPubGrammar2 >> imagesContent [ + ^ '{src=' asPParser, #any asPParser starLazy flatten, '}' asPParser ==> #second +] + { #category : #accessing } PubPubGrammar2 >> start [ ^ document