none
Insert HTML now ignores styles RRS feed

  • Question

  • I never liked the "Insert Code Block" feature. In the past it used a proportional font and messed up indenting and spacing. Since last May I have used the "Insert HTML" feature instead to insert code. I have scripts to convert a text file into HTML. I specify a fixed width font, maintain all indenting and spacing, specify a border, and I added colorization.

    After the recent forum update, I noticed that the "Insert Code Block" now uses a fixed width font. Great. Thanks for that. Of course, the colorization for PowerShell is still messed up.

    However, I just noticed that all code I've inserted in all of my replies since the update using the "Insert HTML" button no longer use the styles I specified. All of my replies now use a proportional font, the indenting and spacing is now reduced/modified, and there is no border. Only the colorization remains. My old replies seem to be fine, but new ones have the style specifications stripped out.

    Specifically, I recently inserted HTML where the first line was:

    <p style="font-family:Courier New,Courier;border:1px solid black">


    When I noticed my code looked wrong, I checked the HTML in my reply and found the above was replaced with this:

    <p style="border-bottom:black 1px solid;">

    Maybe I will eventually decide to use the "Insert Code Block", but then I will be at the mercy of styles beyond my control that I cannot see. For example, I will get colorization like the below PowerShell snippet:

    $inputFile = Import-CSV  C:\test.csv
    foreach($line in $inputFile){ 
        New-ADUser `
            -SamAccountName $line.UserName `
            -name $line.FullName `
            -AccountPassword (ConvertTo-SecureString `
            -AsPlainText "Password" `
            -Force `
            -Enabled $true `
            -Path $line.ou `
            -DisplayName $line.FullName `
            -GivenName $line.FirstName `
            -Surname $line.SurName `
            -UserPrincipalName $line.UserPrincipalName `
            -PassThru
        $groups=$line.groups.Split('|')
        foreach($group in $groups){
            Add-ADGroupMember -Identity $group -Member $line.UserName
        }
    }

    I realize I'm the only person that uses "Insert HTML" to insert code, but lots of other people fix problems or modify their replies using "Insert HTML". I'm sure other people in the past used "Insert Code Block" first, then modified it to use a fixed width font using "Insert HTML".

    What specifically does the new editor do with HTML? Why are my styles modified? What are we allowed to do with "Insert HTML"?


    Richard Mueller - MVP Directory Services

    Wednesday, February 15, 2012 5:10 PM
    Moderator

Answers

  • I agree it is strange that your experience is different. Some of the problems I've had seem to depend on which forum I'm in (or maybe how I got there). I'm going to go back and correct the code snippets I've posted in the last few days. If I find any situations where my style was not stripped out, I'll report back. Most of my experiements have been in the sandbox so far, but I noticed the problem (and fixed it) in the Scripting Guy's forum.

    This problem really only affects me, and I now have a solution. But I'd like to know what seems to cause the Insert HTML feature to modify my style, as I believe others use this feature to fix things, including fonts.


    Richard Mueller - MVP Directory Services

    Thursday, February 16, 2012 6:46 PM
    Moderator

