@@ -20,17 +20,36 @@ def generate(site)
20
20
# during the podcast page creation
21
21
podcast . data [ "references" ] = get_podcast_references ( reference_page . content , podcast . url )
22
22
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
+
26
27
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
+ )
28
47
end
29
48
end
30
49
end
31
50
end
32
51
33
- def find_title ( string , in_list = true , slugify = true )
52
+ def find_title ( string , in_list = true )
34
53
# this conditional prefix is for the special case of the review club section
35
54
# which is not a list item (no dash (-) at the start of the line)
36
55
prefix = in_list ? / *- / : //
@@ -44,7 +63,7 @@ def find_title(string, in_list=true, slugify=true)
44
63
{ }
45
64
else
46
65
result = { "title" => title }
47
- slug = slugify ? { "slug" => generate_slug ( title ) } : { }
66
+ slug = { "slug" => generate_slug ( title ) }
48
67
result . merge! ( slug )
49
68
end
50
69
end
@@ -100,6 +119,11 @@ def get_podcast_references(content, target_page_url)
100
119
podcast_reference . merge! ( current_title )
101
120
podcast_references << podcast_reference
102
121
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
103
127
# Replace the whole match with the link
104
128
headphones_link = "[<i class='fa fa-headphones' title='Listen to our discussion of this on the podcast'></i>]"
105
129
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)
109
133
if p . sub ( /^#+\s */ , "" ) == headers [ ( current_header + 1 ) % headers . length ( ) ]
110
134
current_header += 1
111
135
in_review_club_section = headers [ current_header ] == "Bitcoin Core PR Review Club"
136
+ # reset header-specific variables
137
+ current_title = { }
112
138
end
113
139
114
140
end
0 commit comments