mark-don 0.1.0 → 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 +4 -4
- data/README.md +45 -1
- data/lib/mark_don/converter.rb +1 -0
- data/lib/mark_don/railtie.rb +1 -1
- data/lib/mark_don/version.rb +1 -1
- data/mark-don.gemspec +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 070e0922e5b0ec67d9195720f3bcb38eab41699aefc8771f7651698e5bbf0eab
|
|
4
|
+
data.tar.gz: 5f7b529087578ef596ae1426f511fb06bfdcb516528f32efc575df337b66de95
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bcb45d7e5d1e89b431f7c166362bdca07c82acd9301cd99eee24007888e38699ef1bdc1b16684d951a4a3bc1874a8a6cfdf91d7f7bfe7ba1d4c158f378b2200c
|
|
7
|
+
data.tar.gz: dc6973083a893e4a5102cf57bc0345c899b980d7569911145df3d09f47e59e782d0714792fbc7f4856c88c2dcf5e9c09363d8cf65b51e1a637a091f69852a8fc
|
data/README.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# mark-don
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/paultursuru/mark-don/actions/workflows/ci.yml)
|
|
4
|
+
[](https://badge.fury.io/rb/mark-don)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
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.
|
|
6
10
|
|
|
11
|
+
## Background
|
|
12
|
+
|
|
13
|
+
Inspired by [this Evil Martians article](https://evilmartians.com/chronicles/how-to-make-your-website-visible-to-llms) on making Rails apps visible to LLMs. The `.md` routes technique they describe is exactly what this gem automates.
|
|
14
|
+
|
|
7
15
|
## Installation
|
|
8
16
|
|
|
9
17
|
Add to your Gemfile:
|
|
@@ -78,6 +86,42 @@ This is a **great** room with a [nice view](/view).
|
|
|
78
86
|
- Breakfast at 8am
|
|
79
87
|
```
|
|
80
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
|
+
|
|
81
125
|
## Requirements
|
|
82
126
|
|
|
83
127
|
- Ruby >= 3.0
|
data/lib/mark_don/converter.rb
CHANGED
|
@@ -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
|
data/lib/mark_don/railtie.rb
CHANGED
|
@@ -10,7 +10,7 @@ module MarkDon
|
|
|
10
10
|
# method_missing (which recurses infinitely when the MIME symbol is :md but
|
|
11
11
|
# the called method is :markdown).
|
|
12
12
|
initializer 'mark_don.mime_type' do
|
|
13
|
-
Mime::Type.register 'text/markdown', :markdown unless Mime[:md] || Mime[:markdown]
|
|
13
|
+
Mime::Type.register 'text/markdown', :markdown, [], ['md'] unless Mime[:md] || Mime[:markdown]
|
|
14
14
|
|
|
15
15
|
unless ActionController::MimeResponds::Collector.method_defined?(:markdown)
|
|
16
16
|
ActionController::MimeResponds::Collector.class_eval do
|
data/lib/mark_don/version.rb
CHANGED
data/mark-don.gemspec
CHANGED
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.
|
|
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:
|
|
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.
|
|
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: []
|