Hi

I'm trying to make GeSHi translate the following string into ActionScript
[syntax="actionscript"]var foo:String = "bar";[/syntax]

I understand that I need to define a custom tag for the ActionScript language, but exactly how should the tags be formatted?

I've tried
[syntax="actionscript"][/syntax]
but that doesn't seem to work.

Comments

soxofaan’s picture

After enabling ActionScript as language in the "Languages" configuration tab, you can for example use these:
[code lang="actionscript"]foo[/code]
[code language="actionscript"]foo[/code]
[code type="actionscript"]foo[/code]

If you set the custom language tag "actionscript" for ActionScript, you can also use
[actionscript]foo[/actionscript]

from http://drupal.org/project/geshifilter:

Source code can be entered with for example <code type="java">...</code> or <blockcode language="python">...</blockcode>. Starting from version 5.x-2.0 it is also possible to define your own generic and language specific tags (e.g. <java>) or to work with square bracket style tags (e.g. [code]).

thulstrup’s picture

Thank you for your answer, but thats not quite what I'm looking for.

I already have a lot of data where the format is:
[syntax="actionscript"]var foo:String = "bar";[/syntax].

Is it possible to have a custom language tag where the start tag and end tag is different?
Start tag: [syntax="actionscript"]
End tag: [/syntax]?

tobto’s picture

I'm also interested into implementation of this

soxofaan’s picture

This is not possible with current version of GeSHi filter.
At first sight, I'm not inclined in implementing this type of tags, since that would make the code (especially the regular expressions) too complex.

A possible solution for you is to implement a custom input filter that would translate [syntax="actionscript"]...[/syntax] to [code language="actionscript"]...[/code] and place it before GeSHi filter, so you don't need to touch your dataset. This should be possible in 20 lines of code or something I guess.

thulstrup’s picture

I wrote a small regex that seems to do the trick for me:

$html = '[syntax="actionscript"]var foo:String = "bar";[/syntax]';
$html = preg_replace("#\[syntax=\"(.+?)\"\]([^[]+)\[/syntax\]#", "[code language=\"$1\"]$2[/code]", $html);
boombatower’s picture

Status: Active » Fixed

Seems fixed and supper old, please re-open if still relevant to recent version.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.