yard-fence 0.5.0 → 0.7.0
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +27 -1
- data/README.md +1 -1
- data/lib/yard/fence/kramdown_gfm_document.rb +56 -3
- data/lib/yard/fence/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ab9b554560a42067263a056274659da9b71ab9d384a255dfda0e9e8f0ef86db9
|
|
4
|
+
data.tar.gz: 540eaf18d29756c303e7e4cba3ffcdddd29db9bc4f73a9507448509aac84efd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7724c35b7df1307d0220cfdf5610f3f7a0495e9ab6a8c325f709fbcfadbc3857f755f71879e859a62aa82c03a599bfebddfd164d62ec6ea30b1948315e077bfb
|
|
7
|
+
data.tar.gz: e57d9c374b51e94874be71f261c6d02cf689f3722245fd374daffa48f48022218321ade826453a33e16523d984eb74c71743c7012d8f49aedc7b09f4d784073c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,28 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
30
30
|
|
|
31
31
|
### Security
|
|
32
32
|
|
|
33
|
+
## [0.7.0] - 2025-11-08
|
|
34
|
+
|
|
35
|
+
- TAG: [v0.7.0][0.7.0t]
|
|
36
|
+
- COVERAGE: 99.19% -- 123/124 lines in 4 files
|
|
37
|
+
- BRANCH COVERAGE: 90.00% -- 36/40 branches in 4 files
|
|
38
|
+
- 37.93% documented
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Actually use custom KramdownGFM
|
|
43
|
+
|
|
44
|
+
## [0.6.0] - 2025-11-07
|
|
45
|
+
|
|
46
|
+
- TAG: [v0.6.0][0.6.0t]
|
|
47
|
+
- COVERAGE: 100.00% -- 119/119 lines in 4 files
|
|
48
|
+
- BRANCH COVERAGE: 100.00% -- 34/34 branches in 4 files
|
|
49
|
+
- 37.93% documented
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
|
|
53
|
+
- Catch unrendered code blocks and attempt to convert to HTML
|
|
54
|
+
|
|
33
55
|
## [0.5.0] - 2025-11-07
|
|
34
56
|
|
|
35
57
|
- TAG: [v0.5.0][0.5.0t]
|
|
@@ -94,7 +116,11 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
94
116
|
|
|
95
117
|
- Initial release
|
|
96
118
|
|
|
97
|
-
[Unreleased]: https://github.com/galtzo-floss/yard-fence/compare/v0.
|
|
119
|
+
[Unreleased]: https://github.com/galtzo-floss/yard-fence/compare/v0.7.0...HEAD
|
|
120
|
+
[0.7.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.6.0...v0.7.0
|
|
121
|
+
[0.7.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.7.0
|
|
122
|
+
[0.6.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.5.0...v0.6.0
|
|
123
|
+
[0.6.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.6.0
|
|
98
124
|
[0.5.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.4.0...v0.5.0
|
|
99
125
|
[0.5.0t]: https://github.com/galtzo-floss/yard-fence/releases/tag/v0.5.0
|
|
100
126
|
[0.4.0]: https://github.com/galtzo-floss/yard-fence/compare/v0.3.0...v0.4.0
|
data/README.md
CHANGED
|
@@ -586,7 +586,7 @@ Thanks for RTFM. ☺️
|
|
|
586
586
|
[📌gitmoji]: https://gitmoji.dev
|
|
587
587
|
[📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
|
|
588
588
|
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
589
|
-
[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.
|
|
589
|
+
[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.124-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
|
|
590
590
|
[🔐security]: SECURITY.md
|
|
591
591
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
592
592
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
@@ -12,14 +12,67 @@ require "kramdown-parser-gfm"
|
|
|
12
12
|
module Yard
|
|
13
13
|
module Fence
|
|
14
14
|
class KramdownGfmDocument < Kramdown::Document
|
|
15
|
+
# Detects an unrendered fenced code block that slipped through HTML generation.
|
|
16
|
+
# Note on <details markdown="1">:
|
|
17
|
+
# - The classic kramdown parser honors the markdown="1" attribute on block HTML like <details>,
|
|
18
|
+
# and will parse contained markdown as block-level content.
|
|
19
|
+
# - The GFM parser generally handles many cases well, and markdown="1" may appear to work in
|
|
20
|
+
# most sections; however, we've observed edge cases where fenced code blocks inside a
|
|
21
|
+
# <details markdown="1"> are left as literal backticks (rendered as <p>``` …</p>).
|
|
22
|
+
# This fallback detects that situation and re-renders with the classic parser.
|
|
23
|
+
UNRENDERED_FENCE_PARAGRAPH = /<p>```/
|
|
24
|
+
DETAILS_MARKDOWN_1 = /<details[^>]*markdown=["']1["'][^>]*>/i
|
|
25
|
+
|
|
15
26
|
def initialize(source, options = {})
|
|
16
27
|
options[:input] = "GFM" unless options.key?(:input)
|
|
28
|
+
@__yard_fence_source = source # Keep original for potential fallback.
|
|
17
29
|
super(source, options)
|
|
18
30
|
end
|
|
31
|
+
|
|
32
|
+
# Override to_html to provide a smart fallback: if the GFM parse leaves literal
|
|
33
|
+
# fenced code markers (```), re-run the render with the classic 'kramdown' input which
|
|
34
|
+
# correctly evaluates markdown inside <details markdown="1"> blocks.
|
|
35
|
+
# Opt-out via ENV["YARD_FENCE_DISABLE_FALLBACK"] == "1".
|
|
36
|
+
def to_html
|
|
37
|
+
html = super
|
|
38
|
+
return html if ENV["YARD_FENCE_DISABLE_FALLBACK"] == "1"
|
|
39
|
+
return html unless @__yard_fence_source.include?("```")
|
|
40
|
+
|
|
41
|
+
if needs_fallback?(html)
|
|
42
|
+
fallback_options = @options.merge(input: "kramdown")
|
|
43
|
+
fb_html = Kramdown::Document.new(@__yard_fence_source, fallback_options).to_html
|
|
44
|
+
return fb_html if fallback_improved?(fb_html)
|
|
45
|
+
end
|
|
46
|
+
html
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def needs_fallback?(html)
|
|
52
|
+
# Obvious failure: raw fenced code rendered as a paragraph
|
|
53
|
+
return true if html.match?(UNRENDERED_FENCE_PARAGRAPH)
|
|
54
|
+
# Edge case: details wrapper present in source but output lacks any code block
|
|
55
|
+
if @__yard_fence_source.match?(DETAILS_MARKDOWN_1)
|
|
56
|
+
has_code_block = html.include?("<pre") && html.include?("<code")
|
|
57
|
+
return !has_code_block
|
|
58
|
+
end
|
|
59
|
+
false
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def fallback_improved?(fb_html)
|
|
63
|
+
fb_html.match?(UNRENDERED_FENCE_PARAGRAPH) == false &&
|
|
64
|
+
fb_html.include?("<pre") && fb_html.include?("<code")
|
|
65
|
+
end
|
|
19
66
|
end
|
|
20
67
|
end
|
|
21
68
|
end
|
|
22
69
|
|
|
23
|
-
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
70
|
+
# Ensure YARD can resolve the provider constant at the top-level
|
|
71
|
+
# YARD does something akin to Object.const_get("::" + const), so it expects
|
|
72
|
+
# a top-level ::KramdownGfmDocument when const == "KramdownGfmDocument".
|
|
73
|
+
# Provide an alias to our namespaced implementation.
|
|
74
|
+
# :nocov:
|
|
75
|
+
unless defined?(KramdownGfmDocument)
|
|
76
|
+
KramdownGfmDocument = Yard::Fence::KramdownGfmDocument
|
|
77
|
+
end
|
|
78
|
+
# :nocov:
|
data/lib/yard/fence/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yard-fence
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter H. Boling
|
|
@@ -316,10 +316,10 @@ licenses:
|
|
|
316
316
|
- MIT
|
|
317
317
|
metadata:
|
|
318
318
|
homepage_uri: https://yard-fence.galtzo.com/
|
|
319
|
-
source_code_uri: https://github.com/galtzo-floss/yard-fence/tree/v0.
|
|
320
|
-
changelog_uri: https://github.com/galtzo-floss/yard-fence/blob/v0.
|
|
319
|
+
source_code_uri: https://github.com/galtzo-floss/yard-fence/tree/v0.7.0
|
|
320
|
+
changelog_uri: https://github.com/galtzo-floss/yard-fence/blob/v0.7.0/CHANGELOG.md
|
|
321
321
|
bug_tracker_uri: https://github.com/galtzo-floss/yard-fence/issues
|
|
322
|
-
documentation_uri: https://www.rubydoc.info/gems/yard-fence/0.
|
|
322
|
+
documentation_uri: https://www.rubydoc.info/gems/yard-fence/0.7.0
|
|
323
323
|
funding_uri: https://github.com/sponsors/pboling
|
|
324
324
|
wiki_uri: https://github.com/galtzo-floss/yard-fence/wiki
|
|
325
325
|
news_uri: https://www.railsbling.com/tags/yard-fence
|
metadata.gz.sig
CHANGED
|
Binary file
|