burp_cms 1.3.12 → 1.3.13

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: 8d1011991b02c12d1fe3ea6b3c52c1b48f285776
4
- data.tar.gz: f7ca5b10fb752fe0e9e91d6a0d031fef35808712
3
+ metadata.gz: 730ca90334c6ad1ab3b78bbe3fe4ffb85c80f158
4
+ data.tar.gz: 974e91faf4a38b7a7b71a7e175f25b9502dfdfb9
5
5
  SHA512:
6
- metadata.gz: 8b745012106bfdcd0f3ea0e58e1dc6fff3cf99a9f798d6fcd5cfe505d4757dda72cbd50efcbf3e77ff3f33a82a3abcb2bc45b54274339a5088e261ffa99cdabe
7
- data.tar.gz: 6dd53e24bed82c17fc0bf7ed55dc44010863975eaa73029d18591b31f9108379376eabdd44111e74da9e38c091ccf6acb713eec30e5aaa07014be66bf600eab1
6
+ metadata.gz: 8c33ee90f26d1a6529500ea0e0f66939245ace6b1fa408f3f3b5d57af4941645d31eaf626bc4b614d3c944c2c763a725bec7725e21cb1bbca073632a6d278b97
7
+ data.tar.gz: 29f106d57a0904933f2342ed24f170d5779bd43123b2b11584c07fec30b86c8b767a1287db4911db784d9ccd84040cf1df6aea2bfbc63f80b1fe86eaa49dbf31
@@ -27,12 +27,30 @@ function getBeforePadding(element,padding) {
27
27
  return padding;
28
28
  }
29
29
 
