mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
ba634cbf11
We use margin bottom in osu-web markdown paragraph[1] as reference for this line spacing value. The value from osu-web itself is 1.5em[2]. Because the base font size of the paragraph is 14px[3][4], the actual value is 14 * 1.5 = 21px [1]376cac43a0/resources/assets/less/bem/osu-md.less (L230)
[2]376cac43a0/resources/assets/less/variables.less (L58)
[3]376cac43a0/resources/assets/less/bem/osu-md.less (L9)
[4]376cac43a0/resources/assets/less/variables.less (L161)
76 lines
3.0 KiB
C#
76 lines
3.0 KiB
C#
// 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;
|
|
using Markdig.Extensions.AutoIdentifiers;
|
|
using Markdig.Extensions.Tables;
|
|
using Markdig.Extensions.Yaml;
|
|
using Markdig.Syntax;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Containers.Markdown;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
namespace osu.Game.Graphics.Containers.Markdown
|
|
{
|
|
public class OsuMarkdownContainer : MarkdownContainer
|
|
{
|
|
public OsuMarkdownContainer()
|
|
{
|
|
LineSpacing = 21;
|
|
}
|
|
|
|
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
|
{
|
|
switch (markdownObject)
|
|
{
|
|
case YamlFrontMatterBlock _:
|
|
// Don't parse YAML Frontmatter
|
|
break;
|
|
|
|
case ListItemBlock listItemBlock:
|
|
var childContainer = CreateListItem(listItemBlock, level);
|
|
container.Add(childContainer);
|
|
foreach (var single in listItemBlock)
|
|
base.AddMarkdownComponent(single, childContainer.Content, level);
|
|
break;
|
|
|
|
default:
|
|
base.AddMarkdownComponent(markdownObject, container, level);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public override SpriteText CreateSpriteText() => new OsuSpriteText
|
|
{
|
|
Font = OsuFont.GetFont(size: 14),
|
|
};
|
|
|
|
public override MarkdownTextFlowContainer CreateTextFlow() => new OsuMarkdownTextFlowContainer();
|
|
|
|
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new OsuMarkdownHeading(headingBlock);
|
|
|
|
protected override MarkdownFencedCodeBlock CreateFencedCodeBlock(FencedCodeBlock fencedCodeBlock) => new OsuMarkdownFencedCodeBlock(fencedCodeBlock);
|
|
|
|
protected override MarkdownSeparator CreateSeparator(ThematicBreakBlock thematicBlock) => new OsuMarkdownSeparator();
|
|
|
|
protected override MarkdownQuoteBlock CreateQuoteBlock(QuoteBlock quoteBlock) => new OsuMarkdownQuoteBlock(quoteBlock);
|
|
|
|
protected override MarkdownTable CreateTable(Table table) => new OsuMarkdownTable(table);
|
|
|
|
protected override MarkdownList CreateList(ListBlock listBlock) => new MarkdownList
|
|
{
|
|
Padding = new MarginPadding(0)
|
|
};
|
|
|
|
protected virtual OsuMarkdownListItem CreateListItem(ListItemBlock listItemBlock, int level) => new OsuMarkdownListItem(listItemBlock, level);
|
|
|
|
protected override MarkdownPipeline CreateBuilder()
|
|
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
|
|
.UseEmojiAndSmiley()
|
|
.UseYamlFrontMatter()
|
|
.UseAdvancedExtensions().Build();
|
|
}
|
|
}
|