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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 070e0922e5b0ec67d9195720f3bcb38eab41699aefc8771f7651698e5bbf0eab
4
- data.tar.gz: 5f7b529087578ef596ae1426f511fb06bfdcb516528f32efc575df337b66de95
3
+ metadata.gz: bf139b5e4ea3c7211ff53c6d454c0aa3d5a386a2cf876c79ca13cb5ebd99b700
4
+ data.tar.gz: f733c8d9cac4eefa0307033848725cd9ea7b330f9cc7d0adb7db5c9b7a933b23
5
5
  SHA512:
6
- metadata.gz: bcb45d7e5d1e89b431f7c166362bdca07c82acd9301cd99eee24007888e38699ef1bdc1b16684d951a4a3bc1874a8a6cfdf91d7f7bfe7ba1d4c158f378b2200c
7
- data.tar.gz: dc6973083a893e4a5102cf57bc0345c899b980d7569911145df3d09f47e59e782d0714792fbc7f4856c88c2dcf5e9c09363d8cf65b51e1a637a091f69852a8fc
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 `<body>` content of the rendered HTML to GitHub Flavored Markdown using [reverse_markdown](https://github.com/xijo/reverse_markdown) under the hood. Only the body is converted — 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.
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
- ### Excluding elements
89
+ ### Controlling what gets converted
90
90
 
91
- Add `data-markdown-ignore` to any HTML element to exclude it and its children from the Markdown output:
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
- The `<nav>` block is removed before conversion — only the visible content remains in the Markdown response.
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
 
@@ -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
- body = doc.at('body') || doc
14
- ReverseMarkdown.convert(body.inner_html, unknown_tags: :bypass, github_flavored: true).strip
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
@@ -1,3 +1,3 @@
1
1
  module MarkDon
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mark-don
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Lahana