This repository was archived by the owner on Aug 5, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +13
-9
lines changed
Expand file tree Collapse file tree 5 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def initialize
88 end
99
1010 def header ( text , header_level )
11- friendly_text = text . parameterize
11+ friendly_text = text . gsub ( /<[^>]*>/ , "" ) . parameterize
1212 @@headers_history [ header_level ] = text . parameterize
1313
1414 if header_level > 1
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ def toc_data(page_content)
99 headers . push ( {
1010 id : header . attribute ( 'id' ) . to_s ,
1111 content : header . children ,
12+ title : header . children . to_s . gsub ( /<[^>]*>/ , '' ) ,
1213 level : header . name [ 1 ] . to_i ,
1314 children : [ ]
1415 } )
@@ -27,4 +28,4 @@ def toc_data(page_content)
2728 end
2829 end
2930 headers
30- end
31+ end
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def initialize
77 @head_count = { }
88 end
99 def header ( text , header_level )
10- friendly_text = text . gsub ( /<[^<]+ >/ , "" ) . parameterize
10+ friendly_text = text . gsub ( /<[^>]* >/ , "" ) . parameterize
1111 if friendly_text . strip . length == 0
1212 # Looks like parameterize removed the whole thing! It removes many unicode
1313 # characters like Chinese and Russian. To get a unique URL, let's just
Original file line number Diff line number Diff line change 33; ( function ( ) {
44 'use strict' ;
55
6- var htmlPattern = / < [ ^ > ] * > / g;
6+ var htmlPattern = / < [ ^ > ] * > / g;
77 var loaded = false ;
88
99 var debounce = function ( func , waitTime ) {
6767 }
6868
6969 var $best = $toc . find ( "[href='" + best + "']" ) . first ( ) ;
70- var joinedTitle = $best . data ( "title" ) + " – " + originalTitle ;
7170 if ( ! $best . hasClass ( "active" ) ) {
7271 // .active is applied to the ToC link we're currently on, and its parent <ul>s selected by tocListSelector
7372 // .active-expanded is applied to the ToC links that are parents of this one
8180 if ( window . history . replaceState ) {
8281 window . history . replaceState ( null , "" , best ) ;
8382 }
84- // TODO remove classnames
85- document . title = joinedTitle . replace ( htmlPattern , '' ) ;
83+ var thisTitle = $best . data ( "title" )
84+ if ( thisTitle !== undefined && thisTitle . length > 0 ) {
85+ document . title = thisTitle + " – " + originalTitle ;
86+ } else {
87+ document . title = originalTitle ;
88+ }
8689 }
8790 } ;
8891
Original file line number Diff line number Diff line change @@ -72,12 +72,12 @@ under the License.
7272 < ul id ="toc " class ="toc-list-h1 ">
7373 <% toc_data ( page_content ) . each do |h1 | %>
7474 < li >
75- < a href ="# <%= h1 [ :id ] %> " class ="toc-h1 toc-link " data-title ="<%= h1 [ :content ] . to_s . parameterize %> "> <%= h1 [ :content ] %> </ a >
75+ < a href ="# <%= h1 [ :id ] %> " class ="toc-h1 toc-link " data-title ="<%= h1 [ :title ] %> "> <%= h1 [ :content ] %> </ a >
7676 <% if h1 [ :children ] . length > 0 %>
7777 < ul class ="toc-list-h2 ">
7878 <% h1 [ :children ] . each do |h2 | %>
7979 < li >
80- < a href ="# <%= h2 [ :id ] %> " class ="toc-h2 toc-link " data-title ="<%= h2 [ :content ] . to_s . parameterize %> "> <%= h2 [ :content ] %> </ a >
80+ < a href ="# <%= h2 [ :id ] %> " class ="toc-h2 toc-link " data-title ="<%= h2 [ :title ] %> "> <%= h2 [ :content ] %> </ a >
8181 </ li >
8282 <% end %>
8383 </ ul >
You can’t perform that action at this time.
0 commit comments