diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-04 19:05:28 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-04 19:05:28 +0000 |
| commit | 87b5c312309c517030f2130f3deb24082814a67f (patch) | |
| tree | a80b7ae42dfb0cf5e79a1be6674ada347e073b9a /lib | |
| parent | cdffcd49c9d9bda72974e079ba5a9275f5ae719a (diff) | |
Use markdown in identifiers rather than md
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/writers/markdown-writer.js | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js index 148d963..02bef16 100644 --- a/lib/writers/markdown-writer.js +++ b/lib/writers/markdown-writer.js @@ -1,7 +1,7 @@ var _ = require("underscore"); -function mdElement(start, end) { +function markdownElement(start, end) { if (end === undefined) { end = start; } @@ -19,7 +19,7 @@ function mdElement(start, end) { }; } -function mdLink(link, text) { +function markdownLink(link, text) { var attrs = {}; this.open = function(attributes) { @@ -44,7 +44,7 @@ function mdLink(link, text) { }; } -function mdList() { +function markdownList() { this.open = function(attrs) { return attrs.indent > -1 ? "\n" : ""; }; @@ -58,7 +58,7 @@ function mdList() { }; } -function mdListItem() { +function markdownListItem() { this.open = function(attrs) { var output = ""; @@ -79,28 +79,28 @@ function mdListItem() { } // map HTML tags to Markdown syntax -var htmlmd = { +var htmlmarkdown = { // paragraphs elements use three line feeds to close // this prevents them being caught by collapsing list elements in `asString` // while still allowing them to be collapsed when multiple empty lines are removed - "h1": new mdElement("# ", "\n\n\n"), - "h2": new mdElement("## ", "\n\n\n"), - "h3": new mdElement("### ", "\n\n\n"), - "h4": new mdElement("#### ", "\n\n\n"), - "h5": new mdElement("##### ", "\n\n\n"), - "h6": new mdElement("###### ", "\n\n\n"), - "p": new mdElement("", "\n\n\n"), - "br": new mdElement("", " \n"), - "ul": new mdList(), - "ol": new mdList(), - "li": new mdListItem(), - "strong": new mdElement("**"), - "em": new mdElement("*"), - "a": new mdLink("href"), - "img": new mdLink("src", "alt"), + "h1": new markdownElement("# ", "\n\n\n"), + "h2": new markdownElement("## ", "\n\n\n"), + "h3": new markdownElement("### ", "\n\n\n"), + "h4": new markdownElement("#### ", "\n\n\n"), + "h5": new markdownElement("##### ", "\n\n\n"), + "h6": new markdownElement("###### ", "\n\n\n"), + "p": new markdownElement("", "\n\n\n"), + "br": new markdownElement("", " \n"), + "ul": new markdownList(), + "ol": new markdownList(), + "li": new markdownListItem(), + "strong": new markdownElement("**"), + "em": new markdownElement("*"), + "a": new markdownLink("href"), + "img": new markdownLink("src", "alt"), }; -function mdWriter() { +function markdownWriter() { var fragments = []; var listStack = []; var list = { @@ -114,7 +114,7 @@ function mdWriter() { } function open(tagName, attributes) { - if (htmlmd[tagName]) { + if (htmlmarkdown[tagName]) { attributes = attributes || {}; if (tagName === "li") { @@ -125,7 +125,7 @@ function mdWriter() { attributes.indent = list.indent; } - fragments.push(htmlmd[tagName].open(attributes)); + fragments.push(htmlmarkdown[tagName].open(attributes)); if (isList(tagName)) { listStack.push(_.clone(list)); @@ -138,18 +138,18 @@ function mdWriter() { } function close(tagName) { - if (htmlmd[tagName]) { + if (htmlmarkdown[tagName]) { if (isList(tagName)) { list = listStack.pop(); } - fragments.push(htmlmd[tagName].close(list)); + fragments.push(htmlmarkdown[tagName].close(list)); } } function selfClosing(tagName, attributes) { - if (htmlmd[tagName]) { - fragments.push(htmlmd[tagName].empty(attributes)); + if (htmlmarkdown[tagName]) { + fragments.push(htmlmarkdown[tagName].empty(attributes)); } } @@ -176,4 +176,4 @@ function mdWriter() { }; } -exports.writer = mdWriter; +exports.writer = markdownWriter; |
