3

Tearing Up the Carpet

 2 years ago
source link: https://soffes.blog/tearing-up-the-carpet
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Tearing Up the Carpet — Hi, I’m Sam

Tearing Up the Carpet — Hi, I’m Sam

cover.jpg?w=1024&dpr=2&auto=format,compress

Tearing Up the Carpet

Posted on June 22, 2013

Someone asked what Markdown parser we use for Roon. Roon uses Redcarpet.

I figured it was worth expanding a bit about this though. Mainly two things Roon does that's sorta unique made possible by the fabulous Redcarpet folks.

Underline

We have underline support. As far as I know, we are the only people that support this right now. Here's how you write it:

You can underline like _this_. This is still *italic*.

This is made possible by a feature I contributed. From the Markdown spec:

Markdown treats asterisks (*) and underscores (_) as indicators of emphasis. Text wrapped with one * or _ will be wrapped with an HTML <em> tag…

We figured why not treat _this_ as underline since it's still emphasis. That way we didn't stomp on other Markdown things. The Redcarpet folks liked my patch at graciously merged it!

So most of Redcarpet is written in C. I am really bad at C. I mainly write Ruby and Objective-C (which is a lot different than plain C). I was way proud of myself for writing some passable C code.

Highlight

Something I've been doing for awhile is highlighting important parts of my blog posts. A few people call this my signature move. I'll gladly take credit, but I started doing this after I saw 37signals do this on their Basecamp marketing site years ago. (They don't any more).

Anyway, I just made <em> be a highlight instead of italics on my blog. Since people using Roon probably want actual italics instead of everything being highlighted, we need to build something.

Drew and I came up with ==this== for highlight. From Markdown's spec:

A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

I picked == since it's very easy to see and makes the text stand out. I think this fits in well with Gruber's original intent.

I scratched my neckbeard, busted out some C, and added support to Redcarpet for highlight. Again, the fantastic Redcarpet folks accepted my patch. Now Roon has highlight.

Since we invented the syntax for both of these, I doubt many other people are using it yet. That said, you totally can since it's in Redcarpet! Here's now:

Add this to your Gemfile:

gem 'redcarpet', github: 'vmg/redcarpet'

Then parse some Markdown like this:

md = Redcarpet::Markdown.new(Redcarpet::Render::HTML, highlight: true, underline: true)
md.render('This is ==highlighted== and this is _underlined_')
#=> "<p>This is <mark>highlighted</mark> and this is <u>underlined</u></p>\n"

Enjoy!

Parting Ways With Cheddar

Posted on June 22, 2013

I made this thing called Cheddar last year. I'm pretty proud of it. I wrote why I stopped working on it here. I talked about this whole process at length in Founders Talk episode 38, episode 39, and little in episode 40. (Episode 41 isn't about me. Could have sworn I took over that show.)

Anyway, I posted that I was selling Cheddar a few months back. This has been a very interesting process. I learned a lot and met some really cool people. My biggest take away is most people just wanted to find out a lot because they were curious and were just wasting my time.

Today, the money from the Cheddar sale cleared in my back account. It's official. I don't own Cheddar any more. My good friend Josh Long owns it now. He has some big plans for it. He'll be posting about it soon. I'll tweet it out when he does.

Continue reading →

© 2006-2022 Sam Soffes


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK