Here is one method, although I don't know if it is the most efficient. This relies on 'heading' always a being constant text.
const wrapper = $('span');
const part1 = wrapper.text().split('heading')[0];
const part2 = wrapper.text().split('heading')[1];
wrapper.html(`${part1} <h1>heading</h1> ${part2}`);
Grab the span element, then split it by heading text. Then rejoin the parts and wrap the heading text inside a <h1>
.
JSFIDDLE here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…