| 1 | package Articulate::Augmentation::Interpreter::Markdown; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | with 'Articulate::Role::Component'; | |
| 7 | 1 | ▶ | use Articulate::Syntax qw (instantiate); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Text::Markdown; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Articulate::Augmentation::Interpreter::Markdown - convert markdown to HTML | ||
| 13 | |||
| 14 | =head1 METHODS | ||
| 15 | |||
| 16 | =head3 augment | ||
| 17 | |||
| 18 | Converts markdown in the content of the response into HTML. | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | =head1 ATTRIBUTES | ||
| 23 | |||
| 24 | =head3 markdown_parser | ||
| 25 | |||
| 26 | The parser which will be used. This is instantiated and defaults to L<Text::Markdown> - but note that L<Text::Markdown> expects a plain hash, not a reference, so it will need to be configured as an array. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | has markdown_parser => ( | ||
| 31 | is => 'rw', | ||
| 32 | lazy => 1, | ||
| 33 | 0 | ▶ | default => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 34 | 0 | 'Text::Markdown'; | |
| 35 | }, | ||
| 36 | 0 | ▶ | coerce => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 37 | 0 | instantiate( $_[0] ); | |
| 38 | }, | ||
| 39 | 1 | ); | |
| 40 | |||
| 41 | 0 | ▶ | sub augment { |
|
Subroutine
augment: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 42 | 0 | my $self = shift; | |
| 43 | 0 | my $item = shift; | |
| 44 | 0 | $item->content( $self->markdown_parser->markdown( $item->content ) ); | |
| 45 | 0 | return $item; | |
| 46 | } | ||
| 47 | |||
| 48 | 1 | 1; | |