All replies

  • When I go to insert html and put this in

    <p style="font-family:Courier New,Courier;border:1px solid black;">one</p>

    It looks like this

    one

    So it seems to retain the font family etc at least for me.  I don't understand exactly the comment about fixed width font. We already know about the powershell colorizer issue, thanks for letting us know again.


    Community Forums Program Manager

    Wednesday, February 15, 2012 6:18 PM
    Answerer
  • I just used Insert HTML in this TechNet Sandbox forum thread. I duplicates my experiece:

    http://social.technet.microsoft.com/Forums/en-US/tnsandbox/thread/8a15ded7-1d34-4b11-9996-68cad0794cf1

    After I entered the first sentence in the question, I used "Insert HTML" to insert the following (pasted using "Insert Code Block"):

    <p style="font-family:Courier New,Courier;border:1px solid black">
    <span style="color: blue">Option</span> <span style="color: blue">Explicit</span><br />
    <br />
    <span style="color: blue">Dim</span> arrValues(), i, j<br />
    <br />
    <span style="color: blue">For</span> j = 0 To 3<br />
    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">ReDim</span> <span style="color: blue">Preserve</span> arrValues(1, j)<br />
    &nbsp;&nbsp;&nbsp;&nbsp;arrValues(0, j) = j + 1<br />
    &nbsp;&nbsp;&nbsp;&nbsp;arrValues(1, j) = j + 100<br />
    <span style="color: blue">Next</span><br />
    <br />
    <span style="color: blue">For</span> i = 0 To 1<br />
    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">For</span> j = 0 To 3<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Wscript.Echo CStr(i) &amp; <span style="color: #a31515;">&quot;,&quot;</span> &amp; CStr(j) &amp; <span style="color: #a31515;">&quot;: &quot;</span> &amp; arrValues(i, j)<br />
    &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">Next</span><br />
    <span style="color: blue">Next</span><br />
    </p>
    <pre>-----</pre>
    <p><br /></p>

    The HTML I inserted specifies Courier New and a border, which gets stripped out. When I edit the Sandbox message and switch to HTML I see the following:

    <p>Here is a VBScript code&nbsp;example, using the Insert HTML feature:</p><p></p><p style="border-bottom:black 1px solid;"><span style="color:blue;">Option</span> <span style="color:blue;">Explicit</span><br /><br /><span style="color:blue;">Dim</span> arrValues(), i, j<br /><br /><span style="color:blue;">For</span> j = 0 To 3<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">ReDim</span> <span style="color:blue;">Preserve</span> arrValues(1, j)<br />&nbsp;&nbsp;&nbsp;&nbsp;arrValues(0, j) = j + 1<br />&nbsp;&nbsp;&nbsp;&nbsp;arrValues(1, j) = j + 100<br /><span style="color:blue;">Next</span><br /><br /><span style="color:blue;">For</span> i = 0 To 1<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">For</span> j = 0 To 3<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Wscript.Echo CStr(i) &amp; <span style="color:#a31515;">","</span> &amp; CStr(j) &amp; <span style="color:#a31515;">": "</span> &amp; arrValues(i, j)<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">Next</span><br /><span style="color:blue;">Next</span><br /></p><pre>-----</pre><p>This example looks fine before I Submit.</p><p></p><hr class="sig" /><p>Richard Mueller - MVP Directory Services</p><br />

    Well, that didn't work (different issue), but here is the first line of what I pasted as modified when I submitted:

    <p style="border-bottom:black 1px solid;">

    This is modified when I Submit. Older replies where I used the style above before the last forum update seem to be OK.


    Richard Mueller - MVP Directory Services

    Wednesday, February 15, 2012 6:44 PM
    Moderator
  • I just attempted to modify the thread where I discovered this issue. The code is the same as that in the Sandbox forum that I linked above. I decided to modify the <p style> tag to match what I originally used. The code looked as I intended, with Courier New font, etc., until I clicked Submit. Then the style reverted back. My style is just not allowed now, even though it is still used in my old threads.


    Richard Mueller - MVP Directory Services

    Wednesday, February 15, 2012 7:54 PM
    Moderator
  • By experimenting in the TechNet Sandbox forum I believe I know what triggers the "Insert HTML" feature to strip out my style settings. It's my specification of a black border. If I use the following, my style is ignored and I get a proportional font (always):

    <p style="font-family:Courier New,Courier;border:1px solid black">

    -----

    If instead I use the following, I get the fixed-width font I specified, and the code is formated as I want:

    <p style="font-family:Courier New,Courier">

    -----

    I can do without the border, which I added to duplicate what the new "Insert Code Block" feature does.


    Richard Mueller - MVP Directory Services

    Thursday, February 16, 2012 5:38 PM
    Moderator
  • I was able to add a border above without it being stripped out. I wonder why you are not able to. Strange.

    Community Forums Program Manager

    Thursday, February 16, 2012 5:58 PM
    Answerer
  • I agree it is strange that your experience is different. Some of the problems I've had seem to depend on which forum I'm in (or maybe how I got there). I'm going to go back and correct the code snippets I've posted in the last few days. If I find any situations where my style was not stripped out, I'll report back. Most of my experiements have been in the sandbox so far, but I noticed the problem (and fixed it) in the Scripting Guy's forum.

    This problem really only affects me, and I now have a solution. But I'd like to know what seems to cause the Insert HTML feature to modify my style, as I believe others use this feature to fix things, including fonts.


    Richard Mueller - MVP Directory Services

    Thursday, February 16, 2012 6:46 PM
    Moderator
  • My experience in the forums seems to change every few days. I tried again in the TechNet Sandbox forum today to specify my code style using "Insert HTML" as follows:

    <p style="font-family:Courier New,Courier;border:1px solid black">

    For several days this did not work, and the style was changed when I clicked "Submit" (as explained earlier in this thread). Today, my style was retained, including the border. I just confirmed in another forum where I posted code. I assume fixes are being deployed more frequently than in the past. Or is it possible something else could account for my recent experience, since Brent never could duplicate my problem? Maybe my problem will crop up again in the future.


    Richard Mueller - MVP Directory Services

    Monday, February 20, 2012 5:15 PM
    Moderator