The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Adding code to comments a’la CSS-tricks

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #32690

    Hi all

    First post here but been a long time reader of Chris’ blog. I appreciate my query isn’t solely CSS, but I figured it might be a good forum to get help from people who may have done something similar. Googling my issue isn’t helping due to the terms used.

    Ultimately the query is about how to add a code block to a comments form so users can add markup examples in their response. The conundrum I have is that I need to escape out what the user enters in so the markup is preserved and isn’t written out as html when I write the comment back to the page.

    The structure of a comment may potentially be:

    [some html or css example]
    [more text]

    But if I tell my users to wrap their code in something like code tags of some kind, then when I escape the comment, surely I’ll end up with &#lt;code&#gt;, which I presumably can’t then reference in my CSS to style it? So how do I escape a comment, but style part of that comment differently?

    The user at the moment enters their comments in a simple HTML textarea that my form sanitises in php and then submits to the MySQL database.

    Would really appreciate any suggestions or links on the subject!


    (p.s. Yes, I could just use an open source blog or comments module, but I won’t learn anything from that, which is 50% of the goal of my website!)

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.