Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2011-09-26 02:12:55

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Gr3yFox,

Apologies for not having responded earlier. I stopped receiving emails about comments on this post so I assumed all had gone quiet.
And I got busy doing some non-computing stuff for my wife around the garden….

I had debugging on and have now turned it off.

I have sorted out one issue. When constructing an article (to test the fox_code tags) I tried using Preview to view the result. It doesn’t work.

So, now I have published my tests for you to see at : http://www.spatialdbadvisor.com/manifold_tips_tricks (select Test GeSHI).

The first, which doesn’t work, is generated by:

<txp:fox_code language=“sql” >
SELECT 1 FROM DUAL;
</txp:fox_code>

I get html like this:

<br />
<span class=“caps”>SELECT</span> 1 <span class=“caps”>FROM</span> <span class=“caps”>DUAL</span>;<br />

The second, which does work, is generated by:

<txp:fox_code language=“sql” fileid=“14” />

It is the former that will be the dominant method of using fox_code as my articles always include single SQL queries.

regards
Simon

Offline

#26 2011-09-26 02:17:04

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

OK, Textpattern’s article construction form I changed “Article Markup” on the left to “leave text unchanged” from “Use Texttile” and I now get colour coded SQL. But this stuffs up other things.

Surely this is not the right way to use fox_code?

regards
Simon

Offline

#27 2011-09-27 02:23:04

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

OK, so I have gotten it to work reasonably well by use of “notextile..” before <txp:fox_code language=“sql” >
followed by “p.” afterwards.

I would rather NOT have to do this so, Gr3yFox, if you are doing any more work on this most useful plugin I would like to see this issue solved so that I did not have to use “notextile..”/“p.”.

Thank you for all your efforts.

regards
Simon

Offline

#28 2011-09-27 08:34:34

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

So you problem was the absence of “notextile.” before the code tag? I’m aware of this behaviour, I should specify it in the documentation. I’m sorry I forgot.
The issue does not hold for plain html formatted articles, however I’m afraid you’ll have to specify “notextile.” every time you use those tags in textile formatted articles: you can have a look at this (technical) discussion if you want to find out why I’ll not modify my plugin like that, but the point is that it quite goes against the normal textpattern plugin workflow, and it’s far too complicated with respect to the gains.

edit: sorry for the late in answering you, but I’m really busy these days. Should textpattern include the mechanism to add textile plugins, probably I’ll turn my fox_code into a textile plugin, so that the issue will be solved.

Last edited by Gr3yFox (2011-09-27 08:37:41)


Gr3yFox

Offline

#29 2012-04-20 10:23:11

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Hi Riccardo,

Is it possible to edit the plugin to output code without the DIV wrapper, move the selectors to the PRE element, and eliminate inline style attributes?

So instead of this…

<pre>
<code>
<div class="php" style="font-family:mono-space;">
<ol>
...
</ol>
</div>
</code>
</pre>

Have this…

<pre class="php">
<code>
<ol>
...
</ol>
</code>
</pre>

The DIV seems extra to me (though I’m not sure if it’s actually needed to control the numbered listing), and I’d rather control presentation via CSS than inline.

I’ve had a look at the plugin code, but it might as well be Klingon, as far as my non-developer mind can make it out.

Offline

#30 2012-04-20 12:03:19

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Hi Destry.

Both (X)HTML and CSS used in <txp:fox_code_form> come from textpattern’s templates and styles in the admin control panel.

If you are talking about the basic <txp:fox_code> tag then you should be able to change this behaviour by changing a single line of my code. Just comment out (i.e. add two consecutive slashes // in front of it) the $geshi->set_header_type(GESHI_HEADER_DIV); line in the function fox_code: GeSHi’s behaviour will go back to default, leaving only a <pre> around the code. Here is the documentation, should you need it: set_header_type.

Thanks for using my plugin :)


Gr3yFox

Offline

#31 2012-04-20 12:15:28

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Great. Thanks. Yeah, sorry, I should have clarified I was just talking about the basic output.

I’ll give this a whirl.

Offline

#32 2012-04-20 12:46:11

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

So far so good. I notice the Geshi header instructions say dropping the DIV will cause validation problems, but keeping the div also causes extra white space… hmmm. Decisions, decisions.

Anyway, what about the inline style that’s added automatically… style="font-family:mono-space; … can I edit the code to prevent that from being inserted too? Now that you pointed out the line for the DIV, that stands out like a red clover (ha!), but I don’t notice anything that’s controlling the style attribute.

—-

Edit: Hmmm. Looks like there’s a lot more inline styles that I thought. Also within the LI elements, and within more DIV inside the LI elements. I don’t think this will work out for our needs, unfortunately. No worries, though. We’ll go to plan B. :)

Last edited by Destry (2012-04-20 13:02:18)

Offline

#33 2012-04-20 13:04:47

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

If you wish to remove the inline style for the code, you have to provide a CSS instead. <fox_code> has an input parameter to enable CSS styles in GeSHi, css="1". This will make GeSHi use CSS classes instead (I think I wrote something about it in the plugin’s help). It is disabled by default, but if you don’t want to type css="1" every time you can change the line 'css' => '0', at almost the top of my code to 'css' => '1', (don’t remove the comma). That is the associative array with the default values that are applied whenever you omit to specify explicitly an option.

Unfortunately I cannot help you about the list of css classes GeSHi is going to use once you disable the inline style, I really do not remember. Maybe you can find some references at the same documentation page I linked you before, or somewhere else at the GeSHi website. You may as well look at my (really old and crappy) css.

PS: please have a look at the documentation I supplied together with my plugin, it should clarify something about the possible customizations.