30
+ function removeTralingWhiteSpace(element) {
31
+ if(element && element.nodeType === 3) {
32
+ element.data = element.data.replace(/\s+$/,'');
33
+ }
34
+ }
35
+
36
+ function removeStartingWhiteSpace(element) {
37
+ if(element && element.nodeType === 3) {
38
+ element.data = element.data.replace(/^\s+/,'');
39
+ }
40
+ }
41
+
42
+ function shouldSkip(element) {
43
+ return $(element).get(0).attributes.length > 0;
44
+ }
45
+
30
46
  function Html2Markdown(value) {
31
47
  var dom = $("<div id=\"root\"></div>");
32
48
  dom.append(value);
33
49
 
34
50
  dom.find("> hr").each(function() {
35
- $(this).replaceWith(getBeforePadding(this,"\n\n") + "---" + getAfterPadding(this,"\n\n"));
51
+ if(!shouldSkip(this)) {
52
+ $(this).replaceWith(getBeforePadding(this,"\n\n") + "---" + getAfterPadding(this,"\n\n"));
53
+ }
36
54
  });
37
55
 
38
56
  dom.find("em > strong").each(function() {
@@ -40,7 +58,9 @@ function Html2Markdown(value) {
40
58
  });
41
59
 
42
60
  dom.find("> p > em, > em, > ul > li > em").each(function() {
43
- $(this).replaceWith("_"+$(this).html()+"_");
61
+ if(!shouldSkip(this)) {
62
+ $(this).replaceWith("_"+$(this).html()+"_");
63
+ }
44
64
  });
45
65
 
46
66
 
@@ -56,22 +76,43 @@ function Html2Markdown(value) {
56
76
  });
57
77
 
58
78
  dom.find("ul").each(function() {
59
- $(this).find('li').each(function() {
60
- $(this).replaceWith("- "+$(this).html()+getAfterPadding(this,"\n"));
61
- });
79
+ if(!shouldSkip(this)) {
80
+ $(this).contents().each(function() {
81
+ if(this.nodeType === 3) {
82
+ $(this).remove();
83
+ }
84
+ });
85
+
86
+ $(this).find('li').each(function() {
87
+ removeTralingWhiteSpace($(this).get(0).previousSibling);
88
+ $(this).replaceWith(getBeforePadding(this,"\n") + "- "+$(this).html() + getAfterPadding(this,"\n"));
89
+ });
62
90
 
63
- $(this).replaceWith(getBeforePadding(this,"\n\n") + $(this).html() + getAfterPadding(this,"\n\n"));
91
+ $(this).replaceWith(getBeforePadding(this,"\n\n") + $(this).html() + getAfterPadding(this,"\n\n"));
92
+ }
64
93
  });
65
94
 
66
95
  dom.find("ol").each(function() {
67
- $(this).find('li').each(function(index,value) {
68
- $(this).replaceWith((index+1)+". "+$(this).html()+getAfterPadding(this,"\n"));
69
- });
70
- $(this).replaceWith(getBeforePadding(this,"\n\n")+$(this).html());
96
+ if(!shouldSkip(this)) {
97
+
98
+ $(this).contents().each(function() {
99
+ if(this.nodeType === 3) {
100
+ $(this).remove();
101
+ }
102
+ });
103
+
104
+ $(this).find('li').each(function(index,value) {
105
+ removeTralingWhiteSpace($(this).get(0).previousSibling);
106
+ $(this).replaceWith(getBeforePadding(this,"\n")+(index+1)+". "+$(this).html()+getAfterPadding(this,"\n"));
107
+ });
108
+ $(this).replaceWith(getBeforePadding(this,"\n\n")+$(this).html());
109
+ }
71
110
  });
72
111
 
73
112
  dom.find('blockquote').each(function() {
74
- $(this).replaceWith("> "+$.trim($(this).html()).replace(/\n{2,20}/g,"\n\n").replace(/\n/g,'\n> ').replace(/> \n/g,">\n"));
113
+ if(!shouldSkip(this)) {
114
+ $(this).replaceWith("> "+$.trim($(this).html()).replace(/\n{2,20}/g,"\n\n").replace(/\n/g,'\n> ').replace(/> \n/g,">\n"));
115
+ }
75
116
  });
76
117
 
77
118
  $.each(["h1",'h2','h3','h4','h5'],function(index,value) {
@@ -84,6 +125,11 @@ function Html2Markdown(value) {
84
125
 
85
126
  dom.find("> "+value).each(function() {
86
127
 
128
+ // Remove any auto ids
129
+ if($(this).attr("id") === $(this).html().toLowerCase().replace(/[^\w]+/g, '-')) {
130
+ $(this).removeAttr("id");
131
+ }
132
+
87
133
  if($(this).get(0).attributes.length === 0) {
88
134
  $(this).find("> strong").each(function() {
89
135
  $(this).replaceWith("**"+$(this).html()+"**");
data/lib/burp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Burp
2
- VERSION = "1.3.12"
2
+ VERSION = "1.3.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: burp_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.12
4
+ version: 1.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-19 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: burp_cms
@@ -374,6 +374,48 @@ dependencies:
374
374
  - - ~>
375
375
  - !ruby/object:Gem::Version
376
376
  version: 1.8.4
377
+ - !ruby/object:Gem::Dependency
378
+ name: rdoc
379
+ requirement: !ruby/object:Gem::Requirement
380
+ requirements:
381
+ - - ~>
382
+ - !ruby/object:Gem::Version
383
+ version: '3.12'
384
+ type: :development
385
+ prerelease: false
386
+ version_requirements: !ruby/object:Gem::Requirement
387
+ requirements:
388
+ - - ~>
389
+ - !ruby/object:Gem::Version
390
+ version: '3.12'
391
+ - !ruby/object:Gem::Dependency
392
+ name: bundler
393
+ requirement: !ruby/object:Gem::Requirement
394
+ requirements:
395
+ - - '>='
396
+ - !ruby/object:Gem::Version
397
+ version: '0'
398
+ type: :development
399
+ prerelease: false
400
+ version_requirements: !ruby/object:Gem::Requirement
401
+ requirements:
402
+ - - '>='
403
+ - !ruby/object:Gem::Version
404
+ version: '0'
405
+ - !ruby/object:Gem::Dependency
406
+ name: jeweler
407
+ requirement: !ruby/object:Gem::Requirement
408
+ requirements:
409
+ - - ~>
410
+ - !ruby/object:Gem::Version
411
+ version: 1.8.4
412
+ type: :development
413
+ prerelease: false
414
+ version_requirements: !ruby/object:Gem::Requirement
415
+ requirements:
416
+ - - ~>
417
+ - !ruby/object:Gem::Version
418
+ version: 1.8.4
377
419
  - !ruby/object:Gem::Dependency
378
420
  name: rspec
379
421
  requirement: !ruby/object:Gem::Requirement