Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

pre code platform Compatible #75

Closed
wants to merge 1 commit into from

3 participants

@linhuiwu

Low-end engine browers Array.prototype.splice requires 2nd argument to specify the
number of elements to be removed.

jsonml.splice(i, 1);

you can't remove the '1'.

  •  code.push.apply( code, jsonml.splice( i ) );
    
  •  code.push.apply( code, jsonml.splice( i , 1 ) );
    
@ashb
Collaborator

Hmmm, for completeness that 1 should be jsonml.length-i:

a = [1,2,3,4,5];
a.splice(2)
/*
3,4,5
*/

a = [1,2,3,4,5];
a.splice(2,1);
/*
3
*/

a = [1,2,3,4,5];
a.splice(2,a.length-2);

/*
3,4,5
*/

Although right now a code_block tree node will only have 1 element after the attributes it's probably best to not rely on that.

There are other instance of Array#splice only passing one argument in this codebase. Please fix them up too.

@evilstreak
Owner

This issue is resolved by 98d99c8.

@evilstreak evilstreak closed this
@linhuiwu

Thanks .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2013
  1. @linhuiwu

    pre code platform Compatible

    linhuiwu authored
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/markdown.js
View
2  lib/markdown.js
@@ -1492,7 +1492,7 @@ function convert_tree_to_html( tree, references, options ) {
jsonml[ 0 ] = "pre";
i = attrs ? 2 : 1;
var code = [ "code" ];
- code.push.apply( code, jsonml.splice( i ) );
+ code.push.apply( code, jsonml.splice( i , 1 ) );
jsonml[ i ] = code;
break;
case "inlinecode":
Something went wrong with that request. Please try again.