Last edited by Gr3yFox (2012-04-20 13:07:13)


Gr3yFox

Offline

#34 2012-04-20 13:08:17

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Thanks, Riccardo. I’ll look at the docs closer. My fault.

Offline

#35 2012-04-20 13:09:06

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

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Don’t worry, no problem. You’re welcome :)


Gr3yFox

Offline

#36 2024-12-05 04:58:06

hug
Member
Registered: 2024-12-02
Posts: 11

Re: fox_code - A bridge to the powerful GeSHi syntax highlighter

Can I get advice for using fox_code 0.2.1 with Textpattern 4.8.8? I had used Textpattern about 15 years ago, then got caught up with the static-site Jekyll and Hugo, and worked my back to Txp. I’m interested in keeping server-side syntax highlighting and thought to try fox_code. The plugin shows up normally in the admin Plugin panel with the enable/disable, help, etc.

Everything is installed as below. However, it seems I have overlooked something.

My Texpattern home is /var/www/www.the-pythia.net/.

textpattern/plugins/fox_code/fox_code.php
textpattern/plugins/fox_code/help.textile
textpattern/plugins/fox_code/manifest.json
textpattern/lib/geshi.php
textpattern/lib/geshi/4cs.php
textpattern/lib/geshi/6502acme.php
textpattern/lib/geshi/ ... etc. all of the syntax highlighting files

The sample article I’m trying to highlight.

notextile..
<txp:fox_code language=“sql” >
SELECT 1 FROM DUAL;
</txp:fox_code>

The first error output could not find geshi.php. Using the hint here and this thread I added this to my webroot’s .htaccess

php_value include_path ".:/usr/lib/php:/var/www/www.the-pythia.net/textpattern/lib"

That seemed to improve things, as it appears the geshi.php file is loaded, but now I have an issue with “Call to undefined function create_function() in /var/www/www.the-pythia.net/textpattern/lib/geshi.php:4698”. Unfortunately, my PHP knowledge is very old and rusty, and I couldn’t say whether create_function() is verboten or has been superceded with a different function. Any ideas?

The first stack trace is abbreviated for not finding geshi.php. The second one is in full and supports the issue with the create_funtion() menioned above. Thank you for reading! —Hanna

Fatal error: Uncaught Error: Failed opening required 'geshi.php' (include_path='.:/usr/share/php') in /var/www/www.the-pythia.net/textpattern/plugins/fox_code/fox_code.php:67 
Stack trace: 
#0 [internal function]: fox_code() 
...
#25 /var/www/www.the-pythia.net/textpattern/index.php(186): textpattern() 
#26 {main} thrown in /var/www/www.the-pythia.net/textpattern/plugins/fox_code/fox_code.php on line 67

Stack trace after changing the PHP include path, with the create_function() error.

Fatal error: Uncaught Error: Call to undefined function create_function() 
in /var/www/www.the-pythia.net/textpattern/lib/geshi.php:4698 
Stack trace:
#0 /var/www/www.the-pythia.net/textpattern/lib/geshi.php(4621): GeSHi->_optimize_regexp_list_tokens_to_string()
#1 /var/www/www.the-pythia.net/textpattern/lib/geshi.php(1655): GeSHi->optimize_regexp_list()
#2 /var/www/www.the-pythia.net/textpattern/lib/geshi.php(2029): GeSHi->optimize_keyword_group()
#3 /var/www/www.the-pythia.net/textpattern/lib/geshi.php(2168): GeSHi->build_parse_cache()
#4 /var/www/www.the-pythia.net/textpattern/plugins/fox_code/fox_code.php(83): GeSHi->parse_code()
#5 [internal function]: fox_code()
#6 /var/www/www.the-pythia.net/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func()
#7 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(564): Textpattern\Tag\Registry->process()
#8 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(409): processTags()
#9 /var/www/www.the-pythia.net/textpattern/publish/taghandlers.php(2908): parse()
#10 /var/www/www.the-pythia.net/textpattern/publish/taghandlers.php(2937): txp_sandbox()
#11 [internal function]: body()
#12 /var/www/www.the-pythia.net/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func()
#13 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(559): Textpattern\Tag\Registry->process()
#14 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(409): processTags()
#15 /var/www/www.the-pythia.net/textpattern/lib/txplib_misc.php(3551): parse()
#16 /var/www/www.the-pythia.net/textpattern/publish.php(1162): parse_form()
#17 /var/www/www.the-pythia.net/textpattern/publish.php(1197): doArticle()
#18 /var/www/www.the-pythia.net/textpattern/publish.php(921): parseArticles()
#19 [internal function]: article()
#20 /var/www/www.the-pythia.net/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func()
#21 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(559): Textpattern\Tag\Registry->process()
#22 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(409): processTags()
#23 /var/www/www.the-pythia.net/textpattern/publish/taghandlers.php(3833): parse()
#24 [internal function]: if_individual_article()
#25 /var/www/www.the-pythia.net/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func()
#26 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(559): Textpattern\Tag\Registry->process()
#27 /var/www/www.the-pythia.net/textpattern/lib/txplib_publish.php(409): processTags()
#28 /var/www/www.the-pythia.net/textpattern/lib/txplib_misc.php(3626): parse()
#29 /var/www/www.the-pythia.net/textpattern/publish.php(740): parse_page()
#30 /var/www/www.the-pythia.net/textpattern/index.php(186): textpattern()
#31 {main} thrown in /var/www/www.the-pythia.net/textpattern/lib/geshi.php on line 4698

Thank you again!

Last edited by hug (2024-12-05 04:58:45)

Offline

Board footer

Powered by FluxBB