Category talk:J: Difference between revisions

→‎GeSHi Highlighter for J: Here's how to test it.
(→‎GeSHi Highlighter for J: Here's how to test it.)
Line 37:
:I don't know J, but what's keeping you from testing your language definition? ——[[User:Underscore|Underscore]] ([[User talk:Underscore|Talk]]) 01:04, 10 November 2009 (UTC)
::I suspect ignorance more than anything ;-). I imagine that it would probably involve installing and configuring a local PHP server? I've never worked with PHP or installed a PHP server before - not sure that I'm ready to go down that road! --[[User:Tikkanz|Tikkanz]] 05:11, 10 November 2009 (UTC)
:::Oh, don't worry, it's easy. I don't know a word of PHP and I was able to test my Perl 6 language definition. You must already have a copy of GeSHi, so all you need is a PHP interpreter; if you're running a flavor of Unix, get it using your package manager, or if you're running Windows, [http://www.php.net/downloads.php get a binary here]. Then change to your GeSHi directory and create a new file there, <code>testgeshi.php</code>, with these contents:
<blockquote><blockquote><blockquote><lang php><?php
 
include_once 'geshi.php';
 
$source = 'some test code';
 
$language = 'j';
 
$geshi = new GeSHi($source, $language);
 
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head><title>GeSHi test</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>',
$geshi->parse_code(),
'</body></html>';
 
?></lang></blockquote></blockquote></blockquote>
:::Replace "some test code" with some test J code. (I assume you've named your language definition <code>j.php</code> and put it the directory <code>geshi</code>.) Then say <code>php testgeshi.php</code>, redirect the output to a file, and open the file in your favorite Web browser. —[[User:Underscore|Underscore]] ([[User talk:Underscore|Talk]]) 12:56, 10 November 2009 (UTC)
 
While we're on the subject, I would be interested in a programmatic approach to generating these files. The structure of the GeSHi language files is very, very simple; It's little more than a PHP-native serialization of a few regex setrings and symbol constants. If GeSHi supported JSON for that structure, it would be trivial to import language highlighting as a JSON file, and such a file would be trivial to generate programmatically. But GeSHi doesn't, so I'm stuck with PHP files until I (or someone else) writes a JSON->PHP conversion. That said, a number of folks have sent me language files, and so are familiar with its structure. Would anyone be interested in writing a webform-driven language-file ''generator''? For security's sake, I can't automate the import of the generated files, but it would greatly open up the process of generating the files, and perhaps make maintenance easier. I'd give it a subdomain such as geshi.rosettacode.org. --[[User:Short Circuit|Michael Mol]] 03:33, 10 November 2009 (UTC)
845

edits