Skip to content

Improve RedCloth integration #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nathany opened this issue Oct 27, 2012 · 2 comments
Open

Improve RedCloth integration #65

nathany opened this issue Oct 27, 2012 · 2 comments
Milestone

Comments

@nathany
Copy link
Contributor

nathany commented Oct 27, 2012

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

@korny
Copy link
Member

korny commented Mar 10, 2013

Seems very over-complicated. Also, I think RedCloth integration of such a scale should be its own gem (coderay-redcloth or something).

=> Future

@nathany
Copy link
Contributor Author

nathany commented Mar 11, 2013

There's also a completely new implementation of RedCloth https://github.com/jgarber/redcloth-parslet and integration with Redcarpet and such. IMO, just documenting how to use them together might be a good approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants