Просмотр исходного кода

Merge branch 'master' of https://github.com/vincent314/showdown into vincent314-master

Estevão Soares dos Santos 10 лет назад
Родитель
Сommit
6db86a3d2b

+ 43 - 0
test/extensions/table/multiple-tables.html

@@ -0,0 +1,43 @@
+<h1 id="tabletest">Table Test</h1>
+
+<h2 id="section1">section 1</h2>
+
+<table>
+    <thead>
+    <tr>
+        <th id="header1" style="text-align:left;">header1    </th>
+        <th id="header2" style="text-align:left;">header2    </th>
+        <th id="header3" style="text-align:left;">header3</th>
+    </tr>
+    </thead>
+
+    <tbody>
+    <tr>
+        <td style="text-align:left;"><p>Value1     </p></td>
+        <td style="text-align:left;"><p>Value2     </p></td>
+        <td style="text-align:left;"><p>Value3   </p></td>
+    </tr>
+
+    </tbody>
+</table>
+
+<h2 id="section2">section 2</h2>
+
+<table>
+    <thead>
+    <tr>
+        <th id="headera" style="text-align:left;">headerA    </th>
+        <th id="headerb" style="text-align:left;">headerB    </th>
+        <th id="headerc" style="text-align:left;">headerC</th>
+    </tr>
+    </thead>
+
+    <tbody>
+    <tr>
+        <td style="text-align:left;"><p>ValueA     </p></td>
+        <td style="text-align:left;"><p>ValueB     </p></td>
+        <td style="text-align:left;"><p>ValueC   </p></td>
+    </tr>
+
+    </tbody>
+</table>

+ 17 - 0
test/extensions/table/multiple-tables.md

@@ -0,0 +1,17 @@
+Table Test
+============
+
+section 1
+------------
+
+|header1    |header2    |header3|
+|-----------|-----------|---------|
+|Value1     |Value2     |Value3   |
+
+
+section 2
+-----------
+
+|headerA    |headerB    |headerC|
+|-----------|-----------|---------|
+|ValueA     |ValueB     |ValueC   |

+ 24 - 0
test/testTable.js

@@ -0,0 +1,24 @@
+var Showdown = require('../src/showdown');
+var fs = require('fs');
+
+module.exports = {
+    setUp:function(callback) {
+        this.showdown = new Showdown.converter({extensions:['table']});
+        callback();
+    },
+    testMakeHtml:function(test) {
+        var html = this.showdown.makeHtml("**blah**");
+        console.log(html);
+        test.equals(html ,'<p><strong>blah</strong></p>');
+        test.done();
+    },
+    testMakeTable:function(test) {
+        var md = fs.readFileSync('test/extensions/table/multiple-tables.md','UTF-8');
+        var html = fs.readFileSync('test/extensions/table/multiple-tables.html','UTF-8');
+
+        var result = this.showdown.makeHtml(md);
+        console.log(result);
+        test.equals(result, html);
+        test.done();
+    }
+};