RichTextWriter.Write(RichText, int, int) caused an immediate, unconditional StackOverflowException because it called the non-virtual Write(RichText) method due to RichText's implicit string conversion. I fixed this by invoking the virtual Write(string) method through a base TextWriter reference instead.
That revealed a bug in the derived class's virtual Write implementation. HtmlRichTextWriter.Write(string) incorrectly wrote the first char instead of the last/split char when ending the output. So, an input like "Oh, my!" would output as "Oh,Omy!".
Then I discovered that the HighlightingColor.ToCss() method omitted the background-color style because it ignored the HighlightingColor.Background property. I implemented that similar to the Foreground support.
I added the RichTextTests.ToHtmlTest() method to make sure these code paths keep working. They must not have been used before due to the unconditional StackOverflowException and mangled output. However, the ToHtml support is useful in my new RegExponent utility for testing regular expressions. It uses AvalonEdit for syntax highlighting and for generating HTML code for regex patterns, replacements, and input matches. I hope to release RegExponent soon, but it would be nice if these fixes can be merged into a new AvalonEdit NuGet release first.
RichTextWriter.Write(RichText, int, int)
caused an immediate, unconditional StackOverflowException because it called the non-virtualWrite(RichText)
method due to RichText's implicit string conversion. I fixed this by invoking the virtualWrite(string)
method through a base TextWriter reference instead.That revealed a bug in the derived class's virtual Write implementation.
HtmlRichTextWriter.Write(string)
incorrectly wrote the first char instead of the last/split char when ending the output. So, an input like "Oh, my!" would output as "Oh,Omy!".Then I discovered that the
HighlightingColor.ToCss()
method omitted the background-color style because it ignored theHighlightingColor.Background
property. I implemented that similar to the Foreground support.I added the
RichTextTests.ToHtmlTest()
method to make sure these code paths keep working. They must not have been used before due to the unconditional StackOverflowException and mangled output. However, the ToHtml support is useful in my new RegExponent utility for testing regular expressions. It uses AvalonEdit for syntax highlighting and for generating HTML code for regex patterns, replacements, and input matches. I hope to release RegExponent soon, but it would be nice if these fixes can be merged into a new AvalonEdit NuGet release first.