| 1 | # turndown-attendant |
| 2 | |
| 3 | Test runner for HTML to Markdown conversions with Turndown |
| 4 | |
| 5 | ## Usage |
| 6 | |
| 7 | Specify you input HTML and your expected output in an HTML file: |
| 8 | |
| 9 | ```html |
| 10 | <!-- test.html --> |
| 11 | <div class="case", data-name="headings"> |
| 12 | <div class="input"> |
| 13 | <h1>Hello world</h1> |
| 14 | </div> |
| 15 | <pre class="expected"># Hello world</pre> |
| 16 | </div> |
| 17 | ``` |
| 18 | |
| 19 | Create a new attendant with the `TurndownService` class, the HTML file, and optionally a `beforeEach` function which gets called with the new `TurndownService` instance. (This is useful for applying plugins.) Then call `run` to run the test cases. |
| 20 | |
| 21 | ```js |
| 22 | var TurndownService = require('turndown') |
| 23 | var Attendant = require('turndown-attendant') |
| 24 | |
| 25 | var attendant = new Attendant({ |
| 26 | Turndown: TurndownService, |
| 27 | file: '/path/to/test.html', |
| 28 | beforeEach: function (turndownService) { |
| 29 | turndownService.use(…) |
| 30 | } |
| 31 | }) |
| 32 | |
| 33 | attendant.run() |
| 34 | ``` |
| 35 | |
| 36 | To run tests that do not require HTML or a DOM, access `test` on the `attendant` instance: |
| 37 | |
| 38 | ```js |
| 39 | attendant.test('test something else', function (t) { … }) |
| 40 | ``` |