| 1 | # ABSTRACT: Perl Markdown Compiler | ||||||||||
| 2 | package Markdown::Compiler; | ||||||||||
| 3 | 18 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 18 | ▶ | use Markdown::Compiler::Source; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 18 | ▶ | use Markdown::Compiler::Lexer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 18 | ▶ | use Markdown::Compiler::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 18 | ▶ | use Markdown::Compiler::Target::HTML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 18 | ▶ | use Module::Runtime qw( use_module ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 18 | ▶ | use YAML::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 18 | has source => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | required => 1, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | has _source => ( | ||||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | lazy => 1, | ||||||||||
| 19 | 34 | ▶ | builder => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build__source: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 34 | Markdown::Compiler::Source->new( source => shift->source ); | |||||||||
| 21 | } | ||||||||||
| 22 | 18 | ); | |||||||||
| 23 | |||||||||||
| 24 | has lexer => ( | ||||||||||
| 25 | is => 'ro', | ||||||||||
| 26 | lazy => 1, | ||||||||||
| 27 | 7 | ▶ | builder => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build_lexer: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 7 | Markdown::Compiler::Lexer->new( source => shift->_source->body ); | |||||||||
| 29 | }, | ||||||||||
| 30 | 18 | ); | |||||||||
| 31 | |||||||||||
| 32 | has parser => ( | ||||||||||
| 33 | is => 'ro', | ||||||||||
| 34 | lazy => 1, | ||||||||||
| 35 | 54 | ▶ | builder => sub { | ||||||||
|
Subroutine
_build_parser: called CC=1 SCAR=0.0
| |||||||||||
| 36 | 54 | Markdown::Compiler::Parser->new( stream => shift->stream ); | |||||||||
| 37 | }, | ||||||||||
| 38 | 18 | ); | |||||||||
| 39 | |||||||||||
| 40 | has stream => ( | ||||||||||
| 41 | is => 'ro', | ||||||||||
| 42 | lazy => 1, | ||||||||||
| 43 | 64 | ▶ | builder => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 64 | shift->lexer->tokens; | |||||||||
| 45 | }, | ||||||||||
| 46 | 18 | ); | |||||||||
| 47 | |||||||||||
| 48 | has tree => ( | ||||||||||
| 49 | is => 'ro', | ||||||||||
| 50 | lazy => 1, | ||||||||||
| 51 | 64 | ▶ | builder => sub { | ||||||||
|
Subroutine
_build_tree: called CC=1 SCAR=0.0
| |||||||||||
| 52 | 64 | shift->parser->tree; | |||||||||
| 53 | }, | ||||||||||
| 54 | 18 | ); | |||||||||
| 55 | |||||||||||
| 56 | has compiler => ( | ||||||||||
| 57 | is => 'ro', | ||||||||||
| 58 | lazy => 1, | ||||||||||
| 59 | 40 | ▶ | builder => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 60 | 40 | Markdown::Compiler::Target::HTML->new( tree => shift->tree ); | |||||||||
| 61 | }, | ||||||||||
| 62 | 18 | ); | |||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub compiler_for { | ||||||||
|
Subroutine
compiler_for: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 65 | 0 | my ( $self, $target ) = @_; | |||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | $target = substr($target,0,1) eq '+' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | ? substr($target,1) | ||||||||||
| 69 | : 'Markdown::Compiler::Target::' . $target; | ||||||||||
| 70 | |||||||||||
| 71 | 0 | return use_module("$target")->new( tree => $self->tree ); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | has result => ( | ||||||||||
| 75 | is => 'ro', | ||||||||||
| 76 | lazy => 1, | ||||||||||
| 77 | 64 | ▶ | builder => sub { | ||||||||
|
Subroutine
_build_result: called CC=1 SCAR=0.0
| |||||||||||
| 78 | 64 | shift->compiler->result; | |||||||||
| 79 | } | ||||||||||
| 80 | 18 | ); | |||||||||
| 81 | |||||||||||
| 82 | has metadata => ( | ||||||||||
| 83 | is => 'ro', | ||||||||||
| 84 | lazy => 1, | ||||||||||
| 85 | 2 | ▶ | builder => sub { | ||||||||
|
Subroutine
_build_metadata: called CC=2 SCAR=7.6
| |||||||||||
| 86 | 2 | my ( $self ) = @_; | |||||||||
| 87 | |||||||||||
| 88 | # Process YAML files with YAML::XS. | ||||||||||
| 89 | 2 | ▶ | if ( $self->_source->metatype eq 'YAML' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 2 | return Load( $self->_source->metadata ); | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 0 | return $self->_source->metadata; | |||||||||
| 94 | } | ||||||||||
| 95 | 18 | ); | |||||||||
| 96 | |||||||||||
| 97 | 18 | 1; | |||||||||
| 98 | |||||||||||
| 99 | __END__ | ||||||||||