2222def 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
3334end
3435
36+ # Extract all nodes below a given headline
3537def 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
7173l1_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 } )"
7479end
7580
7681puts "\n "
@@ -80,5 +85,8 @@ def collect_section_nodes(file, section_title)
8085
8186l2_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 } )"
8492end
0 commit comments