New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow parsing of fenced code blocks inside lists #232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please add a unit test for your code sample (mentioned in the description:
To prevent the warning message regarding the deprecation of the
mysql_native_password
plugin from being logged, you have a couple of options:Option 1: Update User Authentication Method:
Connect to your MySQL server using a MySQL client, such as the
mysql
command-line tool:mysql -u username -pOnce connected, run the following command to alter the user's authentication method:
ALTER USER 'username'@'hostname' IDENTIFIED WITH caching_sha2_password;Replace
'username'
with the actual username and'hostname'
with the appropriate hostname or IP address. If you want to update for all users, replace'username'@'hostname'
with'*'@'%'
.Repeat this process for each user on your MySQL server.
case FencedCodeBlock code: | ||
{ | ||
builder.OpenElement(ElementIndex++, "li"); | ||
var text = code.CreateCodeBlockText(); | ||
|
||
builder.OpenComponent<MudCodeHighlight>(ElementIndex++); | ||
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Text), text); | ||
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Language), code.Info ?? string.Empty); | ||
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Theme), CodeBlockTheme); | ||
builder.CloseComponent(); | ||
builder.CloseElement(); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all thank you for making the PR.
But sorry. this implementation is just copy paste from lines 178-182 and it cannot be accepted. Please do the following:
- create a function
RenderFencedCodeBlock(RenderTreeBuilder, FencedCodeBlock)
and use it on the line 176
// 176
case FencedCodeBlock code:
{
RenderFencedCodeBlock(builder, code);
break;
}
// 464 (or somewhere else at the end)
protected virtual void RenderFencedCodeBlock(in RenderTreeBuilder builder, in FencedCodeBlock code)
{
var text = code.CreateCodeBlockText();
builder.OpenComponent<MudCodeHighlight>(ElementIndex++);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Text), text);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Language), code.Info ?? string.Empty);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Theme), CodeBlockTheme);
builder.CloseComponent();
}
- Instead of your code please use this (there is no need to create a new
li
element for the code block, at least this is how it should work in your example):
case FencedCodeBlock x:
{
RenderFencedCodeBlock(builder, x);
break;
}
Then it will look a bit similar to what is rendered on GitHub. However, the line "Replace username
.." should not have the "li" tag, so if you can also fix this problem it would be nice. If you do not want to do it, then I can do it in a separate PR. To give you a hint - it can be determined by "Parent.Order" properties of ParagraphBlock or FencedCodeBlock is the parent is ListItemBlock
Will be fixed in #236 |
While working with the Mudblazor.Markdown package, I discovered that, if a block of Markdown text being parsed included a fenced code block within a list, the code block would not be rendered in the output. This pull request is designed to correct this issue.
The following Markdown can be used as an example: