mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +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
|
#nullable disable
|
||||||
|
|
||||||
using Markdig;
|
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.Tables;
|
||||||
using Markdig.Extensions.Yaml;
|
using Markdig.Extensions.Yaml;
|
||||||
using Markdig.Syntax;
|
using Markdig.Syntax;
|
||||||
@ -18,6 +20,18 @@ namespace osu.Game.Graphics.Containers.Markdown
|
|||||||
{
|
{
|
||||||
public class OsuMarkdownContainer : MarkdownContainer
|
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()
|
public OsuMarkdownContainer()
|
||||||
{
|
{
|
||||||
LineSpacing = 21;
|
LineSpacing = 21;
|
||||||
@ -78,10 +92,22 @@ namespace osu.Game.Graphics.Containers.Markdown
|
|||||||
return new OsuMarkdownUnorderedListItem(level);
|
return new OsuMarkdownUnorderedListItem(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reference: https://github.com/ppy/osu-web/blob/05488a96b25b5a09f2d97c54c06dd2bae59d1dc8/app/Libraries/Markdown/OsuMarkdown.php#L301
|
||||||
protected override MarkdownPipeline CreateBuilder()
|
protected override MarkdownPipeline CreateBuilder()
|
||||||
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
|
{
|
||||||
.UseEmojiAndSmiley()
|
var pipeline = new MarkdownPipelineBuilder()
|
||||||
.UseYamlFrontMatter()
|
.UseAutoIdentifiers()
|
||||||
.UseAdvancedExtensions().Build();
|
.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
|
public class CommentMarkdownContainer : OsuMarkdownContainer
|
||||||
{
|
{
|
||||||
|
protected override bool Autolinks => true;
|
||||||
|
|
||||||
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new CommentMarkdownHeading(headingBlock);
|
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new CommentMarkdownHeading(headingBlock);
|
||||||
|
|
||||||
private class CommentMarkdownHeading : OsuMarkdownHeading
|
private class CommentMarkdownHeading : OsuMarkdownHeading
|
||||||
|
@ -15,6 +15,8 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
|||||||
{
|
{
|
||||||
public class WikiMarkdownContainer : OsuMarkdownContainer
|
public class WikiMarkdownContainer : OsuMarkdownContainer
|
||||||
{
|
{
|
||||||
|
protected override bool Footnotes => true;
|
||||||
|
|
||||||
public string CurrentPath
|
public string CurrentPath
|
||||||
{
|
{
|
||||||
set => DocumentUrl = value;
|
set => DocumentUrl = value;
|
||||||
|
Loading…
Reference in New Issue
Block a user