From 6eada9fe001065d6d0cf6316cf016a0140eb9fb9 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Wed, 8 Mar 2023 16:48:03 -0500 Subject: [PATCH] Creating a parser for HedgeDoc youtube embedded links. --- src/MiniDocs/HedgeDocGrammar.class.st | 19 +++++++++++++++++++ src/MiniDocs/HedgeDocGrammarTest.class.st | 15 +++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/MiniDocs/HedgeDocGrammar.class.st create mode 100644 src/MiniDocs/HedgeDocGrammarTest.class.st diff --git a/src/MiniDocs/HedgeDocGrammar.class.st b/src/MiniDocs/HedgeDocGrammar.class.st new file mode 100644 index 0000000..764b410 --- /dev/null +++ b/src/MiniDocs/HedgeDocGrammar.class.st @@ -0,0 +1,19 @@ +Class { + #name : #HedgeDocGrammar, + #superclass : #PP2CompositeNode, + #instVars : [ + 'youtubeEmbeddedLink' + ], + #category : #'MiniDocs-Model' +} + +{ #category : #accessing } +HedgeDocGrammar >> start [ + ^ #any asPParser starLazy +] + +{ #category : #accessing } +HedgeDocGrammar >> youtubeEmbeddedLink [ + "I parse a youtube embedded link in a hedgedoc document." + ^ '{%youtube' asPParser token trim, #any asPParser starLazy token, '%}' asPParser token trim +] diff --git a/src/MiniDocs/HedgeDocGrammarTest.class.st b/src/MiniDocs/HedgeDocGrammarTest.class.st new file mode 100644 index 0000000..448700d --- /dev/null +++ b/src/MiniDocs/HedgeDocGrammarTest.class.st @@ -0,0 +1,15 @@ +Class { + #name : #HedgeDocGrammarTest, + #superclass : #PP2CompositeNodeTest, + #category : #'MiniDocs-Model' +} + +{ #category : #accessing } +HedgeDocGrammarTest >> parserClass [ + ^ HedgeDocGrammar +] + +{ #category : #accessing } +HedgeDocGrammarTest >> testYoutubeEmbeddedLink [ + ^ self parse: '{%youtube U7mpXaLN9Nc %}' rule: #youtubeEmbeddedLink +]