Refine the auto-link selector.

This commit is contained in:
John-David Dalton
2016-09-05 01:54:33 -07:00
parent fb833b0c19
commit 691db4d406

View File

@@ -41,12 +41,12 @@ const hlTypes = [
* @param {Object} $ The Cheerio object.
*/
function autoLink($) {
$('code').each(function() {
$('.doc-container code').each(function() {
const $code = $(this);
const html = $code.html();
if (/^_\.\w+$/.test(html)) {
const id = html.split('.')[1];
$code.html(`<a href="#${ id }">_.${ id }</a>`);
$code.replaceWith(`<a href="#${ id }"><code>_.${ id }</code></a>`);
}
});
}