diff --git a/test/index.js b/test/index.js index 0a9e094b..cc7262b7 100644 --- a/test/index.js +++ b/test/index.js @@ -324,13 +324,13 @@ function fix(options) { // node fix.js var dir = __dirname + '/tests'; - // fix unencoded quotes fs.readdirSync(dir).filter(function(file) { return path.extname(file) === '.html'; }).forEach(function(file) { var file = path.join(dir, file) , html = fs.readFileSync(file, 'utf8'); + // fix unencoded quotes html = html .replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;') .replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;') @@ -339,6 +339,21 @@ function fix(options) { .replace(/&__QUOT__;/g, '"') .replace(/&__APOS__;/g, '\''); + // add heading id's + html = html + .replace(/<(h[1-6])>([^<]+)<\/\1>/g, function(s, h, text) { + var id = text + .replace(/'/g, '\'') + .replace(/"/g, '"') + .replace(/>/g, '>') + .replace(/</g, '<') + .replace(/&/g, '&'); + + id = id.toLowerCase().replace(/\s/g, '-'); + + return '<' + h + ' id="' + id + '">' + text + '' + h + '>'; + }); + fs.writeFileSync(file, html); }); diff --git a/test/new/gfm_code_hr_list.html b/test/new/gfm_code_hr_list.html index 783d84cd..9fbd0fb9 100644 --- a/test/new/gfm_code_hr_list.html +++ b/test/new/gfm_code_hr_list.html @@ -1,4 +1,4 @@ -
bar:
diff --git a/test/new/main.html b/test/new/main.html index a1e20f6a..8f78c4d3 100644 --- a/test/new/main.html +++ b/test/new/main.html @@ -1,4 +1,4 @@ -A heading
Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely inconsistent with regards to paragraphs in list items.
A link. Not anymore.
List Item 3 The final item.
List Item 4 The real final item.
Paragraph.
- bq Item 1
- bq Item 2
- New bq Item 1
- New bq Item 2 Text here
Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again
Hello world. Here is a link. And an image .
Code goes here.
Lots of it...
diff --git a/test/new/toplevel_paragraphs.html b/test/new/toplevel_paragraphs.html
index 3faf7963..97d715e2 100644
--- a/test/new/toplevel_paragraphs.html
+++ b/test/new/toplevel_paragraphs.html
@@ -9,10 +9,10 @@
hello world
-hello world
-hello world
how are you