CommunityToolkit / CommunityToolkit/ColorCode-Universal

Wrap source code in code tags

Đang mở
#35 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
265
Fork
57
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Referencing [this issue on markdown-colorcode](https://github.com/wbaldoumas/markdown-colorcode/issues/83), this package overwrites some of the [behavior used in Markdig](https://github.com/xoofx/markdig/blob/203cfd6508d4f8fca510edd2f66f229ada2c25ad/src/Markdig.Benchmarks/spec.md#fenced-code-blocks) that appears to be in line with [the CommonMark spec](https://spec.commonmark.org/0.30/#example-142), that is, this package does not wrap code using a `code` element. Additionally, if a language is present, the spec specifies a `class="language-[lang]"` attribute as well.

I have not started a fork because I am not sure whether this would be a breaking change or not, however, the general change seems rather simple, adding the following methods to `HtmlClassFormatter` and then wrapping the inner text in `WriteHeader` and `WriteFooter`.

```csharp
private void WriteHeaderCodeStart(ILanguage language)
{
WriteElementStart("code", language.CssClassName);
}

private void WriteHeaderCodeEnd()
{
WriteElementEnd("code");
}
```

In my case, this would make it easier to enforce consistent styling across my app.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.