Skip to content

Commit

Permalink
Don't emit a warning when provided an empty tag list in YFM
Browse files Browse the repository at this point in the history
This fixes #426
  • Loading branch information
mquinson committed Jun 16, 2023
1 parent 51f069a commit a2e86b2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Tex:

Markdown:
* Treat link reference definitions as no-wrap (GitHub's #422) [gemmaro].
* Don't emit a warning when provided an empty tag list in YFM
(GitHub's #426) [Martin].

General:
* Don't fail on empty po files, e.g. adoc files containing only
Expand Down
10 changes: 8 additions & 2 deletions lib/Locale/Po4a/TransTractor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1308,9 +1308,15 @@ sub handle_yaml {
my ( $self, $is_yfm, $blockref, $hash, $indent, $ctx, $yfm_keys, $yfm_skip_array, $yfm_paths ) = @_;

foreach my $name ( sort keys %$hash ) {
my $el = $hash->{$name};
my $el = $hash->{$name} // "";
my $header = ( ' ' x $indent ) . YAML::Tiny::_dump_scalar( "dummy", $name, 1 ) . ":";
my $type = ref $el;

unless ( length($el) > 0 ) { # empty element, as in "tags: " with nothing after the column
$self->pushline( $header . "\n" );
next;
}

my $type = ref $el;
if ( !$type ) {
my %keys = %{$yfm_keys};
my %paths = %{$yfm_paths};
Expand Down
1 change: 1 addition & 0 deletions t/fmt/txt-markdown/YamlFrontMatter_KeysPaths.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ numeric_ignored_value: 22
tags:
- yaml
- markdown
emptytag:
people:
-
name: John D'vloper
Expand Down
1 change: 1 addition & 0 deletions t/fmt/txt-markdown/YamlFrontMatter_KeysPaths.norm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
author: test
emptytag:
numeric_ignored_value: 22
paragraph: "Some text to translate, please.\n"
people:
Expand Down
8 changes: 4 additions & 4 deletions t/fmt/txt-markdown/YamlFrontMatter_KeysPaths.po
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ msgid "I mean: why not?"
msgstr "I MEAN: WHY NOT?"

#. type: Title #
#: YamlFrontMatter_KeysPaths.md:28
#: YamlFrontMatter_KeysPaths.md:29
#, no-wrap
msgid "YAML: does it fit in Markdown?"
msgstr "YAML: DOES IT FIT IN MARKDOWN?"

#. type: Plain text
#: YamlFrontMatter_KeysPaths.md:32
#: YamlFrontMatter_KeysPaths.md:33
msgid ""
"Lots of Static Site Generators like Jekyll, Hugo, Lektor and more use a "
"standard format: Markdown with YAML Front Matter."
Expand All @@ -50,11 +50,11 @@ msgstr ""
"STANDARD FORMAT: MARKDOWN WITH YAML FRONT MATTER."

#. type: Plain text
#: YamlFrontMatter_KeysPaths.md:34
#: YamlFrontMatter_KeysPaths.md:35
msgid "Why"
msgstr "WHY"

#. type: Plain text
#: YamlFrontMatter_KeysPaths.md:37
#: YamlFrontMatter_KeysPaths.md:38
msgid "Because blog posts need metadata!"
msgstr "BECAUSE BLOG POSTS NEED METADATA!"
8 changes: 4 additions & 4 deletions t/fmt/txt-markdown/YamlFrontMatter_KeysPaths.pot
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ msgid "I mean: why not?"
msgstr ""

#. type: Title #
#: YamlFrontMatter_KeysPaths.md:28
#: YamlFrontMatter_KeysPaths.md:29
#, markdown-text, no-wrap
msgid "YAML: does it fit in Markdown?"
msgstr ""

#. type: Plain text
#: YamlFrontMatter_KeysPaths.md:32
#: YamlFrontMatter_KeysPaths.md:33
#, markdown-text
msgid ""
"Lots of Static Site Generators like Jekyll, Hugo, Lektor and more use a "
"standard format: Markdown with YAML Front Matter."
msgstr ""

#. type: Plain text
#: YamlFrontMatter_KeysPaths.md:34
#: YamlFrontMatter_KeysPaths.md:35
#, markdown-text
msgid "Why"
msgstr ""

#. type: Plain text
#: YamlFrontMatter_KeysPaths.md:37
#: YamlFrontMatter_KeysPaths.md:38
#, markdown-text
msgid "Because blog posts need metadata!"
msgstr ""
1 change: 1 addition & 0 deletions t/fmt/txt-markdown/YamlFrontMatter_KeysPaths.trans
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
author: test
emptytag:
numeric_ignored_value: 22
paragraph: "SOME TEXT TO TRANSLATE, PLEASE.\n"
people:
Expand Down

0 comments on commit a2e86b2

Please sign in to comment.