Saturday, March 7, 2009

Windows Live Writer Code Formatter Plugin 2.0

Steve Dunn mentions in this post that he has updated the Code Formatter Plugin to version 2.0.

Here I try it with the code snippet from XREF_test.dvb that shows how to figure out with VBA if an Xref is Attached or Overlay with the help of some AutoLISP.

Sub xref_test()
    Dim ps_str As String
    Dim po_blk As AcadBlock
    Dim po_blkref As AcadBlockReference
    Dim pi_dxf70 As Integer
    Dim pv_1 As Variant
    Dim userr1 As Integer
    
    ThisDrawing.Utility.GetEntity po_blkref, pv_1
    
    userr1 = ThisDrawing.GetVariable("USERR1")
    Set po_blk = ThisDrawing.Blocks(po_blkref.Name)
    ps_str = "(SETVAR ""USERR1"" (cdr (assoc 70 (tblsearch ""BLOCK"" """ & po_blkref.Name & """)))) "
    ThisDrawing.SendCommand ps_str
    pi_dxf70 = ThisDrawing.GetVariable("USERR1")
    
    ps_str = "(SETVAR ""USERR1"" " & userr1 & ") "
    ThisDrawing.SendCommand ps_str
    
    If pi_dxf70 = 44 Then MsgBox "XREF " & po_blk.Name & " is Overlaid."
    If pi_dxf70 = 36 Then MsgBox "XREF " & po_blk.Name & " is Attached."
End Sub

But if I select the code above and paste it into Notepad everything ends up on one row. Wondering if it can be something in my blogger template or that I use Windows Internet Explorer 8 RC1.

Update. I got a reply from Steve as he could not add it as a comment due to the markup tags:

Hi Jimmy,

Thanks for trying out the new version.  I initially copied and pasted your code using FireFox and it was fine in notepad.  I then tried with IE8 and saw the same problem as you did. I also tried this in IE6 and got the same results. 

The HTML that the plug-in writes looks correct - that is, all line breaks are <br/>'s.

I did notice that the initial <pre> style had two semi-colons which isn't right but didn't affect the rendering or the copying.

I boiled the offending HTML down to the following:

<pre><span>Line 1<br /></span><span>Line 2<br /></span></pre>

Creating an HTML file with just this line exhibits the issues.

Loading this in the W3C validator reported no errors.

From what I've read about the pre tag, the text in the middle IS affected by markup.  In fact, IE is rendering the line breaks, but just not treating them as cr/[lf]'s in the clipboard [straight text] text (pasting into Wordpad works correctly as the RTF that IE copies IS correct!)

I looked at some of your older posts, for instance, http://blog.jtbworld.com/2007/12/solution-for-google-analytics-tracking.html from December 13th 2007.  This has the same problem.

I also tried one of my recent posts using the latest version of the plugin.  Interestingly, the HTML in my post contained real CR/LF's codes instead of <br /> markup.  I then changed the language to VB.NET, but still the same (and VBScript, but still the same).

I don't know whether this has anything to do with it, but there's a setting in blogger under settings/formatting/convert line breaks.  Mine's set to No.  I previously had this set to yes and my blogger template had massive gaps between the generated code and the next written paragraph.

I did find that we're not alone with this issue. http://stackoverflow.com/questions/136443/why-doesnt-ie7-copy-precode-blocks-to-the-clipboard-correctly

Looks like a complicated issue, although it doesn't resolve the [likely irrelevant] fact that you've got <br />s and I haven't.  Maybe you've got some other javascript running?

Anyway, hope this helps.

Cheers,

Steve.

I changed the Blogger settings convert line breaks to No and now it works as expected. Not sure if it will break any of the formatting on some of the older posts though.

Thanks Steve!

No comments:

Post a Comment