emd 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -27
- data/lib/emd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dff540501ce48aa3c7dd04006ea8b2c441c54fb097201851a80d64bee65c566c
|
4
|
+
data.tar.gz: 6587540baf347167d95365b0b67d066b5c1043af3c53b17740456b3713868558
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b5dc54ba17f79500cab2a400c1692b01cc29625350760aa2a97586235da020b9db379204234a956301cee4e71ada93b048885d5e5fb28a8799a6824f8298eb
|
7
|
+
data.tar.gz: cc25fe24687e07c5cf823db1512705681102512ab43fc68a3c0a792a770722c3113652621c41ffc62411a7ee21260e6d60184ff113788d95613c9ff8ffbb016e
|
data/README.md
CHANGED
@@ -1,34 +1,27 @@
|
|
1
1
|
# Embedded Markdown [![Gem Version](https://badge.fury.io/rb/emd.svg)](https://badge.fury.io/rb/emd)
|
2
2
|
|
3
|
-
Embedded Markdown
|
4
|
-
|
5
|
-
The motivation is to reuse Markdown file in several of my Rails projects.
|
6
|
-
|
7
|
-
- 😊 Reuse Markdown in Rails products
|
8
|
-
- 📝 Allow copywriters & marketers to be involved in building your content easily
|
9
|
-
- 📝 Allows you to focus on the content instead of the webpage structure.
|
10
|
-
- 🙌 Supports syntax highlighting via Coderay
|
3
|
+
Embedded Markdown supports Markdown in Rails views and syntax highlighting at your Markdown code block.
|
11
4
|
|
12
5
|
## Installation
|
13
6
|
|
14
|
-
Add
|
7
|
+
Add these lines to your application's Gemfile:
|
15
8
|
|
16
9
|
```ruby
|
17
10
|
gem 'coderay' #optional for Syntax Highlighting
|
18
11
|
gem 'redcarpet'
|
19
12
|
gem 'emd'
|
20
13
|
```
|
21
|
-
> emd depends on Redcarpet for Markdown rendering
|
22
14
|
|
23
15
|
And then execute:
|
24
16
|
|
25
|
-
|
26
|
-
|
17
|
+
```
|
18
|
+
bundle
|
19
|
+
```
|
27
20
|
## Usage
|
28
21
|
|
29
|
-
###
|
22
|
+
### Use it in a Markdown view `markdown.html.md`
|
30
23
|
|
31
|
-
1. Create a view
|
24
|
+
1. Create a `markdown.html.md` view at `app/view/home/markdown.html.md` and add the following Markdown code:
|
32
25
|
|
33
26
|
```markdown
|
34
27
|
## This is a sample Markdown code
|
@@ -38,16 +31,16 @@ And then execute:
|
|
38
31
|
|
39
32
|
1. Generate a home controller using the following command `rails generate controller home`
|
40
33
|
|
41
|
-
1.
|
34
|
+
1. Add the following line to `route.rb`:
|
42
35
|
```
|
43
36
|
get '/markdown', to: 'home#markdown'
|
44
37
|
```
|
45
|
-
1.
|
38
|
+
1. And finally, visit the Markdown view at [http://localhost:3000/markdown](http://localhost:3000/markdown)
|
46
39
|
|
47
40
|
|
48
|
-
###
|
41
|
+
### Use it in a Markdown partial `_component.html.md`
|
49
42
|
|
50
|
-
1. Create a partial app/view/home
|
43
|
+
1. Create a `_component.html.md` partial at `app/view/home/_component.html.md`:
|
51
44
|
|
52
45
|
```markdown
|
53
46
|
### This is a component
|
@@ -57,7 +50,14 @@ And then execute:
|
|
57
50
|
- [This is a link to google] (http://google.com)
|
58
51
|
```
|
59
52
|
|
60
|
-
1.
|
53
|
+
1. Use this partial using `<%= render "component" %>` within any view like at `home/index.html.erb`
|
54
|
+
|
55
|
+
1. Add the following line to `route.rb`:
|
56
|
+
```
|
57
|
+
get '/home', to: 'home#index'
|
58
|
+
```
|
59
|
+
1. And finally, visit the Rails view with Markdown partial at [http://localhost:3000/home](http://localhost:3000/home)
|
60
|
+
|
61
61
|
|
62
62
|
### Syntax Highlighting
|
63
63
|
|
@@ -72,13 +72,15 @@ This will turn all the code block into:
|
|
72
72
|
|
73
73
|
```ruby
|
74
74
|
```ruby
|
75
|
-
|
75
|
+
class Something
|
76
|
+
end
|
76
77
|
```
|
77
78
|
```
|
78
79
|
|
79
80
|
```ruby
|
80
|
-
|
81
|
-
|
81
|
+
class Something
|
82
|
+
end
|
83
|
+
```
|
82
84
|
|
83
85
|
### Control which extensions Redcarpet uses
|
84
86
|
|
@@ -88,16 +90,17 @@ puts "something"
|
|
88
90
|
module MarkdownTemplateHandler
|
89
91
|
def self.call(template)
|
90
92
|
compiled_source = erb.call(template)
|
91
|
-
|
92
|
-
no_intra_emphasis:
|
93
|
-
fenced_code_blocks:
|
93
|
+
%(Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
94
|
+
no_intra_emphasis: true,
|
95
|
+
fenced_code_blocks: true,
|
94
96
|
# I actually like that, so commented it out:
|
95
97
|
# disable_indented_code_blocks: true,
|
96
|
-
space_after_headers:
|
98
|
+
space_after_headers: true,
|
97
99
|
prettify: true,
|
98
100
|
tables: true,
|
99
101
|
with_toc_data: true,
|
100
|
-
autolink:
|
102
|
+
autolink: true
|
103
|
+
).render(begin;#{compiled_source};end).html_safe)
|
101
104
|
end
|
102
105
|
end
|
103
106
|
```
|
@@ -120,3 +123,28 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
120
123
|
|
121
124
|
Special thanks to [these folks](http://stackoverflow.com/questions/4163560/how-can-i-automatically-render-partials-using-markdown-in-rails-3/10131299#10131299
|
122
125
|
) for making emd possible
|
126
|
+
|
127
|
+
|
128
|
+
## TODO
|
129
|
+
|
130
|
+
- [x] Syntax highlighting
|
131
|
+
- [ ] Tests
|
132
|
+
- [ ] Scaffolders
|
133
|
+
- [ ] Example repo
|
134
|
+
- [ ] Add a copy button to the code block
|
135
|
+
|
136
|
+
|
137
|
+
## Benefits
|
138
|
+
|
139
|
+
EMD uses a Rails engine and a simple initializer to initiate a markdown template handler with the help of Redcarpet and syntax highlighting from Coderay.
|
140
|
+
|
141
|
+
The motivation is to reuse Markdown file in several of my Rails projects.
|
142
|
+
|
143
|
+
- 😊 Reuse Markdown in Rails products
|
144
|
+
- 📝 Allow copywriters & marketers to be involved in building your content easily
|
145
|
+
- 📝 Allows you to focus on the content instead of the webpage structure.
|
146
|
+
- 🙌 Supports syntax highlighting via Coderay
|
147
|
+
|
148
|
+
|
149
|
+
## Other implementations
|
150
|
+
- [Markdown Rails](https://github.com/joliss/markdown-rails)
|
data/lib/emd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Lim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|