Low level syntax highlighting tools?

G

Gregory Brown

I'll confess I didn't research this deeply, in hopes that someone
knows of a library and can point me right at it.

Are there any syntax gems out there that'll spit back simple strings
and color values,
something like:

[["def foo\n", "ccffcc"], [" bar()\n", "ffffff" ], ["end", "ccffcc"]]

If such a tool exists, I can rejoice, because it'd allow me to build
an awsum Prawn based presentation builder.

-greg
 
J

Jean-François Trân

2008/10/18 Gregory Brown :
I'll confess I didn't research this deeply, in hopes that someone
knows of a library and can point me right at it.

Are there any syntax gems out there that'll spit back simple strings
and color values,
something like:

[["def foo\n", "ccffcc"], [" bar()\n", "ffffff" ], ["end", "ccffcc"]]

I guess no, but if you're using a syntax-colorizing, I think the
thing to do is using the scanner/tokenizer part, that will yield you
tokens for a specified language, and then you just have to create
your own class of Encoder/Converter that will consume tokens
and generate what you need, here an array like you want. It should
be easy, for example, with CodeRay [1] : write your encoder, and
don't use the html encoder.
If such a tool exists, I can rejoice, because it'd allow me to build
an awsum Prawn based presentation builder.

Very interesting. I was also thinking of using Prawn to generate
slides.

-- Jean-Fran=E7ois.

[1] http://coderay.rubychan.de

--=20
Les 50 ans du Lisp : http://www.lisp50.org
http://twitter.com/underflow_
 
G

Gregory Brown

2008/10/18 Gregory Brown :
I'll confess I didn't research this deeply, in hopes that someone
knows of a library and can point me right at it.

Are there any syntax gems out there that'll spit back simple strings
and color values,
something like:

[["def foo\n", "ccffcc"], [" bar()\n", "ffffff" ], ["end", "ccffcc"]]

I guess no, but if you're using a syntax-colorizing, I think the
thing to do is using the scanner/tokenizer part, that will yield you
tokens for a specified language, and then you just have to create
your own class of Encoder/Converter that will consume tokens
and generate what you need, here an array like you want. It should
be easy, for example, with CodeRay [1] : write your encoder, and
don't use the html encoder.

Cool, I'll look into this, thanks.
Very interesting. I was also thinking of using Prawn to generate
slides.

This code is very old, but will eventually be replaced with modernized
Prawn code:
http://github.com/sandal/brine/tree/master

If you're thinking of working on this, you're welcome to fork this
repos so that we don't duplicate effort.

--=20
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com
 
A

ara.t.howard

I'll confess I didn't research this deeply, in hopes that someone
knows of a library and can point me right at it.

Are there any syntax gems out there that'll spit back simple strings
and color values,
something like:

[["def foo\n", "ccffcc"], [" bar()\n", "ffffff" ], ["end", "ccffcc"]]

If such a tool exists, I can rejoice, because it'd allow me to build
an awsum Prawn based presentation builder.

-greg



it seems like using Hpricot against one of the current highlighters
would work - just skim out innerHTML/class pairs right?

a @ http://codeforpeople.com/
 
G

Gregory Brown

I'll confess I didn't research this deeply, in hopes that someone
knows of a library and can point me right at it.

Are there any syntax gems out there that'll spit back simple strings
and color values,
something like:

[["def foo\n", "ccffcc"], [" bar()\n", "ffffff" ], ["end", "ccffcc"]]

If such a tool exists, I can rejoice, because it'd allow me to build
an awsum Prawn based presentation builder.

-greg



it seems like using Hpricot against one of the current highlighters would
work - just skim out innerHTML/class pairs right?

Hmm... that's an interesting idea too. I'll take a quick look at how
easy it is to get under the hood of Code Ray, and if it seems
complicated, such a hack would probably do fine.

-greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,041
Members
47,643
Latest member
ashutoshjha_1101

Latest Threads

Top