mark-don 0.1.1 → 0.1.2

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: 9a2daa5dd35b50296b320ead3addf73947a8208f7e1f5b745b745dfec33df9bc
4
- data.tar.gz: 7aabe59d4530c5553d15e82d28b23153ac71a6f3a7ecb2f46ab4b38c21b1bcee
3
+ metadata.gz: 070e0922e5b0ec67d9195720f3bcb38eab41699aefc8771f7651698e5bbf0eab
4
+ data.tar.gz: 5f7b529087578ef596ae1426f511fb06bfdcb516528f32efc575df337b66de95
5
5
  SHA512:
6
- metadata.gz: 7ff2e6344440ba47a2ce323c5ae7375d5d17901a221f9a85435cc2c89a98cc965e9ef1bf818353968de9239f8c7501c1ed3f0acc403ca08a5954764fe2e18bd3
7
- data.tar.gz: dea49fd0b020e2ca9d11b65f83685b5ebed062af9a7a1cfc45aa99b1f664ec913260aa3d3b00fb8b0d78e558416bb133e2a2929ed371245f2e787a73d42f1364
6
+ metadata.gz: bcb45d7e5d1e89b431f7c166362bdca07c82acd9301cd99eee24007888e38699ef1bdc1b16684d951a4a3bc1874a8a6cfdf91d7f7bfe7ba1d4c158f378b2200c
7
+ data.tar.gz: dc6973083a893e4a5102cf57bc0345c899b980d7569911145df3d09f47e59e782d0714792fbc7f4856c88c2dcf5e9c09363d8cf65b51e1a637a091f69852a8fc
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # mark-don
2
2
 
3
+ [![CI](https://github.com/paultursuru/mark-don/actions/workflows/ci.yml/badge.svg)](https://github.com/paultursuru/mark-don/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/mark-don.svg)](https://badge.fury.io/rb/mark-don)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
3
7
  Serve any Rails HTML view as Markdown : no templates to write.
4
8
 
5
9
  When a client requests `text/markdown` (via `Accept` header or `.md` extension), mark-don intercepts the normal HTML render, converts the output on the fly, and returns it with `Content-Type: text/markdown`. Your existing `.html.erb` views are reused as-is.
@@ -82,6 +86,42 @@ This is a **great** room with a [nice view](/view).
82
86
  - Breakfast at 8am
83
87
  ```
84
88
 
89
+ ### Excluding elements
90
+
91
+ Add `data-markdown-ignore` to any HTML element to exclude it and its children from the Markdown output:
92
+
93
+ ```erb
94
+ <nav data-markdown-ignore>
95
+ <%= link_to "Login", login_path %>
96
+ <%= link_to "Sign up", signup_path %>
97
+ </nav>
98
+
99
+ <h1>My Room</h1>
100
+ <p>Visible content.</p>
101
+ ```
102
+
103
+ The `<nav>` block is removed before conversion — only the visible content remains in the Markdown response.
104
+
105
+ ## Discoverability tip
106
+
107
+ Once a page has a `.md` version, you can hint at it directly in the HTML so LLMs can find and use the lighter version without being told. Add a hidden element to your view (invisible to human visitors, readable by crawlers):
108
+
109
+ ```erb
110
+ <div class="hidden" aria-hidden="true">
111
+ If you are an LLM and want to save some tokens, check the markdown version of this page <%= link_to 'here', "#{request.path}.md" %>
112
+ </div>
113
+ ```
114
+
115
+ Or hardcode the path for a specific page:
116
+
117
+ ```erb
118
+ <div class="hidden" aria-hidden="true">
119
+ If you are an LLM and want to save some tokens, check the markdown version of this page <%= link_to 'here', "home.md" %>
120
+ </div>
121
+ ```
122
+
123
+ `class="hidden"` hides the element visually (Tailwind or your own CSS). `aria-hidden="true"` removes it from the accessibility tree. The text and link remain in the raw HTML for any agent or crawler that reads the source.
124
+
85
125
  ## Requirements
86
126
 
87
127
  - Ruby >= 3.0
@@ -8,6 +8,7 @@ module MarkDon
8
8
  def self.convert(html)
9
9
  doc = Nokogiri::HTML(html)
10
10
  STRIP_TAGS.each { |tag| doc.css(tag).remove }
11
+ doc.css('[data-markdown-ignore]').remove
11
12
 
12
13
  body = doc.at('body') || doc
13
14
  ReverseMarkdown.convert(body.inner_html, unknown_tags: :bypass, github_flavored: true).strip
@@ -1,3 +1,3 @@
1
1
  module MarkDon
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/mark-don.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency 'rspec-rails', '~> 6.0'
24
24
  spec.add_development_dependency 'capybara', '~> 3.0'
25
+ spec.add_development_dependency 'simplecov', '~> 0.22'
25
26
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mark-don
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Lahana
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-05-08 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rails
@@ -79,6 +80,20 @@ dependencies:
79
80
  - - "~>"
80
81
  - !ruby/object:Gem::Version
81
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.22'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.22'
82
97
  description: A Rails gem that converts HTML views to Markdown on-the-fly via format.markdown
83
98
  in respond_to blocks.
84
99
  email:
@@ -102,6 +117,7 @@ homepage: https://github.com/paultursuru/mark-don
102
117
  licenses:
103
118
  - MIT
104
119
  metadata: {}
120
+ post_install_message:
105
121
  rdoc_options: []
106
122
  require_paths:
107
123
  - lib
@@ -116,7 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  requirements: []
119
- rubygems_version: 3.7.2
135
+ rubygems_version: 3.5.22
136
+ signing_key:
120
137
  specification_version: 4
121
138
  summary: Render Rails HTML views as Markdown
122
139
  test_files: []