Skip to content

Commit 6340d15

Browse files
committed
Fix bug for repeating array of 1 element
1 parent 78d8077 commit 6340d15

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

bin/yaml-grammar-html-to-yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ sub reformat_input_text {
173173
# Add missing parens in rule 211:
174174
s/(l-document-suffix\+ l-document-prefix\*\nl-any-document\?)(\n\| )(l-document-prefix\* l-explicit-document\?)/( $1 )$2( $3 )/;
175175

176-
177176
return $_;
178177
}
179178

@@ -553,6 +552,7 @@ my $n = 1;
553552
sub reformat_data {
554553
my ($data) = @_;
555554

555+
556556
for my $next (@$data) {
557557
if (my $rule = $next->{rule}) {
558558
$rule->{rule} = reformat_node($rule->{rule});
@@ -646,6 +646,7 @@ sub reformat_data {
646646
return { $func => reformat_node($array) };
647647
}
648648
else {
649+
$array = $array->[0] if @$array == 1;
649650
return { $func => reformat_node(reformatted($array)) };
650651
}
651652
}

spec-1.2.json

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,35 +3067,33 @@
30673067
"(???)": "l-any-document"
30683068
},
30693069
{
3070-
"(***)": [
3071-
{
3072-
"(any)": [
3073-
{
3074-
"(all)": [
3075-
{
3076-
"(+++)": "l-document-suffix"
3077-
},
3078-
{
3079-
"(***)": "l-document-prefix"
3080-
},
3081-
{
3082-
"(???)": "l-any-document"
3083-
}
3084-
]
3085-
},
3086-
{
3087-
"(all)": [
3088-
{
3089-
"(***)": "l-document-prefix"
3090-
},
3091-
{
3092-
"(???)": "l-explicit-document"
3093-
}
3094-
]
3095-
}
3096-
]
3097-
}
3098-
]
3070+
"(***)": {
3071+
"(any)": [
3072+
{
3073+
"(all)": [
3074+
{
3075+
"(+++)": "l-document-suffix"
3076+
},
3077+
{
3078+
"(***)": "l-document-prefix"
3079+
},
3080+
{
3081+
"(???)": "l-any-document"
3082+
}
3083+
]
3084+
},
3085+
{
3086+
"(all)": [
3087+
{
3088+
"(***)": "l-document-prefix"
3089+
},
3090+
{
3091+
"(???)": "l-explicit-document"
3092+
}
3093+
]
3094+
}
3095+
]
3096+
}
30993097
}
31003098
]
31013099
}

spec-1.2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3332,7 +3332,7 @@ l-yaml-stream:
33323332
- (***): l-document-prefix
33333333
- (???): l-any-document
33343334
- (***):
3335-
- (any):
3335+
(any):
33363336
- (all):
33373337
- (+++): l-document-suffix
33383338
- (***): l-document-prefix

0 commit comments

Comments
 (0)