| 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 | default => sub { | ||
| 34 | 0 | ▶ | 'Text::Markdown' |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 35 | }, | ||
| 36 | coerce => sub { | ||
| 37 | 0 | ▶ | instantiate( $_[0] ) |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 38 | } | ||
| 39 | 1 | ; | |
| 40 | |||
| 41 | sub augment { | ||
| 42 | 0 | ▶ | my $self = shift; |
|
Subroutine
augment: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 43 | 0 | my $item = shift; | |
| 44 | 0 | $item->content ( | |
| 45 | $self->markdown_parser->markdown($item->content) | ||
| 46 | ); | ||
| 47 | 0 | return $item; | |
| 48 | } | ||
| 49 | |||
| 50 | 1 | 1; | |