Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-07-07 05:21:19

akokskis
Plugin Author
From: Baltimore-ish, USofA
Registered: 2004-11-28
Posts: 230
Website

[plugin] [ORPHAN] ako_syntax

ako_syntax
Syntax highlighting for CSS, PHP and (X)HTML

This is, as Marios requested, a syntax highlighting plugin. It is, for those of you interested in more of the details, it’s a port of the Visual.Syntax plugin for WP.

I’m releasing it right now as beta. That is, I think everything works, but I haven’t had time to fully check it all out. I’m going to be away for a bit, with a highly questionable internet connection, but please do let me know of any bugs you all may find, or if there are any other features that you want with this plugin. I’ll try to stay in touch as much as is possible, but no guarantees (at least for the coming ~3wks)

As far as usage goes, just wrap a <code>< code >< /code ></code> or <code><css></css></code> block with <code><txp:ako_syntax></txp:ako_syntax></code>, and it should all work out well.

As well, it will automatically create a stylesheet with some default rules for some of the code. This should be named ako_syntax.

For now, ako_syntax only supports these tags:
  • wraptag – tag to wrap the output with
  • class – class attribute to add onto the wraptag.
Some thoughts on future releases:
  • Automatically run the plugin on any entry being created / updated
  • Fix the output of PHP syntax highlighting from highlight_string() to uses classes and not inline styles (or, even worse, with PHP < 5, the dreaded font tags
  • [Insert what you want here!]

Download v.1
(no help file yet)

Last edited by akokskis (2006-07-07 05:29:05)


My Photoblog, and my personal site. Got nav? ako_nav.
Thanks for taking the time to look…

— vc3 —

Offline

#2 2006-07-07 05:56:24

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] ako_syntax

EDIT.: Reformatting works well, I forgot to wrap the samples in code blocks, I haven’t tested this in-depth yet,
I’ll do a couple of styles for this in the next couple of days.

regards, marios

Last edited by marios (2006-07-07 06:05:44)


⌃ ⇧ < ⌃ ⇧ >

Offline

#3 2006-08-04 10:42:47

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] ako_syntax

The class selectors are inserted are iserted insteaed of the properties.
An arbitrary code sample:

<code><span style=“color: #000000”>
&lt;div&nbsp;class=“postleft”&gt;<span class=“syntax-dl”>&lt;dl&gt;</span><span class=“syntax-dt”>&lt;dt&gt;</span><span class=“syntax-strong”>&lt;strong&gt;</span>&lt;a&nbsp;href=“profile.php?id=4461”&gt;marios<span class=“syntax-a”>&lt;/a&gt;</span><span class=“syntax-strong”>&lt;/strong&gt;</span><span class=“syntax-dt”>&lt;/dt&gt;</span>&lt;dd&nbsp;class=“usertitle”&gt;<span class=“syntax-strong”>&lt;strong&gt;</span>mu<span class=“syntax-strong”>&lt;/strong&gt;</span><span class=“syntax-dd”>&lt;/dd&gt;</span>&lt;dd&nbsp;class=“postavatar”&gt;&lt;img&nbsp;src=“img/avatars/4461.png”&nbsp;width=“60”&nbsp;height=“60”&nbsp;alt=”“&nbsp;/&gt;<span class=“syntax-dd”>&lt;/dd&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class=“syntax-p”>&lt;p&gt;</span><span class=“syntax-dd”>&lt;dd&gt;</span>From:&nbsp;Greece<span class=“syntax-dd”>&lt;/dd&gt;</span>&lt;br&nbsp;/&gt;<span class=“syntax-dd”>&lt;dd&gt;</span>Known&nbsp;languages:&nbsp;de-el-en-(some-fr),meta-idiotics<span class=“syntax-dd”>&lt;/dd&gt;</span>&lt;br&nbsp;/&gt;<span class=“syntax-dl”>&lt;/dl&gt;</span>&lt;br&nbsp;/&gt;<span class=“syntax-div”>&lt;/div&gt;</span></span>
</code>

Another problem I ran into are the html entities, if I run textile on it
and when textile is switched off I get the line rewrapping on samples if I use the pre tag as well.

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#4 2006-08-04 13:29:21

akokskis
Plugin Author
From: Baltimore-ish, USofA
Registered: 2004-11-28
Posts: 230
Website

Re: [plugin] [ORPHAN] ako_syntax

marios wrote:

The class selectors are inserted are iserted insteaed of the properties.

Do you mean to say that it’s not actually colouring the code? If so, then you just need to use the stylesheet. There should be a stylesheet automatically created, with the name of “ako_syntax,” that has all the colours for the text.

Or am I misunderstanding what you mean by this?


My Photoblog, and my personal site. Got nav? ako_nav.
Thanks for taking the time to look…

— vc3 —

Offline

#5 2006-08-04 17:58:25

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] ako_syntax

ok, sorry I’ve got it working.
I did some light testing on this .

The coloring works. (I had forgotten also to reference the style sheets in the page templates.)
I can override the default styles by inserting an important statement for each rule in the stylesheet.

One more observation.
The span wrapping does not work, for elements that do contain properties and property values.
It will display normally, since it is textiled but uncolored, since it will not get the usual span tag wrapping.

Here is the corresponding line from from my source sample:
<code>&lt;table&nbsp;border=“0”&nbsp;cellspacing=“5”&nbsp;cellpadding=“5”&gt;</code>

regards, marios

Last edited by marios (2006-08-04 17:59:27)


⌃ ⇧ < ⌃ ⇧ >

Offline

#6 2006-08-04 18:08:31

akokskis
Plugin Author
From: Baltimore-ish, USofA
Registered: 2004-11-28
Posts: 230
Website

Re: [plugin] [ORPHAN] ako_syntax

Do you happen to have a URL I could take a look at? Kind of confused by what you mean.


My Photoblog, and my personal site. Got nav? ako_nav.
Thanks for taking the time to look…

— vc3 —

Offline

#7 2006-08-04 20:29:43

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] ako_syntax

Sorry for the delay, I had to port it over to a live install.

<a href=“http://development.cybermarios.com/about/testing-syntax-hilighting”>Testpage</a>

One note for the wraptag option. A class attribute for the wraptag would be usefull.
That way, you could distinguish later on your code blocks according to language.

regards, marios

Last edited by marios (2006-08-04 21:27:32)


⌃ ⇧ < ⌃ ⇧ >

Offline

Board footer

Powered by FluxBB