Modifyng hedgedoc youtube embedded link parser.
This commit is contained in:
parent
2cb905e58f
commit
71d1cbd9a6
@ -11,20 +11,32 @@ Class {
|
|||||||
HedgeDocGrammar >> start [
|
HedgeDocGrammar >> start [
|
||||||
| any |
|
| any |
|
||||||
any := #any asPParser.
|
any := #any asPParser.
|
||||||
^ (self yamlMetadata / any starLazy), self youtubeEmbeddedLink
|
^ (self yamlMetadata / any starLazy), youtubeEmbeddedLink
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
HedgeDocGrammar >> yamlMetadata [
|
HedgeDocGrammar >> yamlMetadata [
|
||||||
"I parse the header of the hedgedoc document for YAML metadata."
|
"I parse the header of the hedgedoc document for YAML metadata."
|
||||||
^ '---' asPParser token trim, #any asPParser starLazy token, '---' asPParser token trim
|
^ '---' asPParser token, #any asPParser starLazy token, '---' asPParser token
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
HedgeDocGrammar >> youtubeEmbeddedLink [
|
HedgeDocGrammar >> youtubeEmbeddedLink [
|
||||||
"I parse the youtube embedded links in a hedgedoc document."
|
"I parse the youtube embedded links in a hedgedoc document."
|
||||||
| link linkSea |
|
| link linkSea |
|
||||||
link := '{%youtube' asPParser token trim, #any asPParser starLazy token, '%}' asPParser token trim.
|
link := self youtubeEmbeddedLinkOpen,
|
||||||
linkSea := link sea ==> #second.
|
#any asPParser starLazy token trim,
|
||||||
^ linkSea star
|
self youtubeEmbeddedLinkClose.
|
||||||
|
linkSea := link islandInSea star.
|
||||||
|
^ linkSea
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
HedgeDocGrammar >> youtubeEmbeddedLinkClose [
|
||||||
|
^ '%}' asPParser token
|
||||||
|
]
|
||||||
|
|
||||||
|
{ #category : #accessing }
|
||||||
|
HedgeDocGrammar >> youtubeEmbeddedLinkOpen [
|
||||||
|
^ '{%youtube' asPParser token
|
||||||
]
|
]
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
Class {
|
Class {
|
||||||
#name : #HedgeDocGrammarExamples,
|
#name : #HedgeDocGrammarExamples,
|
||||||
#superclass : #Object,
|
#superclass : #Object,
|
||||||
#category : #MiniDocs
|
#category : #'MiniDocs-Examples'
|
||||||
}
|
}
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
HedgeDocGrammarExamples >> hedgeDocParseYoutubeEmbeddedLinkExample [
|
HedgeDocGrammarExamples >> hedgeDocParseYoutubeEmbeddedLinkExample [
|
||||||
<gtExample>
|
<gtExample>
|
||||||
| aSampleString parsedString parsedCollection |
|
| aSampleString parsedStringTokens parsedCollection |
|
||||||
aSampleString := '{%youtube 1aw3XmTqFXA %}'.
|
aSampleString := '{%youtube 1aw3XmTqFXA %}'.
|
||||||
parsedString := HedgeDocGrammar new youtubeEmbeddedLink parse: aSampleString.
|
parsedStringTokens := HedgeDocGrammar new youtubeEmbeddedLink parse: aSampleString.
|
||||||
parsedCollection := parsedString first.
|
parsedCollection := parsedStringTokens first.
|
||||||
self assert: parsedCollection size equals: 3.
|
self assert: parsedCollection size equals: 3.
|
||||||
self assert: parsedCollection first value equals: '{%youtube'.
|
self assert: parsedCollection first value equals: '{%youtube'.
|
||||||
self assert: parsedCollection second class equals: PP2Token.
|
self assert: parsedCollection second class equals: PP2Token.
|
||||||
self assert: parsedCollection third value equals: '%}'.
|
self assert: parsedCollection third value equals: '%}'.
|
||||||
^ parsedString
|
^ parsedStringTokens
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user