File tree 5 files changed +13
-9
lines changed
5 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def initialize
8
8
end
9
9
10
10
def header ( text , header_level )
11
- friendly_text = text . parameterize
11
+ friendly_text = text . gsub ( /<[^>]*>/ , "" ) . parameterize
12
12
@@headers_history [ header_level ] = text . parameterize
13
13
14
14
if header_level > 1
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ def toc_data(page_content)
9
9
headers . push ( {
10
10
id : header . attribute ( 'id' ) . to_s ,
11
11
content : header . children ,
12
+ title : header . children . to_s . gsub ( /<[^>]*>/ , '' ) ,
12
13
level : header . name [ 1 ] . to_i ,
13
14
children : [ ]
14
15
} )
@@ -27,4 +28,4 @@ def toc_data(page_content)
27
28
end
28
29
end
29
30
headers
30
- end
31
+ end
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def initialize
7
7
@head_count = { }
8
8
end
9
9
def header ( text , header_level )
10
- friendly_text = text . gsub ( /<[^<]+ >/ , "" ) . parameterize
10
+ friendly_text = text . gsub ( /<[^>]* >/ , "" ) . parameterize
11
11
if friendly_text . strip . length == 0
12
12
# Looks like parameterize removed the whole thing! It removes many unicode
13
13
# characters like Chinese and Russian. To get a unique URL, let's just
Original file line number Diff line number Diff line change 3
3
; ( function ( ) {
4
4
'use strict' ;
5
5
6
- var htmlPattern = / < [ ^ > ] * > / g;
6
+ var htmlPattern = / < [ ^ > ] * > / g;
7
7
var loaded = false ;
8
8
9
9
var debounce = function ( func , waitTime ) {
67
67
}
68
68
69
69
var $best = $toc . find ( "[href='" + best + "']" ) . first ( ) ;
70
- var joinedTitle = $best . data ( "title" ) + " – " + originalTitle ;
71
70
if ( ! $best . hasClass ( "active" ) ) {
72
71
// .active is applied to the ToC link we're currently on, and its parent <ul>s selected by tocListSelector
73
72
// .active-expanded is applied to the ToC links that are parents of this one
81
80
if ( window . history . replaceState ) {
82
81
window . history . replaceState ( null , "" , best ) ;
83
82
}
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
+ }
86
89
}
87
90
} ;
88
91
Original file line number Diff line number Diff line change @@ -72,12 +72,12 @@ under the License.
72
72
< ul id ="toc " class ="toc-list-h1 ">
73
73
<% toc_data ( page_content ) . each do |h1 | %>
74
74
< 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 >
76
76
<% if h1 [ :children ] . length > 0 %>
77
77
< ul class ="toc-list-h2 ">
78
78
<% h1 [ :children ] . each do |h2 | %>
79
79
< 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 >
81
81
</ li >
82
82
<% end %>
83
83
</ ul >
You can’t perform that action at this time.
0 commit comments