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,909
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,909
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,909
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,909
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

Board footer

Powered by FluxBB