http://www.perlmonks.org?node_id=605626

chargrill has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

First, let me apologize, as I realize this may not strictly be a perl question, but perhaps an apache question or even a vim question. Having said that...

I'm trying to incorporate some syntax-colored code in a blog I'm writing, and stumbled across Text::VimColor. "Perfect!" I think - I just so happen to have my eyes trained to appreciate and be accustomed to the particular colorscheme I've selected for vim - "this should let everyone see my code the same way I do!"

Running a preliminary test or two from the command line to make sure I know how to use the module (and it worked great!), I felt a little confident that my syntax-highlighted HTML code would soon appear in my web browser.

Unfortunately, I was mistaken! I've boiled it down to the simplest of code:

#!/usr/bin/perl use strict; use warnings; use CGI q/:standard/; use Text::VimColor; my $perl=<<EOP; #!/usr/bin/perl use strict; use warnings; print "Hello, world!\n"; EOP # my vim is in /usr/local/bin $ENV{PATH}="/usr/local/bin:$ENV{PATH}"; my $vim = Text::VimColor->new( # line 18 string => $perl, ); print header(); print $vim->html;

... but much to my dismay, I keep getting these pesky few lines in my httpd-error.log:

vim returned an error code of '1' Vim wrote this error output: Vim: Warning: Output is not to a terminal Vim: Warning: Input is not from a terminal at /usr/local/www/data/path_to_cgi/html.cgi line 18

After reading some docs and man pages and a fair amount of googling, I see that vim likes to have a terminal. Running vi(m) via an ssh -c command produces similar errors, for which the fix is to pass the -t flag to ssh, to force the allocation of a psuedo-tty.

I'm willing to accept the fact that what I want to do just can't be done, however the fact that the existence of other modules that use Text::VimColor in an apache environment ... e.g. Apache::VimColor, Kwiki::VimMode ... forces me to think that maybe I'm just missing something.

Certainly, it's been a while since word of this module has appeared in the monastery ( On-the-fly all-languages syntax highlighting ) ... but I'm hoping that someone here may have run into this issue or at least offer some kind of solution, as I can't believe I'm the only one who's run into this issue.

N.B. I'm aware of the existence of Syntax::Highlight::Engine::Kate - and in fact have adopted that as my fall-back. It works fine for some code, however (perhaps understandably) it fails to syntax-highlight pieces of my .vimrc file :) I'm also looking for something capable of syntax highlighting bash, SQL, HTML, Perl, JavaScript, and .vimrc files, so the other syntax highlighting options (that I'm aware of) are out.

Update: I'd show my example of using a file which fails in exactly the same way with the same error message, but that's not quite as self contained as my above example.



--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)