the browser-facing portion of osu!
at master 50 lines 1.4 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Libraries\Markdown\StyleBlock; 7 8use League\CommonMark\Node\Block\AbstractBlock; 9use League\CommonMark\Parser\Block\AbstractBlockContinueParser; 10use League\CommonMark\Parser\Block\BlockContinue; 11use League\CommonMark\Parser\Block\BlockContinueParserInterface; 12use League\CommonMark\Parser\Cursor; 13 14class Parser extends AbstractBlockContinueParser 15{ 16 private Element $block; 17 18 public function __construct(string $className) 19 { 20 $this->block = new Element($className); 21 } 22 23 public function getBlock(): AbstractBlock 24 { 25 return $this->block; 26 } 27 28 public function isContainer(): bool 29 { 30 return true; 31 } 32 33 public function canContain(AbstractBlock $childBlock): bool 34 { 35 return true; 36 } 37 38 public function tryContinue(Cursor $cursor, BlockContinueParserInterface $activeBlockParser): ?BlockContinue 39 { 40 $currentLine = $cursor->getLine(); 41 42 // TODO: closing block length is supposed to match opening block length which can be > 3; 43 // what's supposed to happen when they don't match currently is undefined. 44 if ($currentLine === ':::') { 45 return BlockContinue::finished(); 46 } 47 48 return BlockContinue::at($cursor); 49 } 50}