Skip to content

Commit

Permalink
Updates to get_isbn, get_math and #011
Browse files Browse the repository at this point in the history
  • Loading branch information
bgwhite committed Apr 22, 2014
1 parent 90f3bc9 commit d44b421
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions checkwiki.pl
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,8 @@ sub get_math {
error_013_Math_no_correct_end($snippet);
}

$text =~ s/<math(.*?)<\/math>//sg;
# LEAVE MATH TAG IN. CAUSES PROBLEMS WITH #61, #65 and #67
$text =~ s/<math(.*?)<\/math>/<math><\/math>/sg;
}

return ();
Expand Down Expand Up @@ -1143,8 +1144,15 @@ sub get_isbn {
my $test_text = uc($text);

if ( $test_text =~ / ISBN\s*([-]|[:]|10|13)\s*/g ) {
my $output = substr( $test_text, pos($test_text) - 5, 16 );
error_069_isbn_wrong_syntax($output);
my $output = substr( $test_text, pos($test_text) - 11, 40 );

# INFOBOX CAN HAVE "| ISBN10 = ".
# ALSO DON'T CHECK ISBN (10|13)XXXXXXXXXX
if ( ( $output !~ /\|\s*ISBN(10|13)\s*=/g )
and ( $output !~ /ISBN\s*([-]|[:]){0,1}\s*(10|13)\d/g ) )
{
error_069_isbn_wrong_syntax($output);
}
}

while ( $test_text =~ /ISBN([ ]|[-]|[=]|[:])/g ) {
Expand Down Expand Up @@ -1181,17 +1189,22 @@ sub get_isbn {
}
}
elsif ( $digits == 13 ) {
my $sum;
foreach my $index ( 0, 2, 4, 6, 8, 10 ) {
$sum += substr( $isbn_strip, $index, 1 );
$sum += 3 * substr( $isbn_strip, $index + 1, 1 );
if ( $isbn_strip =~ /X/g ) {
error_073_isbn_13_wrong_checksum($isbn_strip);
}
my $checksum =
( 10 * ( int( $sum / 10 ) + 1 ) - $sum ) % 10;
else {
my $sum;
foreach my $index ( 0, 2, 4, 6, 8, 10 ) {
$sum += substr( $isbn_strip, $index, 1 );
$sum += 3 * substr( $isbn_strip, $index + 1, 1 );
}
my $checksum =
( 10 * ( int( $sum / 10 ) + 1 ) - $sum ) % 10;

if ( $checksum ne substr( $isbn_strip, 12, 1 ) ) {
$isbn = $isbn . ' vs ' . $checksum;
error_073_isbn_13_wrong_checksum($isbn);
if ( $checksum ne substr( $isbn_strip, 12, 1 ) ) {
$isbn = $isbn . ' vs ' . $checksum;
error_073_isbn_13_wrong_checksum($isbn);
}
}
}
else {
Expand Down Expand Up @@ -2147,9 +2160,12 @@ sub error_011_html_named_entities {
{
my $pos = -1;

foreach (@HTML_NAMED_ENTITIES) {
if ( $lc_text =~ /&$_;/g ) {
$pos = $-[0];
# HTML NAMED ENTITIES ALLOWED IN MATH TAGS
if ( $lc_text !~ /<math|\{\{math\s*\|/ ) {
foreach (@HTML_NAMED_ENTITIES) {
if ( $lc_text =~ /&$_;/g ) {
$pos = $-[0];
}
}
}

Expand Down

0 comments on commit d44b421

Please sign in to comment.