| 1 | package QuadPres::VimIface; | ||
| 2 | $QuadPres::VimIface::VERSION = '0.32.0'; | ||
| 3 | 1 | ▶ | use 5.016; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use autodie; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | ▶ | use File::ShouldUpdate qw/ should_update /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 0 | ▶ | use Text::VimColor (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | use Path::Tiny qw/ path /; | ||
| 11 | |||
| 12 | sub get_syntax_highlighted_html_from_file | ||
| 13 | { | ||
| 14 | my ($args) = @_; | ||
| 15 | |||
| 16 | my $filename = $args->{'filename'}; | ||
| 17 | |||
| 18 | my $html_filename = "$filename.html-for-quad-pres"; | ||
| 19 | |||
| 20 | if ( should_update( $html_filename, ":", $filename, ) ) | ||
| 21 | { | ||
| 22 | my $syntax = Text::VimColor->new( | ||
| 23 | file => $filename, | ||
| 24 | html_full_page => 1, | ||
| 25 | ( $args->{'filetype'} ? ( filetype => $args->{'filetype'} ) : () ), | ||
| 26 | ); | ||
| 27 | |||
| 28 | path($html_filename) | ||
| 29 | ->spew( $syntax->html =~ s#(<meta[^/>]+[^/])>#$1/>#gr ); | ||
| 30 | } | ||
| 31 | |||
| 32 | my $text = path($html_filename)->slurp; | ||
| 33 | |||
| 34 | $text =~ s{\A.*<pre>[\s\n\r]*}{}s; | ||
| 35 | $text =~ s{[\s\n\r]*</pre>.*\z}{}s; | ||
| 36 | $text =~ s{(class=")syn}{$1}g; | ||
| 37 | |||
| 38 | return $text; | ||
| 39 | } | ||
| 40 | |||
| 41 | 1; | ||
| 42 | |||
| 43 | __END__ | ||