HtmlInlineRenderer escape
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.3k
- Forks
- 510
- Avg merge
- 8d 5h
- Merged PRs (30d)
- 5
Description
Default implementation not using EnableHtmlEscape in HtmlInlineRenderer and HtmlBlockRenderer. I have a markdown like this:
This code defines a static class Connections that contains the following fields and methods:
- The NewCommand field, which is an EventHandler<Command> event. This event is raised when a new command is received from an IoT device.
- The Things field, which is a list of IoT objects. This list stores all connected IoT devices.
After default Markdown.ToHtml() <Command> is not escaped.
So I have to do a custom HtmlInlineRenderer that does renderer.WriteEscape
Why HtmlRenderer is not reusable? I would like to have a class member render to reuse it on each incoming text instead of creating 4 objects each time:
public string MakeMessage(string text)
{
var Writer = new StringWriter();
var Render = new HtmlRenderer(Writer);
Render.ObjectRenderers.Replace<HtmlBlockRenderer>(new CustomHtmlBlockRenderer());
Render.ObjectRenderers.Replace<HtmlInlineRenderer>(new CustomHtmlInlineRenderer());
Markdown.Convert(text, Render, Pipeline);
return Writer.ToString();
}
It would be nice to have Render.Reset()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading HtmlInlineRenderer and HtmlBlockRenderer around EnableHtmlEscape, then inspect HtmlRenderer and Markdown.Convert for how renderer state is managed. Reproduce the unescaped example and examine whether renderer reuse is a separate concern. Done means the requested escaping behavior is defined and covered, with any reset or reuse behavior validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100