mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Merge pull request #20213 from frenzibyte/osu-markdown-extensions
Fix markdown container not rendering certain text correctly
This commit is contained in:
commit
7f5fe56c1d
@ -4,7 +4,9 @@
|
||||
#nullable disable
|
||||
|
||||
using Markdig;
|
||||
using Markdig.Extensions.AutoIdentifiers;
|
||||
using Markdig.Extensions.AutoLinks;
|
||||
using Markdig.Extensions.EmphasisExtras;
|
||||
using Markdig.Extensions.Footnotes;
|
||||
using Markdig.Extensions.Tables;
|
||||
using Markdig.Extensions.Yaml;
|
||||
using Markdig.Syntax;
|
||||
@ -18,6 +20,18 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownContainer : MarkdownContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows this markdown container to parse and link footnotes.
|
||||
/// </summary>
|
||||
/// <seealso cref="FootnoteExtension"/>
|
||||
protected virtual bool Footnotes => false;
|
||||
|
||||
/// <summary>
|
||||
/// Allows this markdown container to make URL text clickable.
|
||||
/// </summary>
|
||||
/// <seealso cref="AutoLinkExtension"/>
|
||||
protected virtual bool Autolinks => false;
|
||||
|
||||
public OsuMarkdownContainer()
|
||||
{
|
||||
LineSpacing = 21;
|
||||
@ -78,10 +92,22 @@ namespace osu.Game.Graphics.Containers.Markdown
|
||||
return new OsuMarkdownUnorderedListItem(level);
|
||||
}
|
||||
|
||||
// reference: https://github.com/ppy/osu-web/blob/05488a96b25b5a09f2d97c54c06dd2bae59d1dc8/app/Libraries/Markdown/OsuMarkdown.php#L301
|
||||
protected override MarkdownPipeline CreateBuilder()
|
||||
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
|
||||
.UseEmojiAndSmiley()
|
||||
.UseYamlFrontMatter()
|
||||
.UseAdvancedExtensions().Build();
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.UseAutoIdentifiers()
|
||||
.UsePipeTables()
|
||||
.UseEmphasisExtras(EmphasisExtraOptions.Strikethrough)
|
||||
.UseYamlFrontMatter();
|
||||
|
||||
if (Footnotes)
|
||||
pipeline = pipeline.UseFootnotes();
|
||||
|
||||
if (Autolinks)
|
||||
pipeline = pipeline.UseAutoLinks();
|
||||
|
||||
return pipeline.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class CommentMarkdownContainer : OsuMarkdownContainer
|
||||
{
|
||||
protected override bool Autolinks => true;
|
||||
|
||||
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new CommentMarkdownHeading(headingBlock);
|
||||
|
||||
private class CommentMarkdownHeading : OsuMarkdownHeading
|
||||
|
@ -15,6 +15,8 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
||||
{
|
||||
public class WikiMarkdownContainer : OsuMarkdownContainer
|
||||
{
|
||||
protected override bool Footnotes => true;
|
||||
|
||||
public string CurrentPath
|
||||
{
|
||||
set => DocumentUrl = value;
|
||||
|
Loading…
Reference in New Issue
Block a user