Found Cause: Live Writer with Insert Code leaving out </ in HTML Code

May 3, 2009 at 8:24 AM
Edited May 3, 2009 at 8:34 AM
Ok I've been at this for an hour now... I'm using LiveWriter.. and I've tried both Insert Code plugs-in's shown on this blog.. http://rtur.net/blog/post/2007/11/Insert-Code---your-options.aspx
The Live Writer ones below.

I didn't use to have this problem with I was on Community server, but now when I paste in HTML code, like this...

<form id="Form1" defaultfocus="textbox" runat="server">
     <
asp:textbox id="textbox1" runat="server"/>
     <
asp:textbox id="textbox2" runat="server"/>
     <
asp:button id="button1" text="Button1" runat="server"/>
</
form>

it looks fine in the preview... but on the post it removes all the "</" from the code. so it comes out like this..

<form id="Form1" defaultfocus="textbox" runat="server">
     <
asp:textbox id="textbox1" runat="server"/>
     <
asp:textbox id="textbox2" runat="server"/>
     <
asp:button id="button1" text="Button1" runat="server"/>
form>

You can see the last line is wrong. I tried it 50 different ways with the embedded style. I'm also using the Standard theme, and when I go to edit the post, it shows the correct version in black and white.

I even tried downloading the extensions bundle to use the codeformatterextension... but when I click on edit.. I get.
"wwwroot\App_Code\Extensions\CodeFormatterExtension.cs] not found"
there's not one in the zip file.

Coordinator
May 3, 2009 at 8:51 AM
I haven't used the WLW code plug-ins before, but just gave this one a try (looks like there's a few available for download).  I installed it on a computer which only has WLW 2008 on it.  I have WLW 2009 on another computer, but didn't try it.

It worked for me -- meaning when publishing the post, nothing was cut out.

Did you try that particular plug-in?

Regarding the CodeFormatterExtension not found, I've seen that error before when clicking on 'View' for CodeFormatterExtension on the Extensions tab.  I'm not sure exactly why it does that (haven't looked into it before).  Although the 'View' option I think just shows you the code for the extension, so even if it "worked", it wouldn't really show you anything too helpful.

But the way the built-in CodeFormatterExtension works, is when you compose a post, you add [code] tags like this:

[code:html]
<form id="Form1" defaultfocus="textbox" runat="server">
     <asp:textbox id="textbox1" runat="server"/>
     <asp:textbox id="textbox2" runat="server"/>
     <asp:button id="button1" text="Button1" runat="server"/>
</form>
[/code]

There's a few choices for the language.  Looking at the CodeFormatter.cs file in the App_Code\Extensions\CodeFormatter folder, it looks like the language choices are:

c#, vb, js, html, xml, tsql, msh
May 3, 2009 at 2:45 PM
Figured it out! I had installed the Extension bundle, and this Extension was causing the issue.
TypograFix 1.0 999 Improves post typography

I disabled it and now my html code works properly. I re-enable it and it removes any "<" or "/" combination from my html code.
Sep 23, 2009 at 5:36 PM
Edited Sep 23, 2009 at 5:36 PM

I had such proplem when i used CodeFormatterExtension. But i modifed source and solved it! In file "TypograFix.cs" I added this code:

if ((text[i + 1] == '/') && (text[i + 2] == '<'))
                    {
                        ++i; ++i;
                        sb.Append("&lt;");
                        sb.Append('/');
                        sb.Append('<');
                        break;
                    }

Into case bloc '<', before first line sb.Append('<'). And in file "CodeFormatter.cs" I commented line text = StripHtml(text).Trim(); in "xml" case.

Sorry for my bad language skill, gool luck.