cloudhead / toto

the 10 second blog-engine for hackers
MIT License
1.49k stars 245 forks source link

Is there a way to preserve indention in markdown code blocks? #104

Closed benjamincharity closed 12 years ago

benjamincharity commented 12 years ago

Not really a toto issue, but I was thinking that one of you might have dealt with this.

I'm not sure if this something simple I'm missing, but when I put a block of code in markdown it left aligns all of the lines. This makes it a bit hard to read. Is this an option, or formatting issue?

ixti commented 12 years ago

Basically default rdiscount mrkdown renderer have some options but I don't remember which ones you need to pass in order to achieve your goal. I propose you to switch to redcarpet instead.This is really easy...

Just add following line into your Gemfile:

gem "redcarpet"

And pass some cool options to the toto config:

toto = Toto::Server.new do
  # ...
  set :markdown,    [:gh_blockcode, :strikethrough, :fenced_code, :no_intraemphasis]
  # ...
end

This will make your markdown really simialr to github's

benjamincharity commented 12 years ago

Adding that line into my config causes this error:

!! Unexpected error while processing request: undefined method `gh_blockcode=' for #<RDiscount:0x007ff442549cf8>

Also, does redcarpet replace rdiscount? Or simply add to it?

ixti commented 12 years ago

The options I have provided are valid to redcarpet only. When you'll add redcarpet gem into your Gemfile it will "substitute" rdiscount, so just add thta gem line and run bundle

benjamincharity commented 12 years ago

Hmm that's what I did. Still throwing the error.

ixti commented 12 years ago

can you show your config.ru file?

benjamincharity commented 12 years ago

Sure thing: https://github.com/benjamincharity/Toto-Site/blob/master/config.ru

Note: the markdown line is commented in my current file as it was causing the app error.

ixti commented 12 years ago

replace second line Bundler.setup with Bundler.require

benjamincharity commented 12 years ago

Still have the same error.

!! Unexpected error while processing request: undefined method `gh_blockcode=' for #<RDiscount:0x007f9cbbb1e450>
ixti commented 12 years ago

Sorry I was a little bit unclear. You need to put redcarpet above toto gem. And of course above rdiscount gem. Also, if you use Bundler.require - there's no ned for manual require. See gist: https://gist.github.com/1327302

benjamincharity commented 12 years ago

That fixed it! Thanks.

ixti commented 12 years ago

np :))