diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-09-26 22:42:46 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-09-26 22:42:46 +0100 |
| commit | 8e6e755f793a02cf8986da1f8efb1c0c12d8d7a7 (patch) | |
| tree | b894fc137177f086317ed079af925b59a03204a4 /test/writers/markdown-writer.tests.js | |
| parent | 9463f5c6ba7161477a6be98e2620044ad2c967db (diff) | |
Escape markdown image alt text and src
Diffstat (limited to 'test/writers/markdown-writer.tests.js')
| -rw-r--r-- | test/writers/markdown-writer.tests.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/writers/markdown-writer.tests.js b/test/writers/markdown-writer.tests.js index d66cc79..578e6ff 100644 --- a/test/writers/markdown-writer.tests.js +++ b/test/writers/markdown-writer.tests.js @@ -117,13 +117,25 @@ test('links have anchors before opening square bracket', function() { test('can generate images', function() { var writer = mdWriter.writer(); writer.selfClosing("img", {"src": "http://example.com/image.jpg", "alt": "Alt Text"}); - return assert.equal(writer.asString(), ""); + return assert.equal(writer.asString(), ""); +}); + +test('image alt text is escaped', function() { + var writer = mdWriter.writer(); + writer.selfClosing("img", {"src": "http://example.com/image.jpg", "alt": "Alt Text]Oops"}); + return assert.equal(writer.asString(), "![Alt Text\\]Oops](http://example\\.com/image\\.jpg)"); +}); + +test('image src is escaped', function() { + var writer = mdWriter.writer(); + writer.selfClosing("img", {"src": "http://example.com/image.jpg)Oops", "alt": "Alt Text"}); + return assert.equal(writer.asString(), "Oops)"); }); test('can generate images with missing alt attribute', function() { var writer = mdWriter.writer(); writer.selfClosing("img", {"src": "http://example.com/image.jpg"}); - return assert.equal(writer.asString(), ""); + return assert.equal(writer.asString(), ""); }); test('can generate images with missing src attribute', function() { |
