jekyll-devto 0.4.0 → 0.4.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: cf35f7b24c365d778527268ce176a1a32be5bbb649401f91550ce0937e239d9c
4
- data.tar.gz: 34717d4bdb4f609360abf3a2e060f8503a40072f00b2c67c3e4be953bc8dfa6a
3
+ metadata.gz: c7bce50b84e2484bee6b05c2600a8d6e55ed88a7af0d9561d4bd77603d313f07
4
+ data.tar.gz: 96b2d3b96deb63f3055b9c5c45fbc100eae7198153cd2685e02fadcf86885a40
5
5
  SHA512:
6
- metadata.gz: 198310a7def375e4bf1fa63db874eb424db80d8bcc40027cefefac02412c3b98651fd4dbfedd936fd31593cee4201900a094ba1d5e44f72da376555a86fc4f25
7
- data.tar.gz: 0c73cff0dd44ce5ddb834e50cbdd4037195dd2f44de4cb0c63cbfe4c495bb9653cf3462b2803f112d0ad80592ca8ad507ff0df46f2e87b684279dc203900ef1d
6
+ metadata.gz: 1cde61c1c0fabde4d0ca05780a43b4d9457aa0932294e3125ec408e97bc6d5223a18fd7ff832c8f8df1a1263eb79754b7000366055b02d9ea493fd3fd44e103c
7
+ data.tar.gz: 1a661f4eebf60225e2644fb6c6d2b8a0371e9fb31cbd14d48012ccaff871063361656db1904dac38dc1257785b05cd4ecc4f0e655bb76ac25ebf34789acb96b9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.1](https://github.com/JuanVqz/jekyll-devto/compare/v0.4.0...v0.4.1) (2026-10-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **feed:** keep adjacent code blocks separate on dev.to ([#20](https://github.com/JuanVqz/jekyll-devto/issues/20)) ([6058520](https://github.com/JuanVqz/jekyll-devto/commit/6058520dc01714e21cde641570365b10af44f91a))
9
+
3
10
  ## [0.4.0](https://github.com/JuanVqz/jekyll-devto/compare/v0.3.1...v0.4.0) (2026-10-05)
4
11
 
5
12
 
data/README.md CHANGED
@@ -134,6 +134,7 @@ Checked against [Forem's source](https://github.com/forem/forem), the software d
134
134
  body. A plain `published: true` request leaves the post a draft.
135
135
  - **The import drops the language of every code block.** dev.to removes every `class` attribute before converting (`Feeds::CleanHtml`), so a fence never gets a language from the feed. The feed marks each block with `data-lang`, which survives, and `jekyll-devto publish` writes that language into the draft's fences, matching blocks by their first line of code.
136
136
  - **Sometimes the import keeps the raw HTML instead of Markdown.** dev.to converts the feed only when block tags outnumber blank lines (`Feeds::AssembleArticleMarkdown#html_content?`). The feed removes blank lines between tags and writes newlines inside code as `
`, so every post takes the Markdown path. Drafts imported before this change may still be raw HTML; their code keeps no language.
137
+ - **Two code blocks in a row merge into one.** After converting, dev.to deletes every closing fence followed by a blank line and an opening fence (`Feeds::AssembleArticleMarkdown#assemble_body_markdown`), which joins two code blocks with nothing between them. The feed puts a paragraph holding only a zero-width space between adjacent `<pre>` blocks to keep them apart.
137
138
  - **Only the first four tags are kept**, stripped to letters and digits and lowercased. Use `devto_tags` to choose them.
138
139
  - **"Replace self-referential links with DEV-specific links"** rewrites links between your posts to
139
140
  their dev.to articles at import time, drafts included. Publish the linked post first, or leave
@@ -47,6 +47,9 @@ module Jekyll
47
47
  # Kramdown's name for a fence with no language.
48
48
  NO_LANGUAGE = %w[plaintext text].freeze
49
49
 
50
+ # What separate_code_blocks puts between two adjacent code blocks.
51
+ ZERO_WIDTH_PARAGRAPH = '<p>&#8203;</p>'
52
+
50
53
  module_function
51
54
 
52
55
  def convert(html, base_url)
@@ -68,6 +71,14 @@ module Jekyll
68
71
  end.join
69
72
  end
70
73
 
74
+ # dev.to's import deletes every "```\n\n```" after converting
75
+ # (Feeds::AssembleArticleMarkdown), so two code blocks with nothing between
76
+ # them become one block holding both. A paragraph with a zero-width space
77
+ # keeps them apart; it has no text, only a line of space.
78
+ def separate_code_blocks(html)
79
+ html.to_s.gsub(%r{</pre>\s*(?=<pre\b)}) { "</pre>\n#{ZERO_WIDTH_PARAGRAPH}\n" }
80
+ end
81
+
71
82
  # Kramdown writes the fence's language as a language-* class, and the
72
83
  # language can hold any non-space character (c#, shell.session). It is
73
84
  # read from the class attribute only, so another attribute such as
@@ -152,7 +163,7 @@ module Jekyll
152
163
  end
153
164
 
154
165
  def devto_html(html, base_url)
155
- HTML.without_blank_lines(HTML.convert(html, base_url))
166
+ HTML.without_blank_lines(HTML.separate_code_blocks(HTML.convert(html, base_url)))
156
167
  end
157
168
  end
158
169
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Devto
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-devto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Vásquez