diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-04 19:17:52 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-04 19:17:52 +0000 |
| commit | c25983466093e99c625ff11bf750dfbbf4c5f845 (patch) | |
| tree | 96358f17cbbeae463ecdba44e5378346018acfeb /lib | |
| parent | 2c02b7caa502c2ec529b571fd3eb20d77f54d374 (diff) | |
Simplify self-closing tags in markdown
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/writers/markdown-writer.js | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js index 711f722..f39e018 100644 --- a/lib/writers/markdown-writer.js +++ b/lib/writers/markdown-writer.js @@ -13,10 +13,6 @@ function markdownElement(start, end) { this.close = function() { return end; }; - - this.empty = function(attrs) { - return this.open(attrs) + this.close(); - }; } function markdownLink() { @@ -30,34 +26,20 @@ function markdownLink() { this.close = function() { return "](" + (href || "") + ")"; }; - - this.empty = function(attrs) { - // don't display empty content (this is mainly to remove images with no src data) - return this.open(attrs) + this.close(); - }; } function markdownImage() { this.open = function(attributes) { var src = attributes.src || ""; var altText = attributes.alt || ""; - return ""; + if (src || altText) { + return ""; + } }; this.close = function() { return ""; }; - - this.empty = function(attrs) { - // don't display empty content (this is mainly to remove images with no src data) - var content = this.open(attrs) + this.close(); - - if (content === "![]()") { - return ""; - } - - return content; - }; } function markdownList() { @@ -68,10 +50,6 @@ function markdownList() { this.close = function(attrs) { return attrs.indent > -1 ? "" : "\n"; }; - - this.empty = function(attrs) { - return this.open(attrs) + this.close(); - }; } function markdownListItem() { @@ -88,10 +66,6 @@ function markdownListItem() { this.close = function() { return "\n"; }; - - this.empty = function(attrs) { - return this.open(attrs) + this.close(); - }; } // map HTML tags to Markdown syntax @@ -164,11 +138,8 @@ function markdownWriter() { } function selfClosing(tagName, attributes) { - attributes = attributes || {}; - - if (htmlmarkdown[tagName]) { - fragments.push(htmlmarkdown[tagName].empty(attributes)); - } + open(tagName, attributes); + close(tagName); } function text(value) { |
