markdown_views 0.4.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cf1dc33fd63dcb76e12249d77dd4759bd68060bf
4
- data.tar.gz: 363c136ece7c0080001fb4f590bb01e70675064f
2
+ SHA256:
3
+ metadata.gz: f81c4a73e77188401ab48d61d0c2d74b046d47bac8564a0d614415c79b549a01
4
+ data.tar.gz: 1c65711a9128b8be0011b5ab9a63a3f0f800397414b54fbd1290e085f8b7ec37
5
5
  SHA512:
6
- metadata.gz: 6da7e5a2607fa43d2c177a78988f7cf811bc9a41b6494b9db4689676d19a5932d50a4b916a72ac4156514729c99b9d141f70a63f04a62c00d4e566a393595dab
7
- data.tar.gz: 34a616a2c482cdabfcce8e0a9b7123ad4770111ef48056d205609214c1d45c5bd2f2d5ee9dcbe714da51af64a140134a29d08e64063b318296569d4947c0c2f7
6
+ metadata.gz: 61d705a6332849bc8a9d54c392cb1f5075b0ce3f08af7870a878d5c5d9c3cf87964fbc9ea263c0f08a4f3310c22b382b5289c0bd062eaaca5bf3acfc9282f6a5
7
+ data.tar.gz: 1a22c8e30aae4fc4ff9e8c5795c70273f4bb054682ddc0e005289ed5a4680d028bf414a9b8444aee02d352a52339bb429413d964f1d3365772b1d28b6e30d47c
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2017 thomas morgan
1
+ Copyright (c) 2014-2018 thomas morgan
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,13 +1,39 @@
1
1
  # MarkdownViews
2
2
 
3
- Make Rails 4+ handle .md templates, with optional preprocessing of ERB, HAML, etc. Easily configurable; uses RedCarpet. Also performs syntax highlighting via CodeRay.
3
+ MarkdownViews enables Rails 5+ to process .md templates as part of `app/views/`, with optional preprocessing of ERB, HAML, etc. A `markdown()` helper is also provided for when you need Markdown for only part of a view.
4
4
 
5
- ## Usage
5
+ It uses CommonMarker for markdown processing and Rouge for syntax highlighting.
6
6
 
7
- Just create views as `some_action.html.md` instead of `some_action.html.erb`.
8
7
 
8
+ ## Usage: Views
9
9
 
10
- By default also strips all HTML comments from the output. This can cause issues with inline Javascript or otherwise be undesired. To disable, add the following to an initializer:
10
+ Just create views as `some_action.html.md` instead of `some_action.html.erb` and write them with Markdown instead of HTML. You can still use ERB (or HAML, etc -- see below).
11
+
12
+ # My page title
13
+
14
+ Hello, **<%= current_user.first_name %>**.
15
+
16
+ ```ruby
17
+ def syntax_highlighting
18
+ 'works too!'
19
+ end
20
+ ```
21
+
22
+
23
+ ## Usage: Helper
24
+
25
+ MarkdownViews also includes a simple Markdown rendering helper.
26
+
27
+ <%= markdown('## Some markdown text') %>
28
+
29
+ <%= markdown do %>
30
+ ## Some markdown text
31
+ <% end %>
32
+
33
+
34
+ ## Configuration
35
+
36
+ By default, all HTML comments are stripped from the output. Occasionally this can cause issues with inline Javascript or otherwise be undesired. To disable, add the following to an initializer:
11
37
 
12
38
  MarkdownViews.strip_comments = false
13
39
 
@@ -16,30 +42,31 @@ By default, all .md files are preprocessed with ERB (making them effectively .md
16
42
  MarkdownViews.preprocessor = :erb
17
43
  MarkdownViews.preprocessor = nil
18
44
 
19
- RedCarpet's rendering can be configured. Both rendering options and markdown options can be set. See RedCarpet's documentation for available options.
45
+ CommonMarker's rendering can also be configured. See CommonMarker's documentation for available options.
20
46
 
21
- MarkdownViews.markdown_opts.merge! fenced_code_blocks: false
47
+ MarkdownViews.parsing_opts -= %i(UNSAFE)
22
48
 
23
- MarkdownViews.rendering_opts.merge! link_attributes: {'data-popup'=> true}
49
+ MarkdownViews.rendering_opts -= %i(UNSAFE TABLE_PREFER_STYLE_ATTRIBUTES)
24
50
 
25
- Likewise, CodeRay can be configured too:
51
+ MarkdownViews.extensions -= %i(autolink)
26
52
 
27
- MarkdownViews.coderay_opts.merge! line_numbers: true
53
+ Likewise, Rouge can be configured:
28
54
 
29
- The default CSS from CodeRay is made available via the asset pipeline. To use it, add this to your `application.css`:
55
+ # Use inline formatting:
56
+ MarkdownViews.rouge_opts.merge! formatter: Rouge::Formatters::HTMLInline.new('pastie')
30
57
 
31
- *= require coderay
58
+ # Enable line numbers:
59
+ MarkdownViews.rouge_opts.merge!(
60
+ formatter: Rouge::Formatters::HTMLTable.new(Rouge::Formatters::HTML.new, code_class: 'rouge-highlight'),
61
+ wrap: false
62
+ )
32
63
 
64
+ The standard CSS themes from Rouge are available via the asset pipeline. To use one, add it to your `application.css`:
33
65
 
34
- ### Helper
66
+ *= require rouge.monokai
35
67
 
36
- MarkdownViews also includes a simple Markdown rendering helper. It uses the app-wide config already defined (see above).
68
+ See `app/assets/stylesheets/` for the complete list.
37
69
 
38
- <%= markdown('## Some markdown text') %>
39
-
40
- <%= markdown do %>
41
- ## Some markdown text
42
- <% end %>
43
70
 
44
71
  ## Installation
45
72
 
@@ -51,6 +78,20 @@ And then execute:
51
78
 
52
79
  $ bundle
53
80
 
81
+
82
+ ## Gem versions
83
+
84
+ The 0.x series used RedCarpet and CodeRay.
85
+ (There was no 1.x series.)
86
+ The 2.x series uses CommonMarker and Rouge.
87
+
88
+ #### Upgrading from 0.x to 2.x
89
+
90
+ The configuration options have changed. The defaults are roughly the same as before. However, if you had customized them previously, then it will need to be revisited.
91
+
92
+ Similarly, the provided stylesheets for syntax highlighting have been changed. If you were importing the 'coderay' stylesheet before, then a new stylesheet will need to be selected. Try 'rouge.colorful' or one of the others included in app/assets/stylesheets.
93
+
94
+
54
95
  ## Contributing
55
96
 
56
97
  1. Fork it ( http://github.com/<my-github-username>/markdown_views/fork )
data/Rakefile CHANGED
@@ -1,5 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
3
  task :generate_stylesheet do
4
- `coderay stylesheet > app/assets/stylesheets/coderay.css`
4
+ %w( base16.light base16.dark base16.solarized.light base16.solarized.dark
5
+ base16.monokai.light base16.monokai.dark colorful github
6
+ gruvbox.light gruvbox.dark igorpro molokai monokai monokai.sublime
7
+ pastie thankful_eyes tulip
8
+ ).each do |theme|
9
+ `rougify style #{theme} --scope .rouge-highlight > app/assets/stylesheets/rouge.#{theme}.css`
10
+ end
5
11
  end
@@ -0,0 +1,78 @@
1
+ .rouge-highlight table td { padding: 5px; }
2
+ .rouge-highlight table pre { margin: 0; }
3
+ .rouge-highlight, .rouge-highlight .w {
4
+ color: #d0d0d0;
5
+ background-color: #151515;
6
+ }
7
+ .rouge-highlight .err {
8
+ color: #151515;
9
+ background-color: #ac4142;
10
+ }
11
+ .rouge-highlight .c, .rouge-highlight .cd, .rouge-highlight .cm, .rouge-highlight .c1, .rouge-highlight .cs {
12
+ color: #505050;
13
+ }
14
+ .rouge-highlight .cp {
15
+ color: #f4bf75;
16
+ }
17
+ .rouge-highlight .nt {
18
+ color: #f4bf75;
19
+ }
20
+ .rouge-highlight .o, .rouge-highlight .ow {
21
+ color: #d0d0d0;
22
+ }
23
+ .rouge-highlight .p, .rouge-highlight .pi {
24
+ color: #d0d0d0;
25
+ }
26
+ .rouge-highlight .gi {
27
+ color: #90a959;
28
+ }
29
+ .rouge-highlight .gd {
30
+ color: #ac4142;
31
+ }
32
+ .rouge-highlight .gh {
33
+ color: #6a9fb5;
34
+ background-color: #151515;
35
+ font-weight: bold;
36
+ }
37
+ .rouge-highlight .k, .rouge-highlight .kn, .rouge-highlight .kp, .rouge-highlight .kr, .rouge-highlight .kv {
38
+ color: #aa759f;
39
+ }
40
+ .rouge-highlight .kc {
41
+ color: #d28445;
42
+ }
43
+ .rouge-highlight .kt {
44
+ color: #d28445;
45
+ }
46
+ .rouge-highlight .kd {
47
+ color: #d28445;
48
+ }
49
+ .rouge-highlight .s, .rouge-highlight .sb, .rouge-highlight .sc, .rouge-highlight .sd, .rouge-highlight .s2, .rouge-highlight .sh, .rouge-highlight .sx, .rouge-highlight .s1 {
50
+ color: #90a959;
51
+ }
52
+ .rouge-highlight .sr {
53
+ color: #75b5aa;
54
+ }
55
+ .rouge-highlight .si {
56
+ color: #8f5536;
57
+ }
58
+ .rouge-highlight .se {
59
+ color: #8f5536;
60
+ }
61
+ .rouge-highlight .nn {
62
+ color: #f4bf75;
63
+ }
64
+ .rouge-highlight .nc {
65
+ color: #f4bf75;
66
+ }
67
+ .rouge-highlight .no {
68
+ color: #f4bf75;
69
+ }
70
+ .rouge-highlight .na {
71
+ color: #6a9fb5;
72
+ }
73
+ .rouge-highlight .m, .rouge-highlight .mf, .rouge-highlight .mh, .rouge-highlight .mi, .rouge-highlight .il, .rouge-highlight .mo, .rouge-highlight .mb, .rouge-highlight .mx {
74
+ color: #90a959;
75
+ }
76
+ .rouge-highlight .ss {
77
+ color: #90a959;
78
+ }
@@ -0,0 +1,77 @@
1
+ .rouge-highlight table td { padding: 5px; }
2
+ .rouge-highlight table pre { margin: 0; }
3
+ .rouge-highlight, .rouge-highlight .w {
4
+ color: #303030;
5
+ }
6
+ .rouge-highlight .err {
7
+ color: #151515;
8
+ background-color: #ac4142;
9
+ }
10
+ .rouge-highlight .c, .rouge-highlight .cd, .rouge-highlight .cm, .rouge-highlight .c1, .rouge-highlight .cs {
11
+ color: #505050;
12
+ }
13
+ .rouge-highlight .cp {
14
+ color: #f4bf75;
15
+ }
16
+ .rouge-highlight .nt {
17
+ color: #f4bf75;
18
+ }
19
+ .rouge-highlight .o, .rouge-highlight .ow {
20
+ color: #d0d0d0;
21
+ }
22
+ .rouge-highlight .p, .rouge-highlight .pi {
23
+ color: #d0d0d0;
24
+ }
25
+ .rouge-highlight .gi {
26
+ color: #90a959;
27
+ }
28
+ .rouge-highlight .gd {
29
+ color: #ac4142;
30
+ }
31
+ .rouge-highlight .gh {
32
+ color: #6a9fb5;
33
+ background-color: #151515;
34
+ font-weight: bold;
35
+ }
36
+ .rouge-highlight .k, .rouge-highlight .kn, .rouge-highlight .kp, .rouge-highlight .kr, .rouge-highlight .kv {
37
+ color: #aa759f;
38
+ }
39
+ .rouge-highlight .kc {
40
+ color: #d28445;
41
+ }
42
+ .rouge-highlight .kt {
43
+ color: #d28445;
44
+ }
45
+ .rouge-highlight .kd {
46
+ color: #d28445;
47
+ }
48
+ .rouge-highlight .s, .rouge-highlight .sb, .rouge-highlight .sc, .rouge-highlight .sd, .rouge-highlight .s2, .rouge-highlight .sh, .rouge-highlight .sx, .rouge-highlight .s1 {
49
+ color: #90a959;
50
+ }
51
+ .rouge-highlight .sr {
52
+ color: #75b5aa;
53
+ }
54
+ .rouge-highlight .si {
55
+ color: #8f5536;
56
+ }
57
+ .rouge-highlight .se {
58
+ color: #8f5536;
59
+ }
60
+ .rouge-highlight .nn {
61
+ color: #f4bf75;
62
+ }
63
+ .rouge-highlight .nc {
64
+ color: #f4bf75;
65
+ }
66
+ .rouge-highlight .no {
67
+ color: #f4bf75;
68
+ }
69
+ .rouge-highlight .na {
70
+ color: #6a9fb5;
71
+ }
72
+ .rouge-highlight .m, .rouge-highlight .mf, .rouge-highlight .mh, .rouge-highlight .mi, .rouge-highlight .il, .rouge-highlight .mo, .rouge-highlight .mb, .rouge-highlight .mx {
73
+ color: #90a959;
74
+ }
75
+ .rouge-highlight .ss {
76
+ color: #90a959;
77
+ }
@@ -0,0 +1,78 @@
1
+ .rouge-highlight table td { padding: 5px; }
2
+ .rouge-highlight table pre { margin: 0; }
3
+ .rouge-highlight, .rouge-highlight .w {
4
+ color: #f8f8f2;
5
+ background-color: #272822;
6
+ }
7
+ .rouge-highlight .err {
8
+ color: #272822;
9
+ background-color: #f92672;
10
+ }
11
+ .rouge-highlight .c, .rouge-highlight .cd, .rouge-highlight .cm, .rouge-highlight .c1, .rouge-highlight .cs {
12
+ color: #75715e;
13
+ }
14
+ .rouge-highlight .cp {
15
+ color: #f4bf75;
16
+ }
17
+ .rouge-highlight .nt {
18
+ color: #f4bf75;
19
+ }
20
+ .rouge-highlight .o, .rouge-highlight .ow {
21
+ color: #f8f8f2;
22
+ }
23
+ .rouge-highlight .p, .rouge-highlight .pi {
24
+ color: #f8f8f2;
25
+ }
26
+ .rouge-highlight .gi {
27
+ color: #a6e22e;
28
+ }
29
+ .rouge-highlight .gd {
30
+ color: #f92672;
31
+ }
32
+ .rouge-highlight .gh {
33
+ color: #66d9ef;
34
+ background-color: #272822;
35
+ font-weight: bold;
36
+ }
37
+ .rouge-highlight .k, .rouge-highlight .kn, .rouge-highlight .kp, .rouge-highlight .kr, .rouge-highlight .kv {
38
+ color: #ae81ff;
39
+ }
40
+ .rouge-highlight .kc {
41
+ color: #fd971f;
42
+ }
43
+ .rouge-highlight .kt {
44
+ color: #fd971f;
45
+ }
46
+ .rouge-highlight .kd {
47
+ color: #fd971f;
48
+ }
49
+ .rouge-highlight .s, .rouge-highlight .sb, .rouge-highlight .sc, .rouge-highlight .sd, .rouge-highlight .s2, .rouge-highlight .sh, .rouge-highlight .sx, .rouge-highlight .s1 {
50
+ color: #a6e22e;
51
+ }
52
+ .rouge-highlight .sr {
53
+ color: #a1efe4;
54
+ }
55
+ .rouge-highlight .si {
56
+ color: #cc6633;
57
+ }
58
+ .rouge-highlight .se {
59
+ color: #cc6633;
60
+ }
61
+ .rouge-highlight .nn {
62
+ color: #f4bf75;
63
+ }
64
+ .rouge-highlight .nc {
65
+ color: #f4bf75;
66
+ }
67
+ .rouge-highlight .no {
68
+ color: #f4bf75;
69
+ }
70
+ .rouge-highlight .na {
71
+ color: #66d9ef;
72
+ }
73
+ .rouge-highlight .m, .rouge-highlight .mf, .rouge-highlight .mh, .rouge-highlight .mi, .rouge-highlight .il, .rouge-highlight .mo, .rouge-highlight .mb, .rouge-highlight .mx {
74
+ color: #a6e22e;
75
+ }
76
+ .rouge-highlight .ss {
77
+ color: #a6e22e;
78
+ }
@@ -0,0 +1,77 @@
1
+ .rouge-highlight table td { padding: 5px; }
2
+ .rouge-highlight table pre { margin: 0; }
3
+ .rouge-highlight, .rouge-highlight .w {
4
+ color: #49483e;
5
+ }
6
+ .rouge-highlight .err {
7
+ color: #272822;
8
+ background-color: #f92672;
9
+ }
10
+ .rouge-highlight .c, .rouge-highlight .cd, .rouge-highlight .cm, .rouge-highlight .c1, .rouge-highlight .cs {
11
+ color: #75715e;
12
+ }
13
+ .rouge-highlight .cp {
14
+ color: #f4bf75;
15
+ }
16
+ .rouge-highlight .nt {
17
+ color: #f4bf75;
18
+ }
19
+ .rouge-highlight .o, .rouge-highlight .ow {
20
+ color: #f8f8f2;
21
+ }
22
+ .rouge-highlight .p, .rouge-highlight .pi {
23
+ color: #f8f8f2;
24
+ }
25
+ .rouge-highlight .gi {
26
+ color: #a6e22e;
27
+ }
28
+ .rouge-highlight .gd {
29
+ color: #f92672;
30
+ }
31
+ .rouge-highlight .gh {
32
+ color: #66d9ef;
33
+ background-color: #272822;
34
+ font-weight: bold;
35
+ }
36
+ .rouge-highlight .k, .rouge-highlight .kn, .rouge-highlight .kp, .rouge-highlight .kr, .rouge-highlight .kv {
37
+ color: #ae81ff;
38
+ }
39
+ .rouge-highlight .kc {
40
+ color: #fd971f;
41
+ }
42
+ .rouge-highlight .kt {
43
+ color: #fd971f;
44
+ }
45
+ .rouge-highlight .kd {
46
+ color: #fd971f;
47
+ }
48
+ .rouge-highlight .s, .rouge-highlight .sb, .rouge-highlight .sc, .rouge-highlight .sd, .rouge-highlight .s2, .rouge-highlight .sh, .rouge-highlight .sx, .rouge-highlight .s1 {
49
+ color: #a6e22e;
50
+ }
51
+ .rouge-highlight .sr {
52
+ color: #a1efe4;
53
+ }
54
+ .rouge-highlight .si {
55
+ color: #cc6633;
56
+ }
57
+ .rouge-highlight .se {
58
+ color: #cc6633;
59
+ }
60
+ .rouge-highlight .nn {
61
+ color: #f4bf75;
62
+ }
63
+ .rouge-highlight .nc {
64
+ color: #f4bf75;
65
+ }
66
+ .rouge-highlight .no {
67
+ color: #f4bf75;
68
+ }
69
+ .rouge-highlight .na {
70
+ color: #66d9ef;
71
+ }
72
+ .rouge-highlight .m, .rouge-highlight .mf, .rouge-highlight .mh, .rouge-highlight .mi, .rouge-highlight .il, .rouge-highlight .mo, .rouge-highlight .mb, .rouge-highlight .mx {
73
+ color: #a6e22e;
74
+ }
75
+ .rouge-highlight .ss {
76
+ color: #a6e22e;
77
+ }