mddir 0.2.0 → 0.2.1

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: abb02fa2e52354eec94c383286dafe3954463784612e7774f85ae00317c5e464
4
- data.tar.gz: f094863fee5535ad5faf6e4d8504acba9a9f0655126266be6efda373c49aa396
3
+ metadata.gz: e6aac0b080aaf3ec9e7b1c912cfabed017b5379610be25ba5ccf865925b061f7
4
+ data.tar.gz: 7a80416b4d19a80e6de0448877b5f6d9b8ab650ed967ae231579fe808c7cbd69
5
5
  SHA512:
6
- metadata.gz: 0272dee5640a128756c89fd0819e4d95759c59c20408fffa72cdf27b6aa3812aea6f3be7c62417277c1a8ef9698ea3fbd06a53e4a7ce14d99444380ae3010345
7
- data.tar.gz: 525bd1a4c3c1d29a1d19e753cd1ed159f9b4170b589b041955ea40afa8e37b71e8364e361912446b40255fdd19d8feb9128192d6e8f36ce8c2edf6871df9de05
6
+ metadata.gz: fcade5ae9ef5dbc11091d817efcdf82bb4a848a9540dac5f9e919afc95b8ccd46b0b96106872af66d0490f9180fa9e4c699ba51cbe5fbe100d1e59689774f78e
7
+ data.tar.gz: ae7f69a7861fb375b45aa7abf64ae781429121cc49053c37cc5d943be02af1765118ed7f4043292b40f813fe34bc18af203370336ee83ffcf6fba2dd1dbf9b9a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2026-03-01
4
+
5
+ - Fix broken image markdown from pages using `<picture>` elements (e.g. Substack)
6
+
3
7
  ## [0.2.0] - 2026-03-01
4
8
 
5
9
  - Lazy load dependencies to speed up Tebako binaries
data/README.md CHANGED
@@ -17,15 +17,32 @@ mddir fetches web pages, converts them to clean markdown, and organizes them int
17
17
 
18
18
  ## Installation
19
19
 
20
- Requires Ruby >= 3.2.0. If you don't have Ruby installed, [mise](https://mise.jdx.dev) is the easiest way to get it:
20
+ ### Homebrew (macOS)
21
21
 
22
22
  ```bash
23
- mise use --global ruby@3
23
+ brew install AliOsm/tap/mddir
24
+ ```
25
+
26
+ ### Standalone Binary (macOS & Linux)
27
+
28
+ Download the latest binary for your platform from the [GitHub releases page](https://github.com/AliOsm/mddir/releases), then:
29
+
30
+ ```bash
31
+ # macOS: remove the quarantine flag
32
+ xattr -d com.apple.quarantine mddir
33
+
34
+ chmod +x mddir
35
+ sudo mv mddir /usr/local/bin/
24
36
  ```
25
37
 
26
- Then install the gem:
38
+ On Linux, skip the `xattr` step.
39
+
40
+ ### RubyGems
41
+
42
+ Requires Ruby >= 3.2.0. If you don't have Ruby installed, [mise](https://mise.jdx.dev) is the easiest way to get it:
27
43
 
28
44
  ```bash
45
+ mise use --global ruby@3
29
46
  gem install mddir
30
47
  ```
31
48
 
data/lib/mddir/fetcher.rb CHANGED
@@ -128,7 +128,8 @@ module Mddir
128
128
  def process_html_response(url, response)
129
129
  html = normalize_encoding(response.body.to_s, response.headers["content-type"])
130
130
  document = Nokogiri::HTML(html)
131
- title, article_html = extract_readable_content(html, document)
131
+ simplify_image_markup(document)
132
+ title, article_html = extract_readable_content(document.to_html, document)
132
133
  markdown = html_to_markdown(article_html)
133
134
 
134
135
  Entry.new(
@@ -142,6 +143,20 @@ module Mddir
142
143
  )
143
144
  end
144
145
 
146
+ def simplify_image_markup(document)
147
+ document.css("picture").each do |picture|
148
+ img = picture.at("img")
149
+ img ? picture.replace(img) : picture.remove
150
+ end
151
+
152
+ document.css("a").each do |a|
153
+ img = a.at("img")
154
+ next unless img
155
+
156
+ a.replace(img) if a.text.strip.empty?
157
+ end
158
+ end
159
+
145
160
  def extract_readable_content(html, document)
146
161
  title, article_html = run_readability(html)
147
162
 
data/lib/mddir/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mddir
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mddir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Hamdi Ali Fadel