[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Syntax highligth with textile: Syntax+RedCloth ?

gabriele renzi

12/30/2005 6:54:00 PM

Hi gurus and nubys,

I was trying to mix RedCloth[1] with Syntax[2] and I'm
facing some small problems.
The idea is to forward parsing of <pre> tags to the HTML convertor
withouth touching the rest of the code.
I thought that I could subclass RedCloth and override #smooth_offtags
which seem quite nice since the starting <pre> tag is carried till that
point, which could allow, for example, parsing of something like
<pre lang="ruby">.

The problem is in the fact that RC escapes html entities before this
step, and thus when I call #convert on the string Syntax will tokenize
them and give back bad html.

Has someone ever faced this before and has an alternate solution?

thanks in advance.

[1]http://redcloth.ruby...
[2]http://syntax.rub...
2 Answers

Ross Bamford

12/30/2005 8:00:00 PM

0

On Fri, 30 Dec 2005 18:53:30 -0000, gabriele renzi
<surrender_it@-remove-yahoo.it> wrote:

> Hi gurus and nubys,
>
> I was trying to mix RedCloth[1] with Syntax[2] and I'm
> facing some small problems.
> The idea is to forward parsing of <pre> tags to the HTML convertor
> withouth touching the rest of the code.
> I thought that I could subclass RedCloth and override #smooth_offtags
> which seem quite nice since the starting <pre> tag is carried till that
> point, which could allow, for example, parsing of something like
> <pre lang="ruby">.
>
> The problem is in the fact that RC escapes html entities before this
> step, and thus when I call #convert on the string Syntax will tokenize
> them and give back bad html.
>
> Has someone ever faced this before and has an alternate solution?
>

Yup, don't it just suck? In the end we introduced a 'macro' concept by
which we could exempt sections of code from formatting filters.

Have a browse around here:

http://rubyforge.org/cgi-bin/viewcvs.cgi/rote/lib/rote/...

Particularly inside 'page.rb' and the 'filters' directory, which has
various filters including syntax and redcloth.

--
Ross Bamford - rosco@roscopeco.remove.co.uk

gabriele renzi

12/31/2005 2:44:00 AM

0

Ross Bamford ha scritto:
> On Fri, 30 Dec 2005 18:53:30 -0000, gabriele renzi
> <surrender_it@-remove-yahoo.it> wrote:
>
>> Hi gurus and nubys,
>>
>> I was trying to mix RedCloth[1] with Syntax[2] and I'm
>> facing some small problems.
>> The idea is to forward parsing of <pre> tags to the HTML convertor
>> withouth touching the rest of the code.
>> I thought that I could subclass RedCloth and override #smooth_offtags
>> which seem quite nice since the starting <pre> tag is carried till
>> that point, which could allow, for example, parsing of something like
>> <pre lang="ruby">.
>>
>> The problem is in the fact that RC escapes html entities before this
>> step, and thus when I call #convert on the string Syntax will
>> tokenize them and give back bad html.
>>
>> Has someone ever faced this before and has an alternate solution?
>>
>
> Yup, don't it just suck? In the end we introduced a 'macro' concept by
> which we could exempt sections of code from formatting filters.

yeah, I was leaning to the same solution, even if I still want to try
out redefining to_html with something like
def to_html
expand pre tags
super
end

> Have a browse around here:
>
> http://rubyforge.org/cgi-bin/viewcvs.cgi/rote/lib/rote/...
>
> Particularly inside 'page.rb' and the 'filters' directory, which has
> various filters including syntax and redcloth.

great thanks