s c h e m a t i c s : c o o k b o o k

/ WebHome / Cookbook.AdminSourceHighlighting

This Web


WebHome 
WebChanges 
TOC (with recipes)
NewRecipe 
WebTopicList 
WebStatistics 

Other Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Schematics


Schematics Home
Sourceforge Page
SchemeWiki.org
Original Cookbook
RSS

Scheme Links


Schemers.org
Scheme FAQ
R5RS
SRFIs
Scheme Cross Reference
PLT Scheme SISC
Scheme48 SCM
MIT Scheme scsh
JScheme Kawa
Chicken Guile
Bigloo Tiny
Gambit LispMe
GaucheChez

Lambda the Ultimate
TWiki.org

Source Highlighting Integration

The following diff documents the change made to SyntaxHighlightingPlugin, to integrate the ScmToXexpr Scheme source highlighting program. The diff applies to SyntaxHighlightingPlugin.pm.

All the change does is test whether the specified language is "scheme", and if so, submits an HTTP POST request containing the specified source code, to the source formatting servlet (see source listing at ScmToXexpr). The HTML returned by the servlet is returned to the invoker of the plugin.

*** SyntaxHighlightingPlugin.original.pm        Sat Apr 10 15:05:13 2004
--- SyntaxHighlightingPlugin.pm Thu Apr 22 19:40:37 2004
***************
*** 33,36 ****
--- 33,38 ----

  use IPC::Open2;
+ use LWP::UserAgent;
+ use HTTP::Request::Common;

  use vars qw(
***************
*** 120,123 ****
--- 122,131 ----

      my ($lang, $text, $nb_option, $nb_start) = @_;
+
+     if ($lang eq "scheme") {
+         my $ua = LWP::UserAgent->new;
+         my $response = $ua->simple_request(POST 'http://127.0.0.1:8000/servlets/pretty.scm', [source => $text]);
+         return $response->content;
+     }

      my $highlighted = pipeThru("enscript --color --language=html --highlight=$langs{lc($lang)} -o - -q", $text);

-- AntonVanStraaten - 22 Apr 2004

CookbookForm
TopicType: Admin
ParentTopic: AdminTopics
Next Topic:

 
 
Copyright © 2004 by the contributing authors. All material on the Schematics Cookbook web site is the property of the contributing authors.
The copyright for certain compilations of material taken from this website is held by the SchematicsEditorsGroup - see ContributorAgreement & LGPL.
Other than such compilations, this material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest