Creating a parser for HedgeDoc youtube embedded links.

This commit is contained in:
ruidajo 2023-03-08 16:48:03 -05:00
parent c8c50288cf
commit 6eada9fe00
2 changed files with 34 additions and 0 deletions

View File

@ -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
]

View File

@ -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
]