copy new tests to test/new. have --fix add heading id's to original tests.
This commit is contained in:
parent
3b2d4bdef6
commit
6dca44b2d9
@ -324,13 +324,13 @@ function fix(options) {
|
|||||||
// node fix.js
|
// node fix.js
|
||||||
var dir = __dirname + '/tests';
|
var dir = __dirname + '/tests';
|
||||||
|
|
||||||
// fix unencoded quotes
|
|
||||||
fs.readdirSync(dir).filter(function(file) {
|
fs.readdirSync(dir).filter(function(file) {
|
||||||
return path.extname(file) === '.html';
|
return path.extname(file) === '.html';
|
||||||
}).forEach(function(file) {
|
}).forEach(function(file) {
|
||||||
var file = path.join(dir, file)
|
var file = path.join(dir, file)
|
||||||
, html = fs.readFileSync(file, 'utf8');
|
, html = fs.readFileSync(file, 'utf8');
|
||||||
|
|
||||||
|
// fix unencoded quotes
|
||||||
html = html
|
html = html
|
||||||
.replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;')
|
.replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;')
|
||||||
.replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;')
|
.replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;')
|
||||||
@ -339,6 +339,21 @@ function fix(options) {
|
|||||||
.replace(/&__QUOT__;/g, '"')
|
.replace(/&__QUOT__;/g, '"')
|
||||||
.replace(/&__APOS__;/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);
|
fs.writeFileSync(file, html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<h2>foo</h2>
|
<h2 id="foo">foo</h2>
|
||||||
<ol>
|
<ol>
|
||||||
<li><p>bar:</p>
|
<li><p>bar:</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<h1>A heading</h1> <p>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 <a href="http://google.com/" title="Google">inconsistent</a> with regards to paragraphs in list items.</p> <p>A link. Not anymore.</p> <aside>This will make me fail the test because
|
<h1 id="a-heading">A heading</h1> <p>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 <a href="http://google.com/" title="Google">inconsistent</a> with regards to paragraphs in list items.</p> <p>A link. Not anymore.</p> <aside>This will make me fail the test because
|
||||||
markdown.js doesnt acknowledge arbitrary html blocks =/</aside> <ul><li><p>List Item 1</p></li><li><p>List Item 2 </p><ul><li>New List Item 1 Hi, this is a list item.</li><li>New List Item 2 Another item <pre><code>Code goes here.
|
markdown.js doesnt acknowledge arbitrary html blocks =/</aside> <ul><li><p>List Item 1</p></li><li><p>List Item 2 </p><ul><li>New List Item 1 Hi, this is a list item.</li><li>New List Item 2 Another item <pre><code>Code goes here.
|
||||||
Lots of it...</code></pre></li><li>New List Item 3 The last item</li></ul></li><li><p>List Item 3 The final item.</p></li><li><p>List Item 4 The real final item.</p></li></ul> <p>Paragraph.</p> <blockquote><ul><li>bq Item 1</li><li>bq Item 2 <ul><li>New bq Item 1</li><li>New bq Item 2 Text here</li></ul></li></ul></blockquote> <hr> <blockquote><p> Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again</p></blockquote> <h2>Another Heading</h2> <p>Hello <em>world</em>. Here is a <a href="//hello">link</a>. And an image <img src="src" alt="alt">.</p> <pre><code>Code goes here.
|
Lots of it...</code></pre></li><li>New List Item 3 The last item</li></ul></li><li><p>List Item 3 The final item.</p></li><li><p>List Item 4 The real final item.</p></li></ul> <p>Paragraph.</p> <blockquote><ul><li>bq Item 1</li><li>bq Item 2 <ul><li>New bq Item 1</li><li>New bq Item 2 Text here</li></ul></li></ul></blockquote> <hr> <blockquote><p> Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again</p></blockquote> <h2 id="another-heading">Another Heading</h2> <p>Hello <em>world</em>. Here is a <a href="//hello">link</a>. And an image <img src="src" alt="alt">.</p> <pre><code>Code goes here.
|
||||||
Lots of it...</code></pre>
|
Lots of it...</code></pre>
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>hello world</p>
|
<p>hello world</p>
|
||||||
<h1>how are you</h1>
|
<h1 id="how-are-you">how are you</h1>
|
||||||
|
|
||||||
<p>hello world</p>
|
<p>hello world</p>
|
||||||
<h1>how are you</h1>
|
<h1 id="how-are-you">how are you</h1>
|
||||||
|
|
||||||
<p>hello world</p>
|
<p>hello world</p>
|
||||||
<blockquote><p>how are you</p></blockquote>
|
<blockquote><p>how are you</p></blockquote>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user