| 1 | package QuadPres::VimIface; | ||
| 2 | $QuadPres::VimIface::VERSION = '0.28.2'; | ||
| 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 | |||
| 7 | 1 | ▶ | use Text::VimColor (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 8 | use Path::Tiny qw/ path /; | ||
| 9 | |||
| 10 | sub is_newer | ||
| 11 | { | ||
| 12 | my $file1 = shift; | ||
| 13 | my $file2 = shift; | ||
| 14 | my @stat1 = stat($file1); | ||
| 15 | my @stat2 = stat($file2); | ||
| 16 | if ( !@stat2 ) | ||
| 17 | { | ||
| 18 | return 1; | ||
| 19 | } | ||
| 20 | return ( $stat1[9] >= $stat2[9] ); | ||
| 21 | } | ||
| 22 | |||
| 23 | sub get_syntax_highlighted_html_from_file | ||
| 24 | { | ||
| 25 | my ($args) = @_; | ||
| 26 | |||
| 27 | my $filename = $args->{'filename'}; | ||
| 28 | |||
| 29 | my $html_filename = "$filename.html-for-quad-pres"; | ||
| 30 | |||
| 31 | if ( is_newer( $filename, $html_filename ) ) | ||
| 32 | { | ||
| 33 | my $syntax = Text::VimColor->new( | ||
| 34 | file => $filename, | ||
| 35 | html_full_page => 1, | ||
| 36 | ( $args->{'filetype'} ? ( filetype => $args->{'filetype'} ) : () ), | ||
| 37 | ); | ||
| 38 | |||
| 39 | path($html_filename) | ||
| 40 | ->spew( $syntax->html =~ s#(<meta[^/>]+[^/])>#$1/>#gr ); | ||
| 41 | } | ||
| 42 | |||
| 43 | my $text = path($html_filename)->slurp; | ||
| 44 | |||
| 45 | $text =~ s{\A.*<pre>[\s\n\r]*}{}s; | ||
| 46 | $text =~ s{[\s\n\r]*</pre>.*\z}{}s; | ||
| 47 | $text =~ s{(class=")syn}{$1}g; | ||
| 48 | |||
| 49 | return $text; | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; | ||
| 53 | |||
| 54 | __END__ | ||
| 55 | |||
| 56 | =pod | ||
| 57 | |||
| 58 | =encoding UTF-8 | ||
| 59 | |||
| 60 | =head1 VERSION | ||
| 61 | |||
| 62 | version 0.28.2 | ||
| 63 | |||
| 64 | =head1 COPYRIGHT & LICENSE | ||
| 65 | |||
| 66 | Copyright 2018 by Shlomi Fish | ||
| 67 | |||
| 68 | This program is distributed under the MIT / Expat License: | ||
| 69 | L<http://www.opensource.org/licenses/mit-license.php> | ||
| 70 | |||
| 71 | Permission is hereby granted, free of charge, to any person | ||
| 72 | obtaining a copy of this software and associated documentation | ||
| 73 | files (the "Software"), to deal in the Software without | ||
| 74 | restriction, including without limitation the rights to use, | ||
| 75 | copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 76 | copies of the Software, and to permit persons to whom the | ||
| 77 | Software is furnished to do so, subject to the following | ||
| 78 | conditions: | ||
| 79 | |||
| 80 | The above copyright notice and this permission notice shall be | ||
| 81 | included in all copies or substantial portions of the Software. | ||
| 82 | |||
| 83 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 84 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
| 85 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 86 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
| 87 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 88 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 89 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 90 | OTHER DEALINGS IN THE SOFTWARE. | ||
| 91 | |||
| 92 | =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan | ||
| 93 | |||
| 94 | =head1 SUPPORT | ||
| 95 | |||
| 96 | =head2 Websites | ||
| 97 | |||
| 98 | The following websites have more information about this module, and may be of help to you. As always, | ||
| 99 | in addition to those websites please use your favorite search engine to discover more resources. | ||
| 100 | |||
| 101 | =over 4 | ||
| 102 | |||
| 103 | =item * | ||
| 104 | |||
| 105 | MetaCPAN | ||
| 106 | |||
| 107 | A modern, open-source CPAN search engine, useful to view POD in HTML format. | ||
| 108 | |||
| 109 | L<https://metacpan.org/release/QuadPres> | ||
| 110 | |||
| 111 | =item * | ||
| 112 | |||
| 113 | RT: CPAN's Bug Tracker | ||
| 114 | |||
| 115 | The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. | ||
| 116 | |||
| 117 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=QuadPres> | ||
| 118 | |||
| 119 | =item * | ||
| 120 | |||
| 121 | CPANTS | ||
| 122 | |||
| 123 | The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. | ||
| 124 | |||
| 125 | L<http://cpants.cpanauthors.org/dist/QuadPres> | ||
| 126 | |||
| 127 | =item * | ||
| 128 | |||
| 129 | CPAN Testers | ||
| 130 | |||
| 131 | The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. | ||
| 132 | |||
| 133 | L<http://www.cpantesters.org/distro/Q/QuadPres> | ||
| 134 | |||
| 135 | =item * | ||
| 136 | |||
| 137 | CPAN Testers Matrix | ||
| 138 | |||
| 139 | The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. | ||
| 140 | |||
| 141 | L<http://matrix.cpantesters.org/?dist=QuadPres> | ||
| 142 | |||
| 143 | =item * | ||
| 144 | |||
| 145 | CPAN Testers Dependencies | ||
| 146 | |||
| 147 | The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. | ||
| 148 | |||
| 149 | L<http://deps.cpantesters.org/?module=QuadPres> | ||
| 150 | |||
| 151 | =back | ||
| 152 | |||
| 153 | =head2 Bugs / Feature Requests | ||
| 154 | |||
| 155 | Please report any bugs or feature requests by email to C<bug-quadpres at rt.cpan.org>, or through | ||
| 156 | the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=QuadPres>. You will be automatically notified of any | ||
| 157 | progress on the request by the system. | ||
| 158 | |||
| 159 | =head2 Source Code | ||
| 160 | |||
| 161 | The code is open to the world, and available for you to hack on. Please feel free to browse it and play | ||
| 162 | with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull | ||
| 163 | from your repository :) | ||
| 164 | |||
| 165 | L<https://github.com/shlomif/quad-pres> | ||
| 166 | |||
| 167 | git clone https://github.com/shlomif/quad-pres.git | ||
| 168 | |||
| 169 | =head1 AUTHOR | ||
| 170 | |||
| 171 | Shlomi Fish <shlomif@cpan.org> | ||
| 172 | |||
| 173 | =head1 BUGS | ||
| 174 | |||
| 175 | Please report any bugs or feature requests on the bugtracker website | ||
| 176 | L<https://github.com/shlomif/quad-pres/issues> | ||
| 177 | |||
| 178 | When submitting a bug or request, please include a test-file or a | ||
| 179 | patch to an existing test-file that illustrates the bug or desired | ||
| 180 | feature. | ||
| 181 | |||
| 182 | =head1 COPYRIGHT AND LICENSE | ||
| 183 | |||
| 184 | This software is Copyright (c) 2019 by Shlomi Fish. | ||
| 185 | |||
| 186 | This is free software, licensed under: | ||
| 187 | |||
| 188 | The MIT (X11) License | ||
| 189 | |||
| 190 | =cut | ||