Skip to content

Commit

Permalink
Fixes #17.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacdotorg committed Oct 29, 2017
1 parent 1635600 commit cba89a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/Plerd.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Plerd;

our $VERSION = '1.52';
our $VERSION = '1.53';

use Moose;
use Template;
Expand Down
23 changes: 12 additions & 11 deletions lib/Plerd/Post.pm
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,18 @@ sub _process_source_file {
}
$self->body( $body );

foreach ( qw( title body ) ) {
if ( defined( $self->$_ ) ) {
$self->$_( Text::SmartyPants::process( markdown( $self->$_ ) ) );
}
}

# Strip unnecessary <p> tags that the markdown processor just added to the title.
my $stripped_title = $self->title;
$stripped_title =~ s{</?p>\s*}{}g;
$self->title( $stripped_title );

# Check and tune attributes used to render social-media metatags.
if ( $attributes{ description } ) {
$self->description( $attributes{ description } );
}
Expand All @@ -402,17 +414,6 @@ sub _process_source_file {
$self->image_alt( $self->plerd->image_alt || '' );
}

foreach ( qw( title body ) ) {
if ( defined( $self->$_ ) ) {
$self->$_( Text::SmartyPants::process( markdown( $self->$_ ) ) );
}
}

# Strip unnecessary <p> tags that the markdown processor just added to the title.
my $stripped_title = $self->title;
$stripped_title =~ s{</?p>\s*}{}g;
$self->title( $stripped_title );

# Note whether the filename asserts the post's publication date.
my ( $filename_year, $filename_month, $filename_day ) =
$self->source_file->basename =~ /^(\d\d\d\d)-(\d\d)-(\d\d)/;
Expand Down
2 changes: 1 addition & 1 deletion t/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ like( $post,

like ( $image_post,
qr{name="twitter:description" content="This file sets up some attributes},
'Metatags: Default description',
'Metatags: Default description (with markup stripped)',
);

# Now add some alt text...
Expand Down
4 changes: 2 additions & 2 deletions t/source_model/metatag-setup-with-image.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: Metatags with image
image: http://blog.example.com/example.png

This file sets up some attributes that should cause some social media tags to get created in the resulting HTML, under the right circumstances.
[This file](http://example.com/) sets up some attributes that should cause some social media tags to get created in the resulting HTML, under the right circumstances.

Furthermore, it refers to a post-specific image. But it doesn't specify a description!
Furthermore, it refers to a post-specific image. But it doesn't specify a description! It does have a hyperlink in the first paragraph, though.

0 comments on commit cba89a7

Please sign in to comment.