none
Code snippet formatting RRS feed

  • Question

  • Hi,

    I have written a couple of articles using Live Writer and inserted code snippets using the Vildosola plugin. When viewing the articles in TechNet on the Edit tab the formatting is fine. The formatting is lost when reading the article normally and the code shows as black text in a smaller font. All the inline styling is definitely there but no having any effect.

    Here is one of the articles Hosting a WCF Data Service... If anyone has any ideas it would be greatly appreciated. I've tried deleting and adding the code again using the 'Format code' button on the editor but that isn't working for me either. I'm pretty sure I am missing something obvious but can't work out what it is.

    Wednesday, March 13, 2013 2:09 AM

Answers

  • This is unfortunately a known issue and we don't have an ETA for getting it resolved yet.

    The only workaround I'm aware of is to replace RGB color values in your HTML code with color names.

     <authentication mode="None"/>

    For example, to get "more" red, you would have to change the current HTML code from:

    <span style="color: rgb(255, 0, 0);">mode</span>

    to

    <span style="color: red;">mode</span>

     

    Cheers,
    Markus


    Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

    • Marked as answer by JayChase Tuesday, April 2, 2013 2:53 AM
    Sunday, March 31, 2013 5:31 PM

All replies

  • I see in the HTML that your code is in <pre>...</pre> tags. Formatting in these tags, especially colors, must get ignored.

    I am having similar problems with tables, where everything looks fine in the editor, but when you click "Save" all formatting is lost. I used to be able to edit text in the tables, but now I cannot edit anything in the entire article without all table formatting being lost. All HTML in the <table>...</table> tags seems to be ignored, especially colors. But this behavior is only in the last month, so I am waiting for whatever bug was introduced to get fixed before I edit any articles with tables. This may be a similar situation. I may be able to confirm if I can find another Wiki article with colorized code. But if it is the same, there is no workaround. We have to wait for them to fix the Wiki editor (or restore the previous behavior).

    This is the forum post where I reported my problems with tables in Wiki articles. I never resolved the problem.

    http://social.technet.microsoft.com/Forums/en-US/tnwiki/thread/22e0c240-0bc0-4b17-8c88-558abb428a2a


    Richard Mueller - MVP Directory Services


    Wednesday, March 13, 2013 12:24 PM
    Moderator
  • Thanks for the reply. I had a closer look in FireFox and you are right about the pre tags. Also I had thought the inline styling was there but it looks like it is getting stripped out at some point.
    Wednesday, March 13, 2013 1:29 PM
  • I found a Wiki article with colorized code that was last modified this past November here:

    http://social.technet.microsoft.com/wiki/contents/articles/2216.windows-server-2008-r2-powershell-backup.aspx

    I experimented with this article to test my theory. Before I updated this article, one of the code snippets appeared as follows:

    The code has a border and variables are colored. I modified this article by removing a blank line in the text (not in any code section). In edit mode everything looked fine. After I saved, however, all of the code formatting, for all code snippets in the article, was gone. Then the same snippet appeared as follows:

    Now the border and colors are gone. I reverted the article, which restored the code formatting as it appeared in November. As I suspected, no modifications can be made to this article, no matter how minor, without destroying the code formatting. This is exactly the same problem as I have experienced with tables. Something changed, possibly in January, that causes this.


    Richard Mueller - MVP Directory Services

    Wednesday, March 13, 2013 2:59 PM
    Moderator
  • This is unfortunately a known issue and we don't have an ETA for getting it resolved yet.

    The only workaround I'm aware of is to replace RGB color values in your HTML code with color names.

     <authentication mode="None"/>

    For example, to get "more" red, you would have to change the current HTML code from:

    <span style="color: rgb(255, 0, 0);">mode</span>

    to

    <span style="color: red;">mode</span>

     

    Cheers,
    Markus


    Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

    • Marked as answer by JayChase Tuesday, April 2, 2013 2:53 AM
    Sunday, March 31, 2013 5:31 PM
  • Hi. Thanks for the workaround. I will have a go with that.
    Tuesday, April 2, 2013 2:53 AM
  • For PowerShell script code, we do have a working solution: How to Include PowerShell Script Code Into a Wiki Article.

    Cheers,
    Markus


    Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

    Tuesday, April 2, 2013 5:24 PM
  • I modified the Wiki article that has PowerShell code that I linked above:

    http://social.technet.microsoft.com/wiki/contents/articles/2216.windows-server-2008-r2-powershell-backup.aspx

    I replaced all colors specified by rgb() values with color names. This worked, the formatting was not lost. The only problem was finding a color name that matched the rgb values. This was not easy, as there are over 16 million rgb values, but only 147 color names. I just got as close as I could, then used global find and replace in the HTML editor to update the article.


    Richard Mueller - MVP Directory Services

    Saturday, April 6, 2013 3:28 PM
    Moderator