forked from mrlan/EnglishPal
				
			更新 'app/static/js/highlight.js'
							parent
							
								
									b53e7031e5
								
							
						
					
					
						commit
						041cbd97fc
					
				|  | @ -31,7 +31,7 @@ function highLight() { | ||||||
|         for (var i = 0; i < list.length; ++i) { |         for (var i = 0; i < list.length; ++i) { | ||||||
|             list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");//消除字符串两边空字符
 |             list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");//消除字符串两边空字符
 | ||||||
|             if (list[i] != "" && "<mark>".indexOf(list[i]) == -1 && "</mark>".indexOf(list[i]) == -1) { |             if (list[i] != "" && "<mark>".indexOf(list[i]) == -1 && "</mark>".indexOf(list[i]) == -1) { | ||||||
| 
 |                 //将正则表达式进行修改 表示搜索的是两端带有空格的list[i] 那么搜索的便为一个完整单词  然后在mark标签的前后各加了一个空格对其进行替换
 | ||||||
|                 txt = txt.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " <mark>" + list[i] + "</mark> "); |                 txt = txt.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " <mark>" + list[i] + "</mark> "); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | @ -41,6 +41,7 @@ function highLight() { | ||||||
|         for (var i = 0; i < list2.length; ++i) { |         for (var i = 0; i < list2.length; ++i) { | ||||||
|             list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, ""); |             list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, ""); | ||||||
|             if (list2[i] != "" && "<mark>".indexOf(list2[i]) == -1 && "</mark>".indexOf(list2[i]) == -1) { |             if (list2[i] != "" && "<mark>".indexOf(list2[i]) == -1 && "</mark>".indexOf(list2[i]) == -1) { | ||||||
|  |                 //将正则表达式进行修改 表示搜索的是两端带有空格的list2[i] 那么搜索的便为一个完整单词  然后在mark标签的前后各加了一个空格对其进行替换
 | ||||||
|                 txt = txt.replace(new RegExp("\\s"+list2[i]+"\\s", "g"), " <mark>" + list2[i] + "</mark> "); |                 txt = txt.replace(new RegExp("\\s"+list2[i]+"\\s", "g"), " <mark>" + list2[i] + "</mark> "); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue