marked-rails 0.2.10.1 → 0.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/README.md +0 -2
- data/lib/marked-rails/version.rb +2 -2
- data/marked-rails.gemspec +3 -2
- data/vendor/assets/javascripts/marked.js +245 -144
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDNkNDE3NjM4Zjg4ZGY0ODNjZDFkM2IzNTVjMmE5MmM2M2EwZTc2Yg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWU3MTkzMzlkMjJlOTFmOGRkN2ZiODFmMGE3NTgwMTc1NjNkYzA3Mg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MGViNTI1YTExN2JhODY0NTU2ZmY3OWU5MmU0ZDk1MThjOTQzODZhNjdlZTQy
|
10
|
+
ZmEwZGUzMDk0NGJlMTI0YTQxMmNiNjU0OWRmNzVmYmJiNDA5ZDA0NjFjMWY4
|
11
|
+
YzNlNTExMjI5YWI2ZmZiMjAyMWJmNTQ2M2NiMWFhNWM2MTE2ZGM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjU3OTMwZDBmODBlMTZjMzk3YmFkNTYyMmZiMzg2YmUwMjUyZDFiMzFmZjQ3
|
14
|
+
M2JhM2EzM2I0ZGM4YzdjZWNhNDlhYjY2ODBjYTI5OGY1NTFlZjFhM2Y2YmRk
|
15
|
+
ZjAzNzMzODE1NWNiYmE0NWNmOWJjNGFiZmQ4Y2Q2ODRlYTU2OGI=
|
data/README.md
CHANGED
data/lib/marked-rails/version.rb
CHANGED
data/marked-rails.gemspec
CHANGED
@@ -3,10 +3,11 @@ require File.expand_path('../lib/marked-rails/version', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["nodanaonlyzuul", "rosscooperman"]
|
6
|
-
gem.email = ["
|
6
|
+
gem.email = ["cooperman@gmail.com"]
|
7
7
|
gem.description = 'A gemified verison of the chjj/marked: "A full-featured markdown parser and compiler, written in javascript."'
|
8
8
|
gem.summary = 'A gemified verison of the chjj/marked'
|
9
|
-
gem.homepage = "https://github.com/
|
9
|
+
gem.homepage = "https://github.com/rosscooperman/marked-rails"
|
10
|
+
gem.licenses = ['MIT']
|
10
11
|
|
11
12
|
gem.files = `git ls-files`.split($\)
|
12
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* marked - a markdown parser
|
3
|
-
* Copyright (c) 2011-
|
3
|
+
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
4
4
|
* https://github.com/chjj/marked
|
5
5
|
*/
|
6
6
|
|
@@ -18,8 +18,8 @@ var block = {
|
|
18
18
|
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
19
19
|
nptable: noop,
|
20
20
|
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
21
|
-
blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/,
|
22
|
-
list: /^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
21
|
+
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
22
|
+
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
23
23
|
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
|
24
24
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
25
25
|
table: noop,
|
@@ -35,13 +35,18 @@ block.item = replace(block.item, 'gm')
|
|
35
35
|
|
36
36
|
block.list = replace(block.list)
|
37
37
|
(/bull/g, block.bullet)
|
38
|
-
('hr',
|
38
|
+
('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
|
39
|
+
('def', '\\n+(?=' + block.def.source + ')')
|
40
|
+
();
|
41
|
+
|
42
|
+
block.blockquote = replace(block.blockquote)
|
43
|
+
('def', block.def)
|
39
44
|
();
|
40
45
|
|
41
46
|
block._tag = '(?!(?:'
|
42
47
|
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
43
48
|
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
44
|
-
+ '|span|br|wbr|ins|del|img)\\b)\\w+(
|
49
|
+
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
|
45
50
|
|
46
51
|
block.html = replace(block.html)
|
47
52
|
('comment', /<!--[\s\S]*?-->/)
|
@@ -141,7 +146,7 @@ Lexer.prototype.lex = function(src) {
|
|
141
146
|
* Lexing
|
142
147
|
*/
|
143
148
|
|
144
|
-
Lexer.prototype.token = function(src, top) {
|
149
|
+
Lexer.prototype.token = function(src, top, bq) {
|
145
150
|
var src = src.replace(/^ +$/gm, '')
|
146
151
|
, next
|
147
152
|
, loose
|
@@ -264,7 +269,7 @@ Lexer.prototype.token = function(src, top) {
|
|
264
269
|
// Pass `top` to keep the current
|
265
270
|
// "toplevel" state. This is exactly
|
266
271
|
// how markdown.pl works.
|
267
|
-
this.token(cap, top);
|
272
|
+
this.token(cap, top, true);
|
268
273
|
|
269
274
|
this.tokens.push({
|
270
275
|
type: 'blockquote_end'
|
@@ -333,7 +338,7 @@ Lexer.prototype.token = function(src, top) {
|
|
333
338
|
});
|
334
339
|
|
335
340
|
// Recurse.
|
336
|
-
this.token(item, false);
|
341
|
+
this.token(item, false, bq);
|
337
342
|
|
338
343
|
this.tokens.push({
|
339
344
|
type: 'list_item_end'
|
@@ -361,7 +366,7 @@ Lexer.prototype.token = function(src, top) {
|
|
361
366
|
}
|
362
367
|
|
363
368
|
// def
|
364
|
-
if (top && (cap = this.rules.def.exec(src))) {
|
369
|
+
if ((!bq && top) && (cap = this.rules.def.exec(src))) {
|
365
370
|
src = src.substring(cap[0].length);
|
366
371
|
this.tokens.links[cap[1].toLowerCase()] = {
|
367
372
|
href: cap[2],
|
@@ -514,6 +519,8 @@ function InlineLexer(links, options) {
|
|
514
519
|
this.options = options || marked.defaults;
|
515
520
|
this.links = links;
|
516
521
|
this.rules = inline.normal;
|
522
|
+
this.renderer = this.options.renderer || new Renderer;
|
523
|
+
this.renderer.options = this.options;
|
517
524
|
|
518
525
|
if (!this.links) {
|
519
526
|
throw new
|
@@ -577,29 +584,26 @@ InlineLexer.prototype.output = function(src) {
|
|
577
584
|
text = escape(cap[1]);
|
578
585
|
href = text;
|
579
586
|
}
|
580
|
-
out +=
|
581
|
-
+ href
|
582
|
-
+ '">'
|
583
|
-
+ text
|
584
|
-
+ '</a>';
|
587
|
+
out += this.renderer.link(href, null, text);
|
585
588
|
continue;
|
586
589
|
}
|
587
590
|
|
588
591
|
// url (gfm)
|
589
|
-
if (cap = this.rules.url.exec(src)) {
|
592
|
+
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
590
593
|
src = src.substring(cap[0].length);
|
591
594
|
text = escape(cap[1]);
|
592
595
|
href = text;
|
593
|
-
out +=
|
594
|
-
+ href
|
595
|
-
+ '">'
|
596
|
-
+ text
|
597
|
-
+ '</a>';
|
596
|
+
out += this.renderer.link(href, null, text);
|
598
597
|
continue;
|
599
598
|
}
|
600
599
|
|
601
600
|
// tag
|
602
601
|
if (cap = this.rules.tag.exec(src)) {
|
602
|
+
if (!this.inLink && /^<a /i.test(cap[0])) {
|
603
|
+
this.inLink = true;
|
604
|
+
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
605
|
+
this.inLink = false;
|
606
|
+
}
|
603
607
|
src = src.substring(cap[0].length);
|
604
608
|
out += this.options.sanitize
|
605
609
|
? escape(cap[0])
|
@@ -610,10 +614,12 @@ InlineLexer.prototype.output = function(src) {
|
|
610
614
|
// link
|
611
615
|
if (cap = this.rules.link.exec(src)) {
|
612
616
|
src = src.substring(cap[0].length);
|
617
|
+
this.inLink = true;
|
613
618
|
out += this.outputLink(cap, {
|
614
619
|
href: cap[2],
|
615
620
|
title: cap[3]
|
616
621
|
});
|
622
|
+
this.inLink = false;
|
617
623
|
continue;
|
618
624
|
}
|
619
625
|
|
@@ -628,50 +634,44 @@ InlineLexer.prototype.output = function(src) {
|
|
628
634
|
src = cap[0].substring(1) + src;
|
629
635
|
continue;
|
630
636
|
}
|
637
|
+
this.inLink = true;
|
631
638
|
out += this.outputLink(cap, link);
|
639
|
+
this.inLink = false;
|
632
640
|
continue;
|
633
641
|
}
|
634
642
|
|
635
643
|
// strong
|
636
644
|
if (cap = this.rules.strong.exec(src)) {
|
637
645
|
src = src.substring(cap[0].length);
|
638
|
-
out +=
|
639
|
-
+ this.output(cap[2] || cap[1])
|
640
|
-
+ '</strong>';
|
646
|
+
out += this.renderer.strong(this.output(cap[2] || cap[1]));
|
641
647
|
continue;
|
642
648
|
}
|
643
649
|
|
644
650
|
// em
|
645
651
|
if (cap = this.rules.em.exec(src)) {
|
646
652
|
src = src.substring(cap[0].length);
|
647
|
-
out +=
|
648
|
-
+ this.output(cap[2] || cap[1])
|
649
|
-
+ '</em>';
|
653
|
+
out += this.renderer.em(this.output(cap[2] || cap[1]));
|
650
654
|
continue;
|
651
655
|
}
|
652
656
|
|
653
657
|
// code
|
654
658
|
if (cap = this.rules.code.exec(src)) {
|
655
659
|
src = src.substring(cap[0].length);
|
656
|
-
out +=
|
657
|
-
+ escape(cap[2], true)
|
658
|
-
+ '</code>';
|
660
|
+
out += this.renderer.codespan(escape(cap[2], true));
|
659
661
|
continue;
|
660
662
|
}
|
661
663
|
|
662
664
|
// br
|
663
665
|
if (cap = this.rules.br.exec(src)) {
|
664
666
|
src = src.substring(cap[0].length);
|
665
|
-
out +=
|
667
|
+
out += this.renderer.br();
|
666
668
|
continue;
|
667
669
|
}
|
668
670
|
|
669
671
|
// del (gfm)
|
670
672
|
if (cap = this.rules.del.exec(src)) {
|
671
673
|
src = src.substring(cap[0].length);
|
672
|
-
out +=
|
673
|
-
+ this.output(cap[1])
|
674
|
-
+ '</del>';
|
674
|
+
out += this.renderer.del(this.output(cap[1]));
|
675
675
|
continue;
|
676
676
|
}
|
677
677
|
|
@@ -696,31 +696,12 @@ InlineLexer.prototype.output = function(src) {
|
|
696
696
|
*/
|
697
697
|
|
698
698
|
InlineLexer.prototype.outputLink = function(cap, link) {
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
+ escape(link.title)
|
706
|
-
+ '"'
|
707
|
-
: '')
|
708
|
-
+ '>'
|
709
|
-
+ this.output(cap[1])
|
710
|
-
+ '</a>';
|
711
|
-
} else {
|
712
|
-
return '<img src="'
|
713
|
-
+ escape(link.href)
|
714
|
-
+ '" alt="'
|
715
|
-
+ escape(cap[1])
|
716
|
-
+ '"'
|
717
|
-
+ (link.title
|
718
|
-
? ' title="'
|
719
|
-
+ escape(link.title)
|
720
|
-
+ '"'
|
721
|
-
: '')
|
722
|
-
+ '>';
|
723
|
-
}
|
699
|
+
var href = escape(link.href)
|
700
|
+
, title = link.title ? escape(link.title) : null;
|
701
|
+
|
702
|
+
return cap[0].charAt(0) !== '!'
|
703
|
+
? this.renderer.link(href, title, this.output(cap[1]))
|
704
|
+
: this.renderer.image(href, title, escape(cap[1]));
|
724
705
|
};
|
725
706
|
|
726
707
|
/**
|
@@ -765,6 +746,149 @@ InlineLexer.prototype.mangle = function(text) {
|
|
765
746
|
return out;
|
766
747
|
};
|
767
748
|
|
749
|
+
/**
|
750
|
+
* Renderer
|
751
|
+
*/
|
752
|
+
|
753
|
+
function Renderer(options) {
|
754
|
+
this.options = options || {};
|
755
|
+
}
|
756
|
+
|
757
|
+
Renderer.prototype.code = function(code, lang, escaped) {
|
758
|
+
if (this.options.highlight) {
|
759
|
+
var out = this.options.highlight(code, lang);
|
760
|
+
if (out != null && out !== code) {
|
761
|
+
escaped = true;
|
762
|
+
code = out;
|
763
|
+
}
|
764
|
+
}
|
765
|
+
|
766
|
+
if (!lang) {
|
767
|
+
return '<pre><code>'
|
768
|
+
+ (escaped ? code : escape(code, true))
|
769
|
+
+ '\n</code></pre>';
|
770
|
+
}
|
771
|
+
|
772
|
+
return '<pre><code class="'
|
773
|
+
+ this.options.langPrefix
|
774
|
+
+ escape(lang, true)
|
775
|
+
+ '">'
|
776
|
+
+ (escaped ? code : escape(code, true))
|
777
|
+
+ '\n</code></pre>\n';
|
778
|
+
};
|
779
|
+
|
780
|
+
Renderer.prototype.blockquote = function(quote) {
|
781
|
+
return '<blockquote>\n' + quote + '</blockquote>\n';
|
782
|
+
};
|
783
|
+
|
784
|
+
Renderer.prototype.html = function(html) {
|
785
|
+
return html;
|
786
|
+
};
|
787
|
+
|
788
|
+
Renderer.prototype.heading = function(text, level, raw) {
|
789
|
+
return '<h'
|
790
|
+
+ level
|
791
|
+
+ ' id="'
|
792
|
+
+ this.options.headerPrefix
|
793
|
+
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
|
794
|
+
+ '">'
|
795
|
+
+ text
|
796
|
+
+ '</h'
|
797
|
+
+ level
|
798
|
+
+ '>\n';
|
799
|
+
};
|
800
|
+
|
801
|
+
Renderer.prototype.hr = function() {
|
802
|
+
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
803
|
+
};
|
804
|
+
|
805
|
+
Renderer.prototype.list = function(body, ordered) {
|
806
|
+
var type = ordered ? 'ol' : 'ul';
|
807
|
+
return '<' + type + '>\n' + body + '</' + type + '>\n';
|
808
|
+
};
|
809
|
+
|
810
|
+
Renderer.prototype.listitem = function(text) {
|
811
|
+
return '<li>' + text + '</li>\n';
|
812
|
+
};
|
813
|
+
|
814
|
+
Renderer.prototype.paragraph = function(text) {
|
815
|
+
return '<p>' + text + '</p>\n';
|
816
|
+
};
|
817
|
+
|
818
|
+
Renderer.prototype.table = function(header, body) {
|
819
|
+
return '<table>\n'
|
820
|
+
+ '<thead>\n'
|
821
|
+
+ header
|
822
|
+
+ '</thead>\n'
|
823
|
+
+ '<tbody>\n'
|
824
|
+
+ body
|
825
|
+
+ '</tbody>\n'
|
826
|
+
+ '</table>\n';
|
827
|
+
};
|
828
|
+
|
829
|
+
Renderer.prototype.tablerow = function(content) {
|
830
|
+
return '<tr>\n' + content + '</tr>\n';
|
831
|
+
};
|
832
|
+
|
833
|
+
Renderer.prototype.tablecell = function(content, flags) {
|
834
|
+
var type = flags.header ? 'th' : 'td';
|
835
|
+
var tag = flags.align
|
836
|
+
? '<' + type + ' style="text-align:' + flags.align + '">'
|
837
|
+
: '<' + type + '>';
|
838
|
+
return tag + content + '</' + type + '>\n';
|
839
|
+
};
|
840
|
+
|
841
|
+
// span level renderer
|
842
|
+
Renderer.prototype.strong = function(text) {
|
843
|
+
return '<strong>' + text + '</strong>';
|
844
|
+
};
|
845
|
+
|
846
|
+
Renderer.prototype.em = function(text) {
|
847
|
+
return '<em>' + text + '</em>';
|
848
|
+
};
|
849
|
+
|
850
|
+
Renderer.prototype.codespan = function(text) {
|
851
|
+
return '<code>' + text + '</code>';
|
852
|
+
};
|
853
|
+
|
854
|
+
Renderer.prototype.br = function() {
|
855
|
+
return this.options.xhtml ? '<br/>' : '<br>';
|
856
|
+
};
|
857
|
+
|
858
|
+
Renderer.prototype.del = function(text) {
|
859
|
+
return '<del>' + text + '</del>';
|
860
|
+
};
|
861
|
+
|
862
|
+
Renderer.prototype.link = function(href, title, text) {
|
863
|
+
if (this.options.sanitize) {
|
864
|
+
try {
|
865
|
+
var prot = decodeURIComponent(unescape(href))
|
866
|
+
.replace(/[^\w:]/g, '')
|
867
|
+
.toLowerCase();
|
868
|
+
} catch (e) {
|
869
|
+
return '';
|
870
|
+
}
|
871
|
+
if (prot.indexOf('javascript:') === 0) {
|
872
|
+
return '';
|
873
|
+
}
|
874
|
+
}
|
875
|
+
var out = '<a href="' + href + '"';
|
876
|
+
if (title) {
|
877
|
+
out += ' title="' + title + '"';
|
878
|
+
}
|
879
|
+
out += '>' + text + '</a>';
|
880
|
+
return out;
|
881
|
+
};
|
882
|
+
|
883
|
+
Renderer.prototype.image = function(href, title, text) {
|
884
|
+
var out = '<img src="' + href + '" alt="' + text + '"';
|
885
|
+
if (title) {
|
886
|
+
out += ' title="' + title + '"';
|
887
|
+
}
|
888
|
+
out += this.options.xhtml ? '/>' : '>';
|
889
|
+
return out;
|
890
|
+
};
|
891
|
+
|
768
892
|
/**
|
769
893
|
* Parsing & Compiling
|
770
894
|
*/
|
@@ -773,14 +897,17 @@ function Parser(options) {
|
|
773
897
|
this.tokens = [];
|
774
898
|
this.token = null;
|
775
899
|
this.options = options || marked.defaults;
|
900
|
+
this.options.renderer = this.options.renderer || new Renderer;
|
901
|
+
this.renderer = this.options.renderer;
|
902
|
+
this.renderer.options = this.options;
|
776
903
|
}
|
777
904
|
|
778
905
|
/**
|
779
906
|
* Static Parse Method
|
780
907
|
*/
|
781
908
|
|
782
|
-
Parser.parse = function(src, options) {
|
783
|
-
var parser = new Parser(options);
|
909
|
+
Parser.parse = function(src, options, renderer) {
|
910
|
+
var parser = new Parser(options, renderer);
|
784
911
|
return parser.parse(src);
|
785
912
|
};
|
786
913
|
|
@@ -789,7 +916,7 @@ Parser.parse = function(src, options) {
|
|
789
916
|
*/
|
790
917
|
|
791
918
|
Parser.prototype.parse = function(src) {
|
792
|
-
this.inline = new InlineLexer(src.links, this.options);
|
919
|
+
this.inline = new InlineLexer(src.links, this.options, this.renderer);
|
793
920
|
this.tokens = src.reverse();
|
794
921
|
|
795
922
|
var out = '';
|
@@ -840,83 +967,53 @@ Parser.prototype.tok = function() {
|
|
840
967
|
return '';
|
841
968
|
}
|
842
969
|
case 'hr': {
|
843
|
-
return
|
970
|
+
return this.renderer.hr();
|
844
971
|
}
|
845
972
|
case 'heading': {
|
846
|
-
return
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
+ '">'
|
851
|
-
+ this.inline.output(this.token.text)
|
852
|
-
+ '</h'
|
853
|
-
+ this.token.depth
|
854
|
-
+ '>\n';
|
973
|
+
return this.renderer.heading(
|
974
|
+
this.inline.output(this.token.text),
|
975
|
+
this.token.depth,
|
976
|
+
this.token.text);
|
855
977
|
}
|
856
978
|
case 'code': {
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
this.token.escaped = true;
|
861
|
-
this.token.text = code;
|
862
|
-
}
|
863
|
-
}
|
864
|
-
|
865
|
-
if (!this.token.escaped) {
|
866
|
-
this.token.text = escape(this.token.text, true);
|
867
|
-
}
|
868
|
-
|
869
|
-
return '<pre><code'
|
870
|
-
+ (this.token.lang
|
871
|
-
? ' class="'
|
872
|
-
+ this.options.langPrefix
|
873
|
-
+ this.token.lang
|
874
|
-
+ '"'
|
875
|
-
: '')
|
876
|
-
+ '>'
|
877
|
-
+ this.token.text
|
878
|
-
+ '</code></pre>\n';
|
979
|
+
return this.renderer.code(this.token.text,
|
980
|
+
this.token.lang,
|
981
|
+
this.token.escaped);
|
879
982
|
}
|
880
983
|
case 'table': {
|
881
|
-
var
|
882
|
-
,
|
984
|
+
var header = ''
|
985
|
+
, body = ''
|
883
986
|
, i
|
884
987
|
, row
|
885
988
|
, cell
|
989
|
+
, flags
|
886
990
|
, j;
|
887
991
|
|
888
992
|
// header
|
889
|
-
|
993
|
+
cell = '';
|
890
994
|
for (i = 0; i < this.token.header.length; i++) {
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
body += '>' + heading + '</th>\n';
|
995
|
+
flags = { header: true, align: this.token.align[i] };
|
996
|
+
cell += this.renderer.tablecell(
|
997
|
+
this.inline.output(this.token.header[i]),
|
998
|
+
{ header: true, align: this.token.align[i] }
|
999
|
+
);
|
897
1000
|
}
|
898
|
-
|
1001
|
+
header += this.renderer.tablerow(cell);
|
899
1002
|
|
900
|
-
// body
|
901
|
-
body += '<tbody>\n'
|
902
1003
|
for (i = 0; i < this.token.cells.length; i++) {
|
903
1004
|
row = this.token.cells[i];
|
904
|
-
|
1005
|
+
|
1006
|
+
cell = '';
|
905
1007
|
for (j = 0; j < row.length; j++) {
|
906
|
-
cell
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
}
|
911
|
-
body += '>' + cell + '</td>\n';
|
1008
|
+
cell += this.renderer.tablecell(
|
1009
|
+
this.inline.output(row[j]),
|
1010
|
+
{ header: false, align: this.token.align[j] }
|
1011
|
+
);
|
912
1012
|
}
|
913
|
-
body += '</tr>\n';
|
914
|
-
}
|
915
|
-
body += '</tbody>\n';
|
916
1013
|
|
917
|
-
|
918
|
-
|
919
|
-
|
1014
|
+
body += this.renderer.tablerow(cell);
|
1015
|
+
}
|
1016
|
+
return this.renderer.table(header, body);
|
920
1017
|
}
|
921
1018
|
case 'blockquote_start': {
|
922
1019
|
var body = '';
|
@@ -925,25 +1022,17 @@ Parser.prototype.tok = function() {
|
|
925
1022
|
body += this.tok();
|
926
1023
|
}
|
927
1024
|
|
928
|
-
return
|
929
|
-
+ body
|
930
|
-
+ '</blockquote>\n';
|
1025
|
+
return this.renderer.blockquote(body);
|
931
1026
|
}
|
932
1027
|
case 'list_start': {
|
933
|
-
var
|
934
|
-
,
|
1028
|
+
var body = ''
|
1029
|
+
, ordered = this.token.ordered;
|
935
1030
|
|
936
1031
|
while (this.next().type !== 'list_end') {
|
937
1032
|
body += this.tok();
|
938
1033
|
}
|
939
1034
|
|
940
|
-
return
|
941
|
-
+ type
|
942
|
-
+ '>\n'
|
943
|
-
+ body
|
944
|
-
+ '</'
|
945
|
-
+ type
|
946
|
-
+ '>\n';
|
1035
|
+
return this.renderer.list(body, ordered);
|
947
1036
|
}
|
948
1037
|
case 'list_item_start': {
|
949
1038
|
var body = '';
|
@@ -954,9 +1043,7 @@ Parser.prototype.tok = function() {
|
|
954
1043
|
: this.tok();
|
955
1044
|
}
|
956
1045
|
|
957
|
-
return
|
958
|
-
+ body
|
959
|
-
+ '</li>\n';
|
1046
|
+
return this.renderer.listitem(body);
|
960
1047
|
}
|
961
1048
|
case 'loose_item_start': {
|
962
1049
|
var body = '';
|
@@ -965,24 +1052,19 @@ Parser.prototype.tok = function() {
|
|
965
1052
|
body += this.tok();
|
966
1053
|
}
|
967
1054
|
|
968
|
-
return
|
969
|
-
+ body
|
970
|
-
+ '</li>\n';
|
1055
|
+
return this.renderer.listitem(body);
|
971
1056
|
}
|
972
1057
|
case 'html': {
|
973
|
-
|
1058
|
+
var html = !this.token.pre && !this.options.pedantic
|
974
1059
|
? this.inline.output(this.token.text)
|
975
1060
|
: this.token.text;
|
1061
|
+
return this.renderer.html(html);
|
976
1062
|
}
|
977
1063
|
case 'paragraph': {
|
978
|
-
return
|
979
|
-
+ this.inline.output(this.token.text)
|
980
|
-
+ '</p>\n';
|
1064
|
+
return this.renderer.paragraph(this.inline.output(this.token.text));
|
981
1065
|
}
|
982
1066
|
case 'text': {
|
983
|
-
return
|
984
|
-
+ this.parseText()
|
985
|
-
+ '</p>\n';
|
1067
|
+
return this.renderer.paragraph(this.parseText());
|
986
1068
|
}
|
987
1069
|
}
|
988
1070
|
};
|
@@ -1000,6 +1082,19 @@ function escape(html, encode) {
|
|
1000
1082
|
.replace(/'/g, ''');
|
1001
1083
|
}
|
1002
1084
|
|
1085
|
+
function unescape(html) {
|
1086
|
+
return html.replace(/&([#\w]+);/g, function(_, n) {
|
1087
|
+
n = n.toLowerCase();
|
1088
|
+
if (n === 'colon') return ':';
|
1089
|
+
if (n.charAt(0) === '#') {
|
1090
|
+
return n.charAt(1) === 'x'
|
1091
|
+
? String.fromCharCode(parseInt(n.substring(2), 16))
|
1092
|
+
: String.fromCharCode(+n.substring(1));
|
1093
|
+
}
|
1094
|
+
return '';
|
1095
|
+
});
|
1096
|
+
}
|
1097
|
+
|
1003
1098
|
function replace(regex, opt) {
|
1004
1099
|
regex = regex.source;
|
1005
1100
|
opt = opt || '';
|
@@ -1032,6 +1127,7 @@ function merge(obj) {
|
|
1032
1127
|
return obj;
|
1033
1128
|
}
|
1034
1129
|
|
1130
|
+
|
1035
1131
|
/**
|
1036
1132
|
* Marked
|
1037
1133
|
*/
|
@@ -1134,7 +1230,10 @@ marked.defaults = {
|
|
1134
1230
|
silent: false,
|
1135
1231
|
highlight: null,
|
1136
1232
|
langPrefix: 'lang-',
|
1137
|
-
smartypants: false
|
1233
|
+
smartypants: false,
|
1234
|
+
headerPrefix: '',
|
1235
|
+
renderer: new Renderer,
|
1236
|
+
xhtml: false
|
1138
1237
|
};
|
1139
1238
|
|
1140
1239
|
/**
|
@@ -1144,6 +1243,8 @@ marked.defaults = {
|
|
1144
1243
|
marked.Parser = Parser;
|
1145
1244
|
marked.parser = Parser.parse;
|
1146
1245
|
|
1246
|
+
marked.Renderer = Renderer;
|
1247
|
+
|
1147
1248
|
marked.Lexer = Lexer;
|
1148
1249
|
marked.lexer = Lexer.lex;
|
1149
1250
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marked-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodanaonlyzuul
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: 'A gemified verison of the chjj/marked: "A full-featured markdown parser
|
14
|
+
description: ! 'A gemified verison of the chjj/marked: "A full-featured markdown parser
|
15
15
|
and compiler, written in javascript."'
|
16
16
|
email:
|
17
|
-
-
|
17
|
+
- cooperman@gmail.com
|
18
18
|
executables: []
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
@@ -30,8 +30,9 @@ files:
|
|
30
30
|
- lib/marked-rails/version.rb
|
31
31
|
- marked-rails.gemspec
|
32
32
|
- vendor/assets/javascripts/marked.js
|
33
|
-
homepage: https://github.com/
|
34
|
-
licenses:
|
33
|
+
homepage: https://github.com/rosscooperman/marked-rails
|
34
|
+
licenses:
|
35
|
+
- MIT
|
35
36
|
metadata: {}
|
36
37
|
post_install_message:
|
37
38
|
rdoc_options: []
|
@@ -39,17 +40,17 @@ require_paths:
|
|
39
40
|
- lib
|
40
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
41
42
|
requirements:
|
42
|
-
- - '>='
|
43
|
+
- - ! '>='
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: '0'
|
45
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
47
|
requirements:
|
47
|
-
- - '>='
|
48
|
+
- - ! '>='
|
48
49
|
- !ruby/object:Gem::Version
|
49
50
|
version: '0'
|
50
51
|
requirements: []
|
51
52
|
rubyforge_project:
|
52
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.2.2
|
53
54
|
signing_key:
|
54
55
|
specification_version: 4
|
55
56
|
summary: A gemified verison of the chjj/marked
|