The Pygments highlighter supports many more languages than CodeRay. Pygments is written in Python, but I''ve seen non-Python projects use it (Jekyll, Pygments). There''s also this: https://github.com/nex3/rb-pygments Any idea how much work it would be to add Pygments support to Webgen?
On 2011-02-07 08:00 +0000 Kannan Goundan wrote:> The Pygments highlighter supports many more languages than CodeRay. > Pygments is written in Python, but I''ve seen non-Python projects use > it (Jekyll, Pygments). > > There''s also this: https://github.com/nex3/rb-pygments > > Any idea how much work it would be to add Pygments support to Webgen?Have a look at the implementation of the xmllint content processor (for how to use the output of a system command) and the coderay tag (for how to implement a tag). This should give you an idea on how to implement a tag that does the same thing as the coderay tag but with pygments as backend. -- Thomas
I put code in "<my-site>/plugins/pygments.rb" but I''m
not sure how to
get webgen to find it. The error I get when I try and use a
{pygments::java} tag:
ERROR -- No default mandatory parameter specified for tag
''Webgen::Tag::Metainfo'' but set in </example.en.html>
Also, where do I specify the options that a tag takes? I didn''t see
anything in coderay.rb that defines the set of options. I''d like to
avoid touching the Webgen source itself (it''s installed via Gems) and
restrict everything to the "<my-site>/plugins" directory if
possible.
On Feb 15, 6:50?am, Thomas Leitner <t_leit... at gmx.at>
wrote:> On 2011-02-07 08:00 +0000 Kannan Goundan wrote:
>
> > The Pygments highlighter supports many more languages than CodeRay. ?
> > Pygments is written in Python, but I''ve seen non-Python
projects use
> > it (Jekyll, Pygments).
>
> > There''s also this:https://github.com/nex3/rb-pygments
>
> > Any idea how much work it would be to add Pygments support to Webgen?
>
> Have a look at the implementation of the xmllint content processor
> (for how to use the output of a system command) and the coderay tag
> (for how to implement a tag). This should give you an idea on how to
> implement a tag that does the same thing as the coderay tag but with
> pygments as backend.
>
> -- Thomas
> _______________________________________________
> webgen-users mailing list
> webgen-us... at
rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
I was looking at 0.4 documentation and doing the wrong thing. If you
put everything in "ext/init.rb" it works, basically.
http://pastebin.com/Dzk6Xpva
You need to specify the highlighting stuff in a style sheet. This is
what I''m using right now:
/* Keywords */
span.kn,span.kd,span.k,span.kr {
font-weight: bold;
color: black;
}
/* Comments */
span.c1 {
font-weight: bold;
color: #388048;
}
/* Literals */
span.s,span.mi {
color: #486088;
}
Pygments supports way more languages than Coderay. It would be nice
if Webgen supported it out of the box.
-- Kannan
On Feb 16, 3:21?am, Kannan Goundan <kan... at cakoose.com>
wrote:> I put code in "<my-site>/plugins/pygments.rb" but
I''m not sure how to
> get webgen to find it. ?The error I get when I try and use a
> {pygments::java} tag:
>
> ERROR -- No default mandatory parameter specified for tag
> ''Webgen::Tag::Metainfo'' but set in
</example.en.html>
>
> Also, where do I specify the options that a tag takes? ?I didn''t
see
> anything in coderay.rb that defines the set of options. ?I''d like
to
> avoid touching the Webgen source itself (it''s installed via Gems)
and
> restrict everything to the "<my-site>/plugins" directory if
possible.
>
> On Feb 15, 6:50?am, Thomas Leitner <t_leit... at gmx.at> wrote:
>
> > On 2011-02-07 08:00 +0000 Kannan Goundan wrote:
>
> > > The Pygments highlighter supports many more languages than
CodeRay. ?
> > > Pygments is written in Python, but I''ve seen non-Python
projects use
> > > it (Jekyll, Pygments).
>
> > > There''s also this:https://github.com/nex3/rb-pygments
>
> > > Any idea how much work it would be to add Pygments support to
Webgen?
>
> > Have a look at the implementation of the xmllint content processor
> > (for how to use the output of a system command) and the coderay tag
> > (for how to implement a tag). This should give you an idea on how to
> > implement a tag that does the same thing as the coderay tag but with
> > pygments as backend.
>
> > -- Thomas
> > _______________________________________________
> > webgen-users mailing list
> > webgen-us... at
rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
>
> _______________________________________________
> webgen-users mailing list
> webgen-us... at
rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
On 2011-02-16 03:21 -0800 Kannan Goundan wrote:> I put code in "<my-site>/plugins/pygments.rb" but I''m not sure how to > get webgen to find it. The error I get when I try and use a > {pygments::java} tag: > > ERROR -- No default mandatory parameter specified for tag > ''Webgen::Tag::Metainfo'' but set in </example.en.html> > > Also, where do I specify the options that a tag takes? I didn''t see > anything in coderay.rb that defines the set of options. I''d like to > avoid touching the Webgen source itself (it''s installed via Gems) and > restrict everything to the "<my-site>/plugins" directory if possible.You need to put your code into the file ext/init.rb so that webgen finds it. Options are defined outside of the tag class, have a look at lib/webgen/default_config.rb in the webgen distribution. There you can see how the coderay tag gets its options defined. Also have a look at the documentation of http://webgen.rubyforge.org/documentation/rdoc/Webgen/Tag/Base.html where everything is described and a sample implementation available. -- Thomas
I''m trying to make "pygments" and "pygmentsfile"
tags. The second
will read in a file for you.
I''m getting strange errors. My code: http://pastebin.com/AVpXUVez
When I try and use the {pygments} tag, Webgen gives me an error:
Error in </overview.en.html:~31> while rendering
</overview.en.html>
with Webgen::Tag::Pygments:
Not all mandatory parameters set: tag.pygmentsfile.filename,
tag.pygmentsfile.lang
(The list of tags is something I added to the error message.)
It looks like the "pygments" tag is requiring parameters associated
with the "pygmentsfile" tag. What am I doing wrong?
On Feb 16, 4:41?am, Thomas Leitner <t_leit... at gmx.at>
wrote:> On 2011-02-16 03:21 -0800 Kannan Goundan wrote:
>
> > I put code in "<my-site>/plugins/pygments.rb" but
I''m not sure how to
> > get webgen to find it. ?The error I get when I try and use a
> > {pygments::java} tag:
>
> > ERROR -- No default mandatory parameter specified for tag
> > ''Webgen::Tag::Metainfo'' but set in
</example.en.html>
>
> > Also, where do I specify the options that a tag takes? ?I
didn''t see
> > anything in coderay.rb that defines the set of options. ?I''d
like to
> > avoid touching the Webgen source itself (it''s installed via
Gems) and
> > restrict everything to the "<my-site>/plugins"
directory if possible.
>
> You need to put your code into the file ext/init.rb so that webgen
> finds it. Options are defined outside of the tag class, have a look at
> lib/webgen/default_config.rb in the webgen distribution. There you can
> see how the coderay tag gets its options defined.
>
> Also have a look at the documentation
ofhttp://webgen.rubyforge.org/documentation/rdoc/Webgen/Tag/Base.html
> where everything is described and a sample implementation available.
>
> -- Thomas
> _______________________________________________
> webgen-users mailing list
> webgen-us... at
rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
On 2011-02-17 03:00 -0800 Kannan Goundan wrote:> I''m trying to make "pygments" and "pygmentsfile" tags. The second > will read in a file for you. > > I''m getting strange errors. My code: http://pastebin.com/AVpXUVez > > When I try and use the {pygments} tag, Webgen gives me an error: > > Error in </overview.en.html:~31> while rendering </overview.en.html> > with Webgen::Tag::Pygments: > Not all mandatory parameters set: tag.pygmentsfile.filename, > tag.pygmentsfile.lang > > (The list of tags is something I added to the error message.) > > It looks like the "pygments" tag is requiring parameters associated > with the "pygmentsfile" tag. What am I doing wrong?That seems to be a bug in webgen... Rename your class PygmentsFile to, for example, FilePygments and it will work. The offending code is in lib/webgen/tag/base.rb:140. -- Thomas
Renaming to "FilePygments" got rid of that problem, but now I have
another.
My "ext/init.rb" is basically the same as before:
http://pastebin.com/tQkaymma
My page has:
{pygmentsfile: {lang: "cks_type", filename: "examples/
students.tcks"}}
The error I get:
Error while rendering </example.en.html>:
can''t convert nil into String
If I change "ext/init.rb" to have a default value for the
"filename"
parameter, webgen uses that default value instead of the one provided
in the tag.
On Feb 17, 4:34?am, Thomas Leitner <t_leit... at gmx.at>
wrote:> On 2011-02-17 03:00 -0800 Kannan Goundan wrote:
>
> > I''m trying to make "pygments" and
"pygmentsfile" tags. ?The second
> > will read in a file for you.
>
> > I''m getting strange errors. ?My
code:http://pastebin.com/AVpXUVez
>
> > When I try and use the {pygments} tag, Webgen gives me an error:
>
> > ? Error in </overview.en.html:~31> while rendering
</overview.en.html>
> > with Webgen::Tag::Pygments:
> > ? ? ? Not all mandatory parameters set: tag.pygmentsfile.filename,
> > tag.pygmentsfile.lang
>
> > (The list of tags is something I added to the error message.)
>
> > It looks like the "pygments" tag is requiring parameters
associated
> > with the "pygmentsfile" tag. ?What am I doing wrong?
>
> That seems to be a bug in webgen... Rename your class PygmentsFile to,
> for example, FilePygments and it will work. The offending code is in
> lib/webgen/tag/base.rb:140.
>
> -- Thomas
> _______________________________________________
> webgen-users mailing list
> webgen-us... at
rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
On 2011-02-19 16:58 -0800 Kannan Goundan wrote:> Renaming to "FilePygments" got rid of that problem, but now I have > another. > > My "ext/init.rb" is basically the same as before: > http://pastebin.com/tQkaymma > > My page has: > {pygmentsfile: {lang: "cks_type", filename: "examples/ > students.tcks"}} > > The error I get: > Error while rendering </example.en.html>: > can''t convert nil into String > > If I change "ext/init.rb" to have a default value for the "filename" > parameter, webgen uses that default value instead of the one provided > in the tag.After renaming your class you also need to change all occurences of pygmentsfile to filepygments since the default way for webgen to find the options for a tag class is by using the class name! I.e. `tag.pygmentsfile.lang` ? `tag.filepygments.lang`! -- Thomas -- |\ Thomas Leitner -- thomas [underscore] leitner [at] gmx [dot] at |> |/ "Life is what happens to you while you''re busy making other plans"