diff --git a/gen.pl b/gen.pl index d7699f10e4235b0563380b269678f7ea468e45cd..92da06e3367eac6bd6aaca9c127adf28c1edf254 100755 --- a/gen.pl +++ b/gen.pl @@ -50,9 +50,8 @@ while (<>) { my $any = 0; foreach my $opt (@options) { - # unless (defined $opt->{"correct"}) { - # die "undefined \"$question\" ($ARGV:$.)\n"; - # } + $opt->{"option"} = md($opt->{"option"}) + if $opt->{"option"}; $any = 1 if (not (defined $opt->{"correct"})) or ($opt->{"correct"} eq JSON::true); } die "no correct option at \"$question\" ($ARGV)\n" @@ -80,9 +79,12 @@ while (<>) { $question = $2; chomp $question; - - $source = $3; - chomp $source if $source; + } elsif (/^[|](.+)/) { + if ($last_option{"option"}) { + $last_option{"option"} .= $1; + } else { + $question .= $1; + } } elsif (/^@(.*)/) { $media = $1; chomp $media; @@ -90,7 +92,7 @@ while (<>) { add(); %last_option = ( - "option" => md($2), + "option" => $2, "correct" => $1 eq "+" ? JSON::true : $1 eq "-" ? JSON::false : JSON::null ); } elsif (/^.+$/) { # non-empty line