Highlight/skylighting.pm

filter: Statementstmt 54.5% 12 / 22 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 38.4% 15 / 39 CC 4 SCAR 14.1
CC
4
Cov
43%
language
6.0
clean
6.0
highlight
6.0
CRAP 4.1
« Highlight/pandoc.pm ↑ Summary
1 package Text::ANSI::Highlight::skylighting;
2  
3 1 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Text::ANSI::Highlight ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # skylighting, the highlighter of pandoc, as a command: the 16 colors
8 # of the terminal and a style without background. The language is
9 # given after it by -s.
10 1 our @COMMAND = qw(skylighting -f ansi -r -C 16 -S pygments);
11  
12 # The languages of skylighting 0.15 (pandoc --list-highlight-languages,
13 # pandoc 3.14). A language is given to the command only when it is
14 # here: the command takes time to look for one it does not know.
15 1 my %LANGUAGE = map { $_ => 1 } qw(
16 abc abnf actionscript ada agda apache asciidoc asn1 asp ats awk bash
17 bibtex boo c cabal changelog clojure cmake cobol coffee coldfusion
18 comments commonlisp context cpp crystal cs css csv curry d dart
19 debiancontrol default desktop diff djangotemplate dockerfile dosbat
20 dot doxygen doxygenlua dtd eiffel elixir elixireex elixirheex elm
21 email erlang fasm fortranfixed fortranfree fsharp gap gcc gdscript
22 gleam glsl gnuassembler go gpr graphql groovy haml hamlet haskell
23 haxe html idl idris ini isocpp j java javadoc javascript
24 javascriptreact jinja jira json jsp julia k kotlin latex lex
25 lilypond literatecurry literatehaskell llvm logfile lua m4 makefile
26 mandoc mathematica matlab maxima mediawiki mermaid meson metafont
27 mips modelines modula2 modula3 monobasic mustache nasm nginx nim
28 ninja nix noweb objectivec objectivecpp ocaml ocamllex ocamlyacc
29 octave odin opencl orgmode pascal perl php pike postscript povray
30 powershell prolog protobuf pure purebasic purescript python q qml
31 quarto r racket raku rdoc relaxng relaxngcompact rest rhtml
32 rmarkdown roff rtf ruby rust sas sass scala scheme sci scss sed sgml
33 sml sparql spdxcomments sql sqlmysql sqlpostgresql stan stata swift
34 systemverilog tcl tcsh terraform texinfo textile tlaplus todo toml
35 typescript typst verilog vhdl vue xml xorg xslt xul yacc yaml zig
36 zsh
37 );
38  
39 0 ▶sub language { $LANGUAGE{$_[0]} ? $_[0] : undef }
Subroutine language: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$LANGUAGE{$_[0]} ? : 0 0 0
40  
41 # The text around the code of a Markdown text is colored
42 0 ▶sub markdown { 1 }
Subroutine markdown: not called CC=1 SCAR=6.9
Pod undocumented
43  
44 # The sequences of skylighting which do nothing: \e[22;23;24m after
45 # every reset, and a reset where there is no color to reset, at the
46 # top of a line or after another reset, with text between them or not.
47 # skylighting resets after every word, colored or not.
48 0 ▶sub clean {
Subroutine clean: not called CC=2 SCAR=17.9
Pod undocumented
49 0 local $_ = shift;
50 0 s/\e\[0m\K\e\[22;23;24m//g;
51 0 ▶ 1 while s/(?:^|\e\[0m)[^\e\n]*\K\e\[0m//mg;
Branch: 1 branch
BranchTrueFalseTotal
s/(?:^|\e\[0m)[^\e\n]*\K\e\[0m//gmu and do { '???' } 0 0 0
52 0 $_;
53 }
54  
55 # The command runs once for each text.
56 0 ▶sub highlight {
Subroutine highlight: not called CC=2 SCAR=17.9
Pod undocumented
57 map {
58 0 my($lang, $text) = @$_;
59 0 my $out = Text::ANSI::Highlight::run([ @COMMAND, '-s', $lang ], $text);
60 0 ▶ defined $out ? clean($out) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $out ? : 0 0 0
61 } @_;
62 }
63  
64 1 1;
« Highlight/pandoc.pm ↑ Summary