[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

JavaScript-based Ruby lexer/parser for CSS syntax highlighting?

Gavin Kistner

2/27/2007 7:43:00 PM

I'm looking for a JS library that will find <code class="ruby"> (or
otherwise-specified) elements on an HTML page and wrap bits in <span
class="keyword">...</span> type elements for CSS syntax coloring of
the original source.

I've found two JS-based syntax highlighters ([1] and [2]), but both
fail on Ruby code like:
foo = "Hello #{ "World" }"

They're both regexp-based, which is the problem. I'm happy to use them
for quick-n-dirty highlighting, but I'm hoping that someone has
written a lexer/parser that handles more complex situations like this
(even if it doesn't cover every single edge case).

26 Answers

Gavin Kistner

2/27/2007 7:45:00 PM

0

On Feb 27, 12:43 pm, "Phrogz" <g...@refinery.com> wrote:
[snip]
> I've found two JS-based syntax highlighters ([1] and [2]), but both
[/snip]

Oops, forgot to attach the references:
[1] http://www.dreamprojections.com/SyntaxHi...
[2] http://softwaremaniacs.org/soft/hig...

Logan Capaldo

2/27/2007 10:44:00 PM

0

On Wed, Feb 28, 2007 at 04:50:05AM +0900, Phrogz wrote:
> On Feb 27, 12:43 pm, "Phrogz" <g...@refinery.com> wrote:
> [snip]
> > I've found two JS-based syntax highlighters ([1] and [2]), but both
> [/snip]
>
Does it have to be JS? You gonna do client side lexing of ruby in JS? (I
guess it has to be, else you wouldn't have asked.)

* forges on anyway *

Sure you can't use http://coderay.ru... instead?
> Oops, forgot to attach the references:
> [1] http://www.dreamprojections.com/SyntaxHi...
> [2] http://softwaremaniacs.org/soft/hig...
>

Gavin Kistner

2/27/2007 10:52:00 PM

0

On Feb 27, 3:44 pm, Logan Capaldo <logancapa...@gmail.com> wrote:
> Does it have to be JS? You gonna do client side lexing of ruby in JS? (I
> guess it has to be, else you wouldn't have asked.)
>
> * forges on anyway *
>
> Sure you can't usehttp://coderay.rubychan.d...

I could, for sure. That trades bytes over the wire for user's cpu
time. Sometimes I just really like having code syntax highlighted by
the page, particularly when it's a tiny snippet as part of a larger
page, and not an entire source file.

I hacked the second library I found to do what I want. Although I'm
annoyed with its speed, it's working reasonably OK for now. It looks
like I was wrong, that is has some form of 'real' lexing applied via a
very incomplete idea about Ruby syntax. If no one has a premade JS
library for this, and if it bothers me enough, I'll spend some time
understanding its scoping and lexing rules and see if it can make the
jump from string mode back into code mode. My quick hackery to add
some features makes it look possible.

AZ Nomad

10/31/2010 4:45:00 PM

0

On Sun, 31 Oct 2010 16:15:44 -0000, Steve O <nospamhere@thanks.com> wrote:


>"duke" wrote in message news:3c4rc6h16655s57t5vapgbgpnua50rmmuo@4ax.com...

>On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
><sonofman2@comcast.net> wrote:

>>First and foremost, the Buddha's words and deeds are pure. Never once
>>does he condone violence of any kind. His morality is never
>>compromised by any given situation. It is NOT okay to preach "thou
>>shalt not kill" and then turn into a hypocrite and instigate the
>>stoning to death of a man who himself was guilty of harming no one,
>>but was merely "found gathering sticks on the sabbath day".

>He's also not a god.

>He's as much a God as yours is.

Put some quoting characters or indentation characters around text you
quote.

You're post makes it look like you are argueing with yourself.

Dakota

10/31/2010 5:15:00 PM

0

On Sun 10/31/10 11:15, Steve O wrote:
>
>
> "duke" wrote in message news:3c4rc6h16655s57t5vapgbgpnua50rmmuo@4ax.com...
>
> On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
> <sonofman2@comcast.net> wrote:
>
>> First and foremost, the Buddha's words and deeds are pure. Never once
>> does he condone violence of any kind. His morality is never
>> compromised by any given situation. It is NOT okay to preach "thou
>> shalt not kill" and then turn into a hypocrite and instigate the
>> stoning to death of a man who himself was guilty of harming no one,
>> but was merely "found gathering sticks on the sabbath day".
>
> He's also not a god.
>
> He's as much a God as yours is.
>
While I agree that all gods are equally valid, the Buddha never claimed
to be a god. He had 'Godness' thrust upon him by men.

And by equally valid, I mean that there is no evidence for any of them.
Ergo, their validity is equally meaningless.
>
>
> -- Steve O
> a.a.2240 BAAWA
> Theological Noncognitivist
> Convicted by Earthquack
> Exempt from Purgatory by Papal Indulgence

Steve O

10/31/2010 6:13:00 PM

0



"AZ Nomad" wrote in message
news:slrnicr781.jmp.aznomad.3@ip70-176-155-130.ph.ph.cox.net...

On Sun, 31 Oct 2010 16:15:44 -0000, Steve O <nospamhere@thanks.com> wrote:


>"duke" wrote in message news:3c4rc6h16655s57t5vapgbgpnua50rmmuo@4ax.com...

>On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
><sonofman2@comcast.net> wrote:

>>First and foremost, the Buddha's words and deeds are pure. Never once
>>does he condone violence of any kind. His morality is never
>>compromised by any given situation. It is NOT okay to preach "thou
>>shalt not kill" and then turn into a hypocrite and instigate the
>>stoning to death of a man who himself was guilty of harming no one,
>>but was merely "found gathering sticks on the sabbath day".

>He's also not a god.

>He's as much a God as yours is.

Put some quoting characters or indentation characters around text you
quote.

I know- I made the mistake of upgrading to windows live mail and the
attributions are crap....
......It's done it again, hasn't it?


-- Steve O
a.a.2240 BAAWA
Theological Noncognitivist
Convicted by Earthquack
Exempt from Purgatory by Papal Indulgence



You're post makes it look like you are argueing with yourself.

Steve O

10/31/2010 6:22:00 PM

0



"Dakota" wrote in message news:SrmdnZ55R8iaOVDR4p2dnAA@giganews.com...

On Sun 10/31/10 11:15, Steve O wrote:
>
>
> "duke" wrote in message news:3c4rc6h16655s57t5vapgbgpnua50rmmuo@4ax.com...
>
> On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
> <sonofman2@comcast.net> wrote:
>
>> First and foremost, the Buddha's words and deeds are pure. Never once
>> does he condone violence of any kind. His morality is never
>> compromised by any given situation. It is NOT okay to preach "thou
>> shalt not kill" and then turn into a hypocrite and instigate the
>> stoning to death of a man who himself was guilty of harming no one,
>> but was merely "found gathering sticks on the sabbath day".
>
> He's also not a god.
>
> He's as much a God as yours is.
>
>While I agree that all gods are equally valid, the Buddha never claimed to
>be a god. He had 'Godness' thrust upon him by men.

Don't they all?

>And by equally valid, I mean that there is no evidence for any of them.
>Ergo, their validity is equally meaningless.

That's what I was trying to say.
Sorry you missed the implication of my statement.


-- Steve O
a.a.2240 BAAWA
Theological Noncognitivist
Convicted by Earthquack
Exempt from Purgatory by Papal Indulgence

AZ Nomad

10/31/2010 6:32:00 PM

0

On Sun, 31 Oct 2010 18:13:03 -0000, Steve O <nospamhere@thanks.com> wrote:


>"AZ Nomad" wrote in message
>news:slrnicr781.jmp.aznomad.3@ip70-176-155-130.ph.ph.cox.net...

>On Sun, 31 Oct 2010 16:15:44 -0000, Steve O <nospamhere@thanks.com> wrote:


>>"duke" wrote in message news:3c4rc6h16655s57t5vapgbgpnua50rmmuo@4ax.com...

>>On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
>><sonofman2@comcast.net> wrote:

>>>First and foremost, the Buddha's words and deeds are pure. Never once
>>>does he condone violence of any kind. His morality is never
>>>compromised by any given situation. It is NOT okay to preach "thou
>>>shalt not kill" and then turn into a hypocrite and instigate the
>>>stoning to death of a man who himself was guilty of harming no one,
>>>but was merely "found gathering sticks on the sabbath day".

>>He's also not a god.

>>He's as much a God as yours is.

>Put some quoting characters or indentation characters around text you
>quote.

>I know- I made the mistake of upgrading to windows live mail and the
>attributions are crap....
>.....It's done it again, hasn't it?

yup

Syd M.

10/31/2010 7:49:00 PM

0

On Oct 31, 11:56 am, duke <duckgumb...@cox.net> wrote:
> On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
>
> <sonofm...@comcast.net> wrote:
> >First and foremost, the Buddha's words and deeds are pure. Never once
> >does he condone violence of any kind. His morality is never
> >compromised by any given situation. It is NOT okay to preach "thou
> >shalt not kill" and then turn into a hypocrite and instigate the
> >stoning to death of a man who himself was guilty of harming no one,
> >but was merely "found gathering sticks on the sabbath day".
>
> He's also not a god.
>
>

And neither is yours.

PDW

LORD JEHOVAH

10/31/2010 9:15:00 PM

0

On Oct 31, 11:56 am, duke <duckgumb...@cox.net> wrote:
> On Sat, 30 Oct 2010 11:43:07 -0700 (PDT), Son of man
>
> <sonofm...@comcast.net> wrote:
> >First and foremost, the Buddha's words and deeds are pure. Never once
> >does he condone violence of any kind. His morality is never
> >compromised by any given situation. It is NOT okay to preach "thou
> >shalt not kill" and then turn into a hypocrite and instigate the
> >stoning to death of a man who himself was guilty of harming no one,
> >but was merely "found gathering sticks on the sabbath day".
>
> He's also not a god.

I never said he was a god.

I said "the Buddha's words and deeds are pure."

I also said I follow Buddha and not YAHWEH.

Why do you make a moot point in saying Buddha was not a god? I never
claimed he was.

>
> The dukester, American-American
> *****
> "The Mass is the most perfect form of Prayer."
> Pope Paul VI
> *****