@@ -20,17 +20,36 @@ def generate(site)
2020 # during the podcast page creation
2121 podcast . data [ "references" ] = get_podcast_references ( reference_page . content , podcast . url )
2222
23- # Each podcast transcript splits into segements using the paragraph title
24- # as the title of the segment. These segment splits are added manually but
25- # we can avoid the need to also manually add their anchors by doing that here
23+ # we use this in `newsletter-references.md` to be easier to identify
24+ # special sections when iterating through the sections of the newsletter
25+ podcast . data [ "special_sections" ] = [ ]
26+
2627 podcast . data [ "references" ] . each do |reference |
27- reference [ "has_transcript_section" ] = podcast . content . sub! ( /^(_.*?#{ Regexp . escape ( reference [ "title" ] ) } .*?_)/ , "{:#{ reference [ "slug" ] } -transcript}\n \\ 1" )
28+ if reference [ "title" ] . nil?
29+ # the title of a reference derives from the nested list items
30+ # under a header/section (News, Releases and release candidates, etc.)
31+ # if there are no list items, we end up with a missing title
32+ # we use this assumption to identify special sections
33+ podcast . data [ "special_sections" ] << reference [ "header" ]
34+ # use the header as the title of the section
35+ reference [ "title" ] = reference [ "header" ]
36+ reference [ "slug" ] = generate_slug ( reference [ "header" ] )
37+ end
38+ # Each podcast transcript splits into segements using the paragraph title
39+ # as the title of the segment. These segment splits must be added manually but
40+ # we can avoid the need to also manually add their anchors by doing that here,
41+ # where we effectivily search for the segment splits and prefix them with the anchor
42+ reference [ "has_transcript_section" ] =
43+ podcast . content . sub! (
44+ /^(_.*?#{ Regexp . escape ( reference [ "title" ] ) } .*?_)/ ,
45+ "{:#{ reference [ "slug" ] } -transcript}\n \\ 1"
46+ )
2847 end
2948 end
3049 end
3150 end
3251
33- def find_title ( string , in_list = true , slugify = true )
52+ def find_title ( string , in_list = true )
3453 # this conditional prefix is for the special case of the review club section
3554 # which is not a list item (no dash (-) at the start of the line)
3655 prefix = in_list ? / *- / : //
@@ -44,7 +63,7 @@ def find_title(string, in_list=true, slugify=true)
4463 { }
4564 else
4665 result = { "title" => title }
47- slug = slugify ? { "slug" => generate_slug ( title ) } : { }
66+ slug = { "slug" => generate_slug ( title ) }
4867 result . merge! ( slug )
4968 end
5069 end
@@ -100,6 +119,11 @@ def get_podcast_references(content, target_page_url)
100119 podcast_reference . merge! ( current_title )
101120 podcast_references << podcast_reference
102121
122+ if current_title . empty?
123+ # this is needed for the podcast reference mark to link to the header
124+ # of the special section
125+ current_title [ "slug" ] = generate_slug ( headers [ current_header ] )
126+ end
103127 # Replace the whole match with the link
104128 headphones_link = "[<i class='fa fa-headphones' title='Listen to our discussion of this on the podcast'></i>]"
105129 replacement_link_to_podcast_item = "#{ headphones_link } (#{ target_page_url } #{ current_title [ "podcast_slug" ] || current_title [ "slug" ] } )"
@@ -109,6 +133,8 @@ def get_podcast_references(content, target_page_url)
109133 if p . sub ( /^#+\s */ , "" ) == headers [ ( current_header + 1 ) % headers . length ( ) ]
110134 current_header += 1
111135 in_review_club_section = headers [ current_header ] == "Bitcoin Core PR Review Club"
136+ # reset header-specific variables
137+ current_title = { }
112138 end
113139
114140 end
0 commit comments