Skip to content

Improve RedCloth integration #65

Open
@nathany

Description

@nathany

Nicola Racco has written another RedCloth CodeRay extension which has more features.

I modified the for_redcloth.rb file so that the user can specify language in a similary way: LANG[SEQUENCE] (where SEQUENCE is in the format :option=value), so all options of the encoder could be specified in SEQUENCE. But it doesn't work.
For example, RedCloth completely ignores: bc[ruby:line_numbers=table:highlight_lines=1,3-5] (I believe that ':', '=', ' ' characters are not allowed).
It could be possible to use another 'work-around' with a syntax like element[LANG_NAME]<!c:SEQUENCE>. For example:

bc[ruby]. <!c:line_numbers=table:highlight_lines=1,2-3>
def a
  a = 3
end

In this way the opts[:text] variable will begin with this 'special' tag. - @nicolaracco


There may be options like :wrap and :line_numbers that you don't want the user to control via the markup. They could destroy a wiki page or a blog's comment with that. So, we should only support the options that are really useful and safe.

I don't think additional syntaxes are a good idea. You'd have to choose between something that could easily be the start of some real code, so it gets in the way, or something that is hard to remember. Either way, it doesn't really look integrated with Textile.

My feeling is that we should reduce the user options to a minimum. While I can see the use of :highlight_lines, I doubt somebody would need line numbers, or no line numbers in a specific code snippet. Can you describe a real use case?

So, I vote for simplicity. - @korny


Well, for line numbering my blog is a real use case :) In my blog most of the code blocks are about 10/15 lines, so line numbering is unnecessary, but in the post Extending RedCloth with CodeRay, there's a code snippet of 60 lines, and line numbering is useful only in that case.

In any case, beyond line numbering, I also vote for simplicity. The problem is to choose a good position (style, class etc.) for these options.

The solution I proposed in my blog uses only the options 'ln' and 'h' placed in the class attribute, like:

bc[ruby](ln h3 h8 h4_7). code

but it's a rough solution (it hides some css classes), however I think options in that form are 'simple' to remember. Maybe we could use the style attribute:

bc[ruby]{cr_title: mytitle; cr_bold: false; cr_highlight: 3 4-7; }. code

Even when you choose to not use option setting, it could be useful setting a set of 'default options'. For example, in an initializer:

require 'coderay'
require 'coderay/for_redcloth.rb'
CodeRay::ForRedCloth::install { :line_numbers => :table, :bolding => false, :hint => :debug }

@nicolaracco

From Redmine: http://odd-eyed-code.org/issues/233

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions