Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-10-26 19:05:55

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Plugin for code syntax highlighting in articles?

Is there any active and supported plugin for code syntax highlighting to put in articles? The only one it seems still alive is fox_code, but the available version seems a bit outdated and I can’t make it work (also, the geshi library seems to have changed, the filename is class.geshi.php and not geshi.php as in the plugin help, so I suppose it’s outdated).

Is anyone using something like this on txp 4.2?

Offline

#2 2009-10-26 20:58:01

kitchenware
New Member
Registered: 2009-10-26
Posts: 1

Re: Plugin for code syntax highlighting in articles?

This is probably because you are using an alpha version of Geshi. Try using the latest release version 1.0.8.4 instead.

Offline

#3 2009-10-26 23:36:29

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: Plugin for code syntax highlighting in articles?

You’re right, kitchenware! I was using an alpha. Now, with 1.0.8.4 release I can get fox_code almost work. The problem is that the (css) code is messy: all newline are transformed in unwanted <br />, and quotes converted in numeric entities… And if I put a blank line between lines of code, it shows <p> </p>… At the end, I can’t understand how I’m supposed to write the code. Any hint?

Offline

#4 2009-10-27 09:41:53

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Plugin for code syntax highlighting in articles?

Zanza wrote:

Any hint?

Textile(?), notextile..

Offline

#5 2009-10-27 15:07:28

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: Plugin for code syntax highlighting in articles?

Yes, you’re right, Gocom. notextile.. just before the fox_code tag. Thanks!

Offline

#6 2009-12-22 09:01:12

craigdrown
Member
Registered: 2006-01-02
Posts: 19

Re: Plugin for code syntax highlighting in articles?

When I ran this plugin I got a php include path error
I then added to .htaccess:
php_value include_path ".:/usr/lib/php:/usr/local/lib/php:/home/mycpanelaccountname/public_html/textpattern/lib"
and all was well.
Just recording here for others.
Cheers,
Craig

Offline

#7 2009-12-22 10:09:16

candyman
Member
From: Italy
Registered: 2006-08-08
Posts: 684

Re: Plugin for code syntax highlighting in articles?

Hello Zanza, the display-code plugin by net-carver may help you?

Offline

#8 2009-12-22 10:17:47

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: Plugin for code syntax highlighting in articles?

I missed that, Alessandro, thanks! The problem is, I don’t want short code in downloadable files, but directly inside the articles (easier to write and rewrite, also searchable, and so on). Anyway, if you sort out any other similar plugin, I’ll be glad to check it out.

Offline

#9 2011-09-04 14:17:19

Gr3yFox
Plugin Author
From: Genova, Italy
Registered: 2007-06-18
Posts: 42
Website

Re: Plugin for code syntax highlighting in articles?

Hi, I’m the fox_code developer. I’m sorry if it seems a little bit outdated, but I don’t have much time for it. I just published it on GitHub along with some small changes to make it work smooth with Textpattern 4.4 (some tag names weren’t supported anymore, so I had to rename them).
I’m planning to review a little bit the code soon and check for it’s compatibility with new versions of geshi (my library version is still quite old).
I have a favor to ask you: could you post some tickets about the problems you’re experiencing or about the features that in your opinion are still missing on my GitHub page, please?

https://github.com/Gr3yFox/fox_code/issues

Riccardo

Last edited by Gr3yFox (2011-09-04 14:18:04)


Gr3yFox

Offline

#10 2011-10-12 06:49:51

sgreener
Member
Registered: 2008-11-05
Posts: 16

Re: Plugin for code syntax highlighting in articles?

Gr3yFox,

How do I ensure that fox_code preserves blank lines between lines of code?

eg
notextile.. <txp:fox_code language=“sql” >
SELECT * FROM dual;

DUMMY
——-
X
</txt:fox_code>

regards
Simon

Last edited by sgreener (2011-10-12 06:50:02)

Offline

#11 2011-10-14 09:39:18

Gr3yFox
Plugin Author
From: Genova, Italy
Registered: 2007-06-18
Posts: 42
Website

Re: Plugin for code syntax highlighting in articles?

@sgreener:

I’m afraid even with “notextile..”, if textile is enabled for the article textpattern still removes unnecessary white lines before saving the corresponding html in the database, thus my plugin (and geshi too) receives a copy of your code without blank lines. I can’t do very much about it from the plugin.

You have two options if you want to keep blank lines in blocks of code: you can either disable textile for the whole article and write it in plain html, or you can upload your code into a file in textpattern and use the fox_code option fileid or filename to load the code. The latter does not require notextille.., and you can use it in combo with fromline and toline to upload a single file and then show only a portion of it. In the following example I load the lines from 35 to 43 of mysource.sql.

<txp:fox_code language=“sql” filename=“mysource.sql” fromline=“35” toline=“43” />

I suggest you this approach, especially if your code is quite long, since you can make your source easly available for download too. If you go, in example, to this page in my website you can see what I mean: I take different portions of code from a single source file, and then (bottom of the page) I make it available for download.

Last edited by Gr3yFox (2011-10-14 09:40:31)


Gr3yFox

Offline

#12 2011-12-17 07:17:29

sgreener
Member
Registered: 2008-11-05
Posts: 16

Re: Plugin for code syntax highlighting in articles?

Gr3yFox,

Sorry for the late reply.

Understood but not the way I write posts – SQL is interspersed with text.

I am simply using the most unobtrusive thing I can use – a single period “.” at the start of a line.

It’s OK.

Thanks.
Simon

Offline

Board footer

Powered by FluxBB