mark-don 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +51 -5
- data/lib/mark_don/converter.rb +2 -2
- data/lib/mark_don/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf139b5e4ea3c7211ff53c6d454c0aa3d5a386a2cf876c79ca13cb5ebd99b700
|
|
4
|
+
data.tar.gz: f733c8d9cac4eefa0307033848725cd9ea7b330f9cc7d0adb7db5c9b7a933b23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3aa615596f90f5b458ecac385fff944ec4f710a9f573a6d6e812470388e95210602a02fe9fe797e7a91f9d866c5e0d5ecf6fd40eeeaec164615f3f71fcbd5e2a
|
|
7
|
+
data.tar.gz: 701708e0e7714be6bf7b6051e0d516464c35c23d4d94fec5f00356e6fbbb257d8c466f2f447a95d42939885c8a25a8ad4c84043ce15ea221e93e33602c5bdb27
|
data/README.md
CHANGED
|
@@ -64,7 +64,7 @@ end
|
|
|
64
64
|
|
|
65
65
|
## Output
|
|
66
66
|
|
|
67
|
-
The gem converts the
|
|
67
|
+
The gem converts the HTML to GitHub Flavored Markdown using [reverse_markdown](https://github.com/xijo/reverse_markdown) under the hood. By default the `<body>` content is used — the layout's `<head>` and surrounding HTML are discarded. `<script>`, `<style>`, `<meta>`, and `<link>` tags are stripped. Inline styles and unknown elements are dropped; their text content is preserved.
|
|
68
68
|
|
|
69
69
|
**Input:**
|
|
70
70
|
```html
|
|
@@ -86,21 +86,67 @@ This is a **great** room with a [nice view](/view).
|
|
|
86
86
|
- Breakfast at 8am
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
###
|
|
89
|
+
### Controlling what gets converted
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
Two HTML attributes let you control the conversion scope. They can be used independently or combined.
|
|
92
|
+
|
|
93
|
+
**`data-markdown-main`** — scopes conversion to a single element. Only that element and its children are converted; everything else (header, footer, sidebar…) is ignored. Works on any tag, not just `<main>`.
|
|
94
|
+
|
|
95
|
+
**`data-markdown-ignore`** — excludes an element and its children from the output, wherever they appear.
|
|
96
|
+
|
|
97
|
+
#### No attributes (default)
|
|
98
|
+
|
|
99
|
+
The entire `<body>` is converted:
|
|
100
|
+
|
|
101
|
+
```erb
|
|
102
|
+
<header>Always included</header>
|
|
103
|
+
<main><h1>Content</h1></main>
|
|
104
|
+
<footer>Also included</footer>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### `data-markdown-main` only
|
|
108
|
+
|
|
109
|
+
Restricts conversion to one element:
|
|
110
|
+
|
|
111
|
+
```erb
|
|
112
|
+
<header>Ignored</header>
|
|
113
|
+
|
|
114
|
+
<main data-markdown-main>
|
|
115
|
+
<h1>My Room</h1>
|
|
116
|
+
<p>Only this will appear in the Markdown response.</p>
|
|
117
|
+
</main>
|
|
118
|
+
|
|
119
|
+
<footer>Ignored</footer>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### `data-markdown-ignore` only
|
|
123
|
+
|
|
124
|
+
Converts the full body but removes specific blocks:
|
|
92
125
|
|
|
93
126
|
```erb
|
|
94
127
|
<nav data-markdown-ignore>
|
|
95
128
|
<%= link_to "Login", login_path %>
|
|
96
|
-
<%= link_to "Sign up", signup_path %>
|
|
97
129
|
</nav>
|
|
98
130
|
|
|
99
131
|
<h1>My Room</h1>
|
|
100
132
|
<p>Visible content.</p>
|
|
101
133
|
```
|
|
102
134
|
|
|
103
|
-
|
|
135
|
+
#### Both combined
|
|
136
|
+
|
|
137
|
+
Scopes to a root element and removes specific children within it:
|
|
138
|
+
|
|
139
|
+
```erb
|
|
140
|
+
<header>Ignored</header>
|
|
141
|
+
|
|
142
|
+
<main data-markdown-main>
|
|
143
|
+
<h1>My Room</h1>
|
|
144
|
+
<aside data-markdown-ignore>Related links</aside>
|
|
145
|
+
<p>This appears, the aside does not.</p>
|
|
146
|
+
</main>
|
|
147
|
+
|
|
148
|
+
<footer>Ignored</footer>
|
|
149
|
+
```
|
|
104
150
|
|
|
105
151
|
## Discoverability tip
|
|
106
152
|
|
data/lib/mark_don/converter.rb
CHANGED
|
@@ -10,8 +10,8 @@ module MarkDon
|
|
|
10
10
|
STRIP_TAGS.each { |tag| doc.css(tag).remove }
|
|
11
11
|
doc.css('[data-markdown-ignore]').remove
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
ReverseMarkdown.convert(
|
|
13
|
+
root = doc.at('[data-markdown-main]') || doc.at('body') || doc
|
|
14
|
+
ReverseMarkdown.convert(root.inner_html, unknown_tags: :bypass, github_flavored: true).strip
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
end
|
data/lib/mark_don/version.rb
CHANGED