Method Community

 

Showing HTML as code in Solutions?

Last post 04-09-2012 9:26 AM by Anonymous. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-05-2012 6:21 PM

    Showing HTML as code in Solutions?

    I know it is possible to display HTML as HTML code in browsers rather than having it interpreted. I'm trying to get my Solution page to show a chunk of HTML code I want my users to see unrendered.

     

    Google led me to various ways of tagging my code so the browser wouldn't interpret it: 

    1. <pre> and </pre> tags

    2. <code> and </code> tags inside the pre tags

    3. escaping all the brackets by replacing "<" with "&lt;", and ">" with "&gt;"

     

    But even with all of these, the next time I view my solution the code has been interpreted! If I try <textarea> tags the contents just disappears. 

    I'm using Google Chrome, which properly displays uninterpreted code from a text file when I use the escaped brackets technique. This leads me to believe Method is doing some interpreting of its own. Any solutions?

  • 04-05-2012 7:48 PM In reply to

    Re: Showing HTML as code in Solutions?

    @smohyee -

    Can I ask why?  If the users need to edit the html of the solution, they can just click the "Html" tab of the HTML editor (March version) or the Html icon of the HTML editor (April version).

    If you don't want to use the HTML editor, just edit solutions screen, and edit the solution body text box and remove the checkbox to show as an HTML editor.  Then you should see the HTML in all its glory.

    Some context as to why you want to do this, though, would be great.

    Paul

  • 04-06-2012 11:22 AM In reply to

    Re: Showing HTML as code in Solutions?

    Well getting rid of the HTML editor does allow me to display html code, but it also gets rid of all that rich text editing. Using the HTML tab was the backup plan anyway, so I'll go with that.

    The reason I wanted to avoid that is because this solution was meant for users who potentially know nothing about HTML but would need to use it (like me!), and I wanted to be able to change the text color and indent a particular chunk of code to make it very obvious it was what I was referring to. Not a big deal.

    I'm more curious than anything. Why does the editor interpret code differently than browsers do? I mean, why is it that escaped brackets get translated into brackets and then into HTML? It's like there's an extra layer of interpretation going on. 

    And for that matter, why can I put html code in a user's email signature, but also enter things like newlines and other whitespace like it was a text editor and have it show like I put in the appropriate html tags? 

  • 04-09-2012 9:26 AM In reply to

    Re: Showing HTML as code in Solutions?

    Answer

    smohyee:
    And for that matter, why can I put html code in a user's email signature, but also enter things like newlines and other whitespace like it was a text editor and have it show like I put in the appropriate html tags?

    The editor provides everything plus the kitchen sink.  It's extremely robust so you can enter HTML into the rich text portion and it'll understand perfectly.  When you hit return after some HTML it'll understand that you're in rich text mode and that enter needs more HTML code to make it look right.

    If you remove HTML editing, and still want to input rich text, then you're going to have to know all your HTML to get it done.  HTML code is pretty simple so a couple of quick Google searches should give you the right tags.  

    My suggestion is to create your signature in the rich text designer, switch to HTML then copy and paste that code into notepad for editing later.  The HTML should be easy enough to read that you can change the colour of the text, add links or images as you need.

    ~C

Page 1 of 1 (4 items)