the browser-facing portion of osu!

Use correct id attribute for wiki table of content

nanaya fdb0d938 6d04830b

+12 -1
+3 -1
app/Libraries/Markdown/Osu/Extension.php
··· 46 46 $environment 47 47 ->addRenderer(ListItem::class, new Renderers\ListItemRenderer(), 10) 48 48 ->addRenderer(Table::class, new Renderers\TableRenderer(), 10) 49 - ->addEventListener(DocumentParsedEvent::class, $this->processor); 49 + // This needs to be run after AttributesExtension so it gets 50 + // correct node id attribute for table of contents. 51 + ->addEventListener(DocumentParsedEvent::class, $this->processor, -10); 50 52 51 53 if ($environment->getConfiguration()->exists('osu_extension/attributes_allowed')) { 52 54 $environment->addEventListener(DocumentParsedEvent::class, new AttributesAllowedListener());
+9
tests/Libraries/Markdown/ProcessorTest.php
··· 33 33 $this->assertSame($expectedOutput, $osuMarkdown->toIndexable()); 34 34 } 35 35 36 + public function testTocId() 37 + { 38 + $parser = new OsuMarkdown('default', osuExtensionConfig: ['attributes_allowed' => ['id'], 'generate_toc' => true]); 39 + 40 + $parsed = $parser->load('## some header {#headerid}')->toArray(); 41 + 42 + $this->assertTrue(isset($parsed['toc']['headerid'])); 43 + } 44 + 36 45 public function testTocImage() 37 46 { 38 47 $parser = new OsuMarkdown('default', osuExtensionConfig: ['generate_toc' => true]);