Justin Makes a Ruby Program Part 2

Elliot Temple replied to my last post with several good comments and I wanted to address them.

Elliot Temple’s comments have a yellow background:

I would write:

You’re mutating state for no reason and making it longer.

Great suggestion, thanks!

For sanitizing, shouldn’t you keep div and span tags? I’ve used those for formatting sometimes (offhand I know some blockquotes use divs). Also shouldn’t you allow hr tags? I use those.

All good suggestions, thanks. I don’t really have a good understanding of HTML and CSS yet so I’m not good at judging things like what’s important to include in a sanitize list. I was mostly judging by noting that the output files looked good enough, but the hr tag in particular helps with a problem I’d noticed on some of the pages so thanks for pointing that out.

The <hr> tag was not agreeable to the Upmark gem, so I added the following to handle that issue

Also shouldn’t you convert h1 and h2 tags similar to the h3?

Yeah it doesn’t hurt to do them all!

Elliot also suggested I handle the RegEx for header tags by just doing substitution instead of using a block. This is what I came up with for the header issue with Elliot’s help. (my syntax highlighter isn’t handling
#{} well so ignore the highlighting on this code snippet):

And I don’t understand why the sanitizer doesn’t have b, i, u, em, strong on the list.

Fixed thanks.

Thanks for your help Elliot!

With regards to code in blog comments, Markdown has been activated in the comments, and it plays nicely with my syntax highlighting plugin! (I’m using Crayon if anyone is curious)

Inline code syntax is `back-ticks like this`

and which produces code styled like this

and for blocks of code

```

its a fence of three backticks around your code like this

```

Leave a Reply

Your email address will not be published.