rdoc-markdown 0.21.0 → 0.21.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 +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/rdoc/generator/markdown/conversion.rb +9 -8
- data/lib/rdoc/markdown/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5103b919452fc2a8143563d54ce1c2e7ab3e4aaf2afdfe44d6057fcce9a2e5c4
|
|
4
|
+
data.tar.gz: d8abe423253297371c5cb60c722bb24507c40d2a73ee9df37eca75a1b2dab60a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3fa2a3b9e6cc98af9902d054f3ad4989e05639f9f55da4bd2d5e4f5a984d9e97833d1c4d06898439a00907ad783ec7329ad46c2c8ae614fcc46a001ceea444fd
|
|
7
|
+
data.tar.gz: dedabad24735933e97d59127de66271a2a628287822e626c6eb4c5bf9631c613c512a05a511918c4a84fed34bffa61dd29166716fe61ae4badf38fa3e9220deb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.21.1
|
|
4
4
|
|
|
5
|
+
- Preserve hash-prefixed comments and literal Markdown headings in code examples when offsetting documentation headings.
|
|
6
|
+
|
|
7
|
+
## 0.21.0
|
|
5
8
|
- Keep generated method and section headings readable after raw HTML descriptions.
|
|
6
9
|
- Validate search-index targets and same-document links against parsed Markdown headings and anchors, including alias targets.
|
|
7
10
|
- Leave alias targets unlinked when RDoc has removed the canonical method from the generated documentation.
|
|
@@ -9,15 +9,13 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
9
9
|
#
|
|
10
10
|
# @return [String] Markdown with normalized links and no trailing whitespace.
|
|
11
11
|
def self.markdownify(input, heading_level_offset: 0)
|
|
12
|
-
fragment = normalized_html_fragment(input)
|
|
12
|
+
fragment = normalized_html_fragment(input, heading_level_offset)
|
|
13
13
|
anchor_aliases = tokenize_legacy_anchors(fragment.css("span.legacy-anchor[id]"))
|
|
14
14
|
document = fragment.document
|
|
15
15
|
fragment.css("a").each { |link| normalize_link(link, document) }
|
|
16
16
|
markdown = ReverseMarkdown.convert(fragment, github_flavored: true).dup
|
|
17
17
|
markdown.gsub!(Regexp.union(anchor_aliases.keys), anchor_aliases)
|
|
18
|
-
normalize_definition_lists(markdown).rstrip
|
|
19
|
-
"#{"#" * [Regexp.last_match(1).length + heading_level_offset, 6].min}#{Regexp.last_match(2)}"
|
|
20
|
-
end
|
|
18
|
+
normalize_definition_lists(markdown).rstrip
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
class << self
|
|
@@ -26,9 +24,10 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
26
24
|
# Normalizes HTML constructs that reverse_markdown cannot preserve directly.
|
|
27
25
|
#
|
|
28
26
|
# @param input [String] RDoc HTML fragment.
|
|
27
|
+
# @param heading_level_offset [Integer] Heading levels to add to actual HTML headings.
|
|
29
28
|
#
|
|
30
29
|
# @return [Nokogiri::HTML4::DocumentFragment] Normalized fragment.
|
|
31
|
-
def normalized_html_fragment(input)
|
|
30
|
+
def normalized_html_fragment(input, heading_level_offset)
|
|
32
31
|
fragment = Nokogiri::HTML.fragment(input)
|
|
33
32
|
context_anchors, content_anchors = fragment.css("span.legacy-anchor[id]").partition do |span|
|
|
34
33
|
context_anchor?(span)
|
|
@@ -41,7 +40,7 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
41
40
|
normalize_pre_blocks(fragment)
|
|
42
41
|
document = fragment.document
|
|
43
42
|
fragment.css("h1, h2, h3, h4, h5, h6").each do |heading|
|
|
44
|
-
|
|
43
|
+
normalize_heading(heading, document, heading_level_offset)
|
|
45
44
|
end
|
|
46
45
|
fragment
|
|
47
46
|
end
|
|
@@ -68,13 +67,15 @@ class RDoc::Generator::Markdown::Conversion
|
|
|
68
67
|
end
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
# Normalizes one heading's leading fragment link.
|
|
70
|
+
# Normalizes one heading's level and leading fragment link.
|
|
72
71
|
#
|
|
73
72
|
# @param heading [Nokogiri::XML::Element] Heading element.
|
|
74
73
|
# @param document [Nokogiri::HTML4::Document] Owning document.
|
|
74
|
+
# @param heading_level_offset [Integer] Heading levels to add, capped at six.
|
|
75
75
|
#
|
|
76
76
|
# @return [void]
|
|
77
|
-
def
|
|
77
|
+
def normalize_heading(heading, document, heading_level_offset)
|
|
78
|
+
heading.name = "h#{[Integer(heading.name.delete_prefix("h")) + heading_level_offset, 6].min}"
|
|
78
79
|
link = heading.xpath("./a[starts-with(@href, '#') and string-length(@href) > 1]").find do |anchor|
|
|
79
80
|
leading_heading_link?(anchor)
|
|
80
81
|
end
|