(text)
| 305 | |
| 306 | |
| 307 | var _HashHTMLBlocks = function(text) { |
| 308 | // attacklab: Double up blank lines to reduce lookaround |
| 309 | text = text.replace(/\n/g,"\n\n"); |
| 310 | |
| 311 | // Hashify HTML blocks: |
| 312 | // We only want to do this for block-level HTML tags, such as headers, |
| 313 | // lists, and tables. That's because we still want to wrap <p>s around |
| 314 | // "paragraphs" that are wrapped in non-block-level tags, such as anchors, |
| 315 | // phrase emphasis, and spans. The list of tags we're looking for is |
| 316 | // hard-coded: |
| 317 | var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" |
| 318 | var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" |
| 319 | |
| 320 | // First, look for nested blocks, e.g.: |
| 321 | // <div> |
| 322 | // <div> |
| 323 | // tags for inner block must be indented. |
| 324 | // </div> |
| 325 | // </div> |
| 326 | // |
| 327 | // The outermost tags must start at the left margin for this to match, and |
| 328 | // the inner nested divs must be indented. |
| 329 | // We need to do this before the next, more liberal match, because the next |
| 330 | // match will start at the first `<div>` and stop at the first `</div>`. |
| 331 | |
| 332 | // attacklab: This regex can be expensive when it fails. |
| 333 | /* |
| 334 | var text = text.replace(/ |
| 335 | ( // save in $1 |
| 336 | ^ // start of line (with /m) |
| 337 | <($block_tags_a) // start tag = $2 |
| 338 | \b // word break |
| 339 | // attacklab: hack around khtml/pcre bug... |
| 340 | [^\r]*?\n // any number of lines, minimally matching |
| 341 | </\2> // the matching end tag |
| 342 | [ \t]* // trailing spaces/tabs |
| 343 | (?=\n+) // followed by a newline |
| 344 | ) // attacklab: there are sentinel newlines at end of document |
| 345 | /gm,function(){...}}; |
| 346 | */ |
| 347 | text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement); |
| 348 | |
| 349 | // |
| 350 | // Now match more liberally, simply from `\n<tag>` to `</tag>\n` |
| 351 | // |
| 352 | |
| 353 | /* |
| 354 | var text = text.replace(/ |
| 355 | ( // save in $1 |
| 356 | ^ // start of line (with /m) |
| 357 | <($block_tags_b) // start tag = $2 |
| 358 | \b // word break |
| 359 | // attacklab: hack around khtml/pcre bug... |
| 360 | [^\r]*? // any number of lines, minimally matching |
| 361 | .*</\2> // the matching end tag |
| 362 | [ \t]* // trailing spaces/tabs |
| 363 | (?=\n+) // followed by a newline |
| 364 | ) // attacklab: there are sentinel newlines at end of document |
no outgoing calls
no test coverage detected