burp_cms 1.3.10 → 1.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b712f7801fbe64d570dbb1ea9dbb6f68c4e3341
4
- data.tar.gz: 76ecfcde61237cc7fd45740286c4a499040d1375
3
+ metadata.gz: 9b3ab2d42e551dca2a7c0ead3172deaba087cbd6
4
+ data.tar.gz: de9980ef7deae09191f1d14b44beda4ee3d5c13c
5
5
  SHA512:
6
- metadata.gz: 58b7b567477a9cffb4b357bdb789417387d21b518bcf6a592c4677621889fda2d69d9bfa964d3e30a909a36c52a50ca79952d02d629532a5e2799e53b52a1210
7
- data.tar.gz: 80341204cdb82686ef1c14c41b81d82982876aa9d3f9ad61ac584fcbe5faa651415cdd5d2d210b93e3487bc7090b2ea9425355d96a5e4fe0850131498443a563
6
+ metadata.gz: 8a125fff2696316d6b982fc57e9d5fd1f373f7f935d7f09992ef421daa9e13a4acdd49544671c8707dd096aaa8dfb810480b42512bc35822fe9f709cf1f9bf81
7
+ data.tar.gz: eab2f3e91d59e36fe3a239dd2f08f2a0e97db5ebf399897eacacb860d53b8469d0aaacc3d104eb4e7734da9b1dfbc2f66bd1a9008c08b9ffdafea07b441c15a0
@@ -1,5 +1,5 @@
1
1
  /*global
2
- marked
2
+ marked markdown2Html
3
3
  */
4
4
  (function($) {
5
5
 
@@ -238,7 +238,8 @@
238
238
  },
239
239
 
240
240
  updateContent: function() {
241
- var html = marked(this.markdown).replace(/\s+/g,' ');
241
+ var html = window.markdown2Html(this.markdown).replace(/\s+/g,' ');
242
+
242
243
  if(this.lastHtml === html) {
243
244
  return;
244
245
  }
@@ -32,7 +32,7 @@ function Html2Markdown(value) {
32
32
  dom.append(value);
33
33
 
34
34
  dom.find("> hr").each(function() {
35
- $(this).replaceWith("---");
35
+ $(this).replaceWith(getBeforePadding(this,"\n\n") + "---" + getAfterPadding(this,"\n\n"));
36
36
  });
37
37
 
38
38
  dom.find("em > strong").each(function() {
@@ -59,7 +59,8 @@ function Html2Markdown(value) {
59
59
  $(this).find('li').each(function() {
60
60
  $(this).replaceWith("- "+$(this).html()+getAfterPadding(this,"\n"));
61
61
  });
62
- $(this).replaceWith(getBeforePadding(this,"\n\n")+$(this).html());
62
+
63
+ $(this).replaceWith(getBeforePadding(this,"\n\n") + $(this).html() + getAfterPadding(this,"\n\n"));
63
64
  });
64
65
 
65
66
  dom.find("ol").each(function() {
@@ -92,12 +93,7 @@ function Html2Markdown(value) {
92
93
  $(this).replaceWith("_"+$(this).html()+"_");
93
94
  });
94
95
 
95
- var newLine = "\n\n";
96
- if($(this).next().length === 0) {
97
- newLine = "";
98
- }
99
-
100
- $(this).replaceWith(getBeforePadding(this,"\n\n")+hashes+" "+$.trim($(this).html()) + newLine);
96
+ $(this).replaceWith(getBeforePadding(this,"\n\n")+hashes+" "+$.trim($(this).html()) + getAfterPadding(this,"\n\n"));
101
97
  }
102
98
  });
103
99
  });
@@ -0,0 +1,54 @@
1
+ /*global
2
+ marked
3
+ */
4
+
5
+ (function() {
6
+
7
+ function includeForMarkdown(element) {
8
+ // Include text
9
+ if(element.nodeType === 3) {
10
+ return true;
11
+ } else if(element.nodeType === 1 && element.tagName.match(/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i)) {
12
+ return true;
13
+ } else {
14
+ return false;
15
+ }
16
+ }
17
+
18
+ function mergeTextAndInlineNodes(nodes) {
19
+ var newArray = [];
20
+ $(nodes).each(function(index, element) {
21
+ var last = newArray.length-1;
22
+ if(includeForMarkdown(element)) {
23
+ var data = $("<div></div>").append(element).html();
24
+
25
+ if(typeof(newArray[last]) === 'string') {
26
+ newArray[last] = newArray[last] + data;
27
+ } else {
28
+ newArray.push(data);
29
+ }
30
+ } else {
31
+ newArray.push(element);
32
+ }
33
+ });
34
+ return newArray;
35
+ }
36
+
37
+ function toHtml(markdown) {
38
+
39
+ var elements = [];
40
+
41
+ $.each(mergeTextAndInlineNodes($("<div></div>").append(markdown).contents()), function(index, value) {
42
+ if(typeof(value) === "string") {
43
+ elements.push(marked(value));
44
+ } else {
45
+ elements.push(value);
46
+ }
47
+ });
48
+
49
+ return $("<div></div>").append(elements).html();
50
+ }
51
+
52
+ window.markdown2Html = toHtml;
53
+
54
+ }());