aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-02-04 19:26:49 +0000
committerMichael Williamson <mike@zwobble.org>2015-02-04 19:26:49 +0000
commit817a7d6a4eddb2eea305779333e27105abebeb87 (patch)
tree87cac93ab67cee06f9ac75253d12485015d38f7a /lib
parentc25983466093e99c625ff11bf750dfbbf4c5f845 (diff)
Remove duplication of markdown headings
Diffstat (limited to 'lib')
-rw-r--r--lib/writers/markdown-writer.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/writers/markdown-writer.js b/lib/writers/markdown-writer.js
index f39e018..b4fbb8e 100644
--- a/lib/writers/markdown-writer.js
+++ b/lib/writers/markdown-writer.js
@@ -73,12 +73,6 @@ 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 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(),
@@ -90,6 +84,16 @@ var htmlmarkdown = {
"img": new markdownImage(),
};
+(function() {
+ for (var i = 1; i <= 6; i++) {
+ htmlmarkdown["h" + i] = new markdownElement(repeatString("#", i) + " ", "\n\n\n");
+ }
+})();
+
+function repeatString(value, count) {
+ return new Array(count + 1).join(value);
+}
+
function markdownWriter() {
var fragments = [];
var listStack = [];