Util.RawHtml and whitespaces
Hi guys,
It seems that Util.RawHtml will add formatting to the output of the provided XML.
The problem here is, that I want to display syntax highlighted code, which is contained in a <pre>. [1]
Because of the formatting, the output looks rather weird (the pre-tag will retain the whitespaces that were introduced by the XML formatting)
I would suggest to add an optional parameter to RawHtml, to tell LinqPad to use:
btw, I am using the current Beta (4.42.01)
[1] If you found this thread searching for syntax highlighting in LinqPad, I am using ColorCode http://colorcode.codeplex.com/
It seems that Util.RawHtml will add formatting to the output of the provided XML.
The problem here is, that I want to display syntax highlighted code, which is contained in a <pre>. [1]
Because of the formatting, the output looks rather weird (the pre-tag will retain the whitespaces that were introduced by the XML formatting)
I would suggest to add an optional parameter to RawHtml, to tell LinqPad to use:
xml.ToString(SaveOptions.DisableFormatting)Or simply always use SaveOptions.DisableFormatting for RawHtml.
btw, I am using the current Beta (4.42.01)
[1] If you found this thread searching for syntax highlighting in LinqPad, I am using ColorCode http://colorcode.codeplex.com/
Comments
btw, are you aware that LINQPad has a built-in feature for displaying syntax-colored text?
PanelManager.DisplaySyntaxColoredText ("var x = \"foo\"", SyntaxLanguageStyle.CSharp);
SyntaxLanguageStyle can be one of the following:
None, CSharp, VB, FSharp, SQL, ESQL, CSS, HTML, JavaScript, PowerShell, Python, XAML, XML
You can run this query and should see some whitespace before the text: Oh and I know about PanelManager.DisplaySyntaxColoredText, but it doesn't put the text in the ordinary HTML-based output, but into extra "tabs".
Sometimes, I want to show some scripts in a table, and RawHtml is doing the job almost perfectly. :-)
www.linqpad.net/beta.aspx
One tiny little problem still remains:
The overload of RawHtml, that takes a string does not preserve whitespaces.
When you run the following query, you should see that there is no whitespace between "blue" and "red". When I change it to use the overload that takes an XElement (parsing it with LoadOptions.PreserveWhitespace), the output is as expected:
I simply changed it in my utility library to use the XElement-overload, so I do not need that fix.
It isn't really obvious, though and the fix seems to be quite straight forward.
Thx for your work on this awesome tool.
Cheers,
Robert