| 1 | package Markdent::Dialect::GitHub::BlockParser; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 5 | ▶ | use namespace::autoclean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 5 | our $VERSION = '0.39'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | 5 | ▶ | use Markdent::Event::CodeBlock; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 5 | ▶ | use Markdent::Regexes qw( $BlockStart $HorizontalWS ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 5 | ▶ | use Moose::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 5 | with 'Markdent::Role::Dialect::BlockParser'; | |||||||||||||
| 15 | |||||||||||||||
| 16 | around _possible_block_matches => sub { | ||||||||||||||
| 17 | 37 | ▶ | my $orig = shift; | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | 37 | my $self = shift; | |||||||||||||
| 19 | |||||||||||||||
| 20 | 37 | my @look_for = $self->$orig(); | |||||||||||||
| 21 | 37 | unshift @look_for, 'fenced_code_block'; | |||||||||||||
| 22 | |||||||||||||||
| 23 | 37 | return @look_for; | |||||||||||||
| 24 | 5 | }; | |||||||||||||
| 25 | |||||||||||||||
| 26 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||
| 27 | sub _match_fenced_code_block { | ||||||||||||||
| 28 | 37 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
_match_fenced_code_block: called CC=5 SCAR=16.4
| |||||||||||||||
| 29 | 37 | my $text = shift; | |||||||||||||
| 30 | |||||||||||||||
| 31 | 37 | ▶ | return unless ${$text} =~ / \G | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | $BlockStart | ||||||||||||||
| 33 | ``` | ||||||||||||||
| 34 | $HorizontalWS?\{?\.?([\w-]+)?\}?$HorizontalWS* # optional language name | ||||||||||||||
| 35 | \n | ||||||||||||||
| 36 | ( # code block content | ||||||||||||||
| 37 | (?:.|\n)+? | ||||||||||||||
| 38 | ) | ||||||||||||||
| 39 | \n | ||||||||||||||
| 40 | ``` | ||||||||||||||
| 41 | \n | ||||||||||||||
| 42 | /xmgc; | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 7 | my $lang = $1; | |||||||||||||
| 45 | 7 | my $code = $2; | |||||||||||||
| 46 | |||||||||||||||
| 47 | 7 | ▶ | $self->_debug_parse_result( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 48 | $code, | ||||||||||||||
| 49 | 'code block', | ||||||||||||||
| 50 | ( $lang ? [ language => $lang ] : () ), | ||||||||||||||
| 51 | ) if $self->debug; | ||||||||||||||
| 52 | |||||||||||||||
| 53 | 7 | ▶ | $self->_send_event( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 54 | 'CodeBlock', | ||||||||||||||
| 55 | code => $code, | ||||||||||||||
| 56 | ( defined $lang ? ( language => $lang ) : () ), | ||||||||||||||
| 57 | ); | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 7 | return 1; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | ## use critic | ||||||||||||||
| 62 | |||||||||||||||
| 63 | 5 | 1; | |||||||||||||
| 64 | |||||||||||||||
| 65 | # ABSTRACT: Block parser for GitHub Markdown | ||||||||||||||
| 66 | |||||||||||||||
| 67 | __END__ | ||||||||||||||
| 68 | |||||||||||||||
| 69 | =pod | ||||||||||||||
| 70 | |||||||||||||||
| 71 | =encoding UTF-8 | ||||||||||||||
| 72 | |||||||||||||||
| 73 | =head1 NAME | ||||||||||||||
| 74 | |||||||||||||||
| 75 | Markdent::Dialect::GitHub::BlockParser - Block parser for GitHub Markdown | ||||||||||||||
| 76 | |||||||||||||||
| 77 | =head1 VERSION | ||||||||||||||
| 78 | |||||||||||||||
| 79 | version 0.39 | ||||||||||||||
| 80 | |||||||||||||||
| 81 | =head1 DESCRIPTION | ||||||||||||||
| 82 | |||||||||||||||
| 83 | This role adds parsing for some of the Markdown extensions used on GitHub. See | ||||||||||||||
| 84 | http://github.github.com/github-flavored-markdown/ for details. | ||||||||||||||
| 85 | |||||||||||||||
| 86 | =head1 ROLES | ||||||||||||||
| 87 | |||||||||||||||
| 88 | This role does the L<Markdent::Role::Dialect::BlockParser> role. | ||||||||||||||
| 89 | |||||||||||||||
| 90 | =head1 BUGS | ||||||||||||||
| 91 | |||||||||||||||
| 92 | See L<Markdent> for bug reporting details. | ||||||||||||||
| 93 | |||||||||||||||
| 94 | Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. | ||||||||||||||
| 95 | |||||||||||||||
| 96 | I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =head1 SOURCE | ||||||||||||||
| 99 | |||||||||||||||
| 100 | The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. | ||||||||||||||
| 101 | |||||||||||||||
| 102 | =head1 AUTHOR | ||||||||||||||
| 103 | |||||||||||||||
| 104 | Dave Rolsky <autarch@urth.org> | ||||||||||||||
| 105 | |||||||||||||||
| 106 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||
| 107 | |||||||||||||||
| 108 | This software is copyright (c) 2021 by Dave Rolsky. | ||||||||||||||
| 109 | |||||||||||||||
| 110 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||
| 111 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||
| 112 | |||||||||||||||
| 113 | The full text of the license can be found in the | ||||||||||||||
| 114 | F<LICENSE> file included with this distribution. | ||||||||||||||
| 115 | |||||||||||||||
| 116 | =cut | ||||||||||||||