Skip to content

Commit 181b8e7

Browse files
authored
Upgrade to latest commonmarker version (#774)
* Upgrade to lates version of commonmarker. * Output links so that they can be rendered as markdown in a GitHub issue.
1 parent 38b3211 commit 181b8e7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

meta/scripts/find_upgradeable_patterns.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
def count_known_instances(file)
2323
section_nodes = collect_section_nodes(file, "Known Instances")
2424
list_nodes = []
25+
2526
# pick the first list in the "Known Instances" section, and return the number of elements in that list.
2627
# CAUTION: this assumes a certain structure across all patterns. Therefore fairly brittle.
2728
list_nodes = section_nodes.select {|n| n.type == :list}
@@ -32,15 +33,16 @@ def count_known_instances(file)
3233
return known_instances_count
3334
end
3435

36+
# Extract all nodes below a given headline
3537
def collect_section_nodes(file, section_title)
3638
markdown = open(file).readlines().join
37-
doc = CommonMarker.render_doc(markdown)
39+
doc = Commonmarker.parse(markdown)
3840

3941
title_found = false
4042
section_nodes = []
4143

4244
doc.walk do |node|
43-
if node.type == :header
45+
if node.type == :heading
4446
if title_found == false
4547
node.each do |subnode|
4648
if subnode.type == :text and subnode.string_content == section_title
@@ -70,7 +72,10 @@ def collect_section_nodes(file, section_title)
7072

7173
l1_patterns.each do |file|
7274
known_instances_count = count_known_instances(file)
73-
puts "#{known_instances_count} | #{file}" if known_instances_count >= 1
75+
file_display = file.gsub("../../patterns/1-initial/","")
76+
file_link = file.gsub("../../","https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/")
77+
78+
puts "#{known_instances_count} | [#{file_display}](#{file_link})"
7479
end
7580

7681
puts "\n"
@@ -80,5 +85,8 @@ def collect_section_nodes(file, section_title)
8085

8186
l2_patterns.each do |file|
8287
known_instances_count = count_known_instances(file)
83-
puts "#{known_instances_count} | #{file}" if known_instances_count >= 3
88+
file_display = file.gsub("../../patterns/2-structured/","")
89+
file_link = file.gsub("../../","https://github.com/InnerSourceCommons/InnerSourcePatterns/blob/main/")
90+
91+
puts "#{known_instances_count} | [#{file_display}](#{file_link})"
8492
end

0 commit comments

Comments
 (0)