mirror of
https://github.com/ppy/osu.git
synced 2025-03-06 04:33:21 +08:00
use image block in markdown container
This commit is contained in:
parent
62fb09774a
commit
2344a1a411
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
@ -23,7 +24,17 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
||||
{
|
||||
case YamlFrontMatterBlock yamlFrontMatterBlock:
|
||||
container.Add(new WikiNoticeContainer(yamlFrontMatterBlock));
|
||||
return;
|
||||
break;
|
||||
|
||||
case ParagraphBlock paragraphBlock:
|
||||
// Check if paragraph only contains an image
|
||||
if (paragraphBlock.Inline.Count() == 1 && paragraphBlock.Inline.FirstChild is LinkInline { IsImage: true } linkInline)
|
||||
{
|
||||
container.Add(new WikiMarkdownImageBlock(linkInline));
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
base.AddMarkdownComponent(markdownObject, container, level);
|
||||
@ -31,8 +42,6 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new WikiMarkdownTextFlowContainer();
|
||||
|
||||
protected override MarkdownParagraph CreateParagraph(ParagraphBlock paragraphBlock, int level) => new WikiMarkdownParagraph(paragraphBlock);
|
||||
|
||||
private class WikiMarkdownTextFlowContainer : OsuMarkdownTextFlowContainer
|
||||
{
|
||||
protected override void AddImage(LinkInline linkInline) => AddDrawable(new WikiMarkdownImage(linkInline));
|
||||
|
Loading…
Reference in New Issue
Block a user