Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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($,,$;,$*,$/)

In reply to Text::VimColor in a CGI - possible? by chargrill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2014-10-20 04:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (72 votes), past polls