mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 13:27:20 +08:00
add OsuMarkdownFencedCodeBlock
Reference :
d56352aeef/resources/assets/less/bem/osu-md.less (L41-L45)
This commit is contained in:
parent
65aa01866e
commit
6959f2a8cc
@ -49,5 +49,18 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
markdownContainer.Text = "[Welcome to osu!](https://osu.ppy.sh)";
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFencedCodeBlock()
|
||||
{
|
||||
AddStep("Add Code Block", () =>
|
||||
{
|
||||
markdownContainer.Text = @"```markdown
|
||||
# Markdown code block
|
||||
|
||||
This is markdown code block.
|
||||
```";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownContainer : MarkdownContainer
|
||||
{
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new OsuMarkdownTextFlowContainer();
|
||||
|
||||
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
||||
{
|
||||
switch (markdownObject)
|
||||
@ -28,6 +26,10 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
}
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new OsuMarkdownTextFlowContainer();
|
||||
|
||||
protected override MarkdownFencedCodeBlock CreateFencedCodeBlock(FencedCodeBlock fencedCodeBlock) => new OsuMarkdownFencedCodeBlock(fencedCodeBlock);
|
||||
|
||||
protected override MarkdownPipeline CreateBuilder()
|
||||
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
|
||||
.UseEmojiAndSmiley()
|
||||
|
@ -0,0 +1,44 @@
|
||||
// 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 Markdig.Syntax;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownFencedCodeBlock : MarkdownFencedCodeBlock
|
||||
{
|
||||
private Box background;
|
||||
private MarkdownTextFlowContainer textFlow;
|
||||
|
||||
public OsuMarkdownFencedCodeBlock(FencedCodeBlock fencedCodeBlock)
|
||||
: base(fencedCodeBlock)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
// TODO : Change to monospace font to match with osu-web
|
||||
background.Colour = colourProvider.Background6;
|
||||
textFlow.Colour = colourProvider.Light1;
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground()
|
||||
{
|
||||
return background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow()
|
||||
{
|
||||
return textFlow = base.CreateTextFlow();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user