CONTENTEDITABLE DIV 仅限示例字符串
int main(){
if((x<3 && x!=5) || x>10)
//execute statement;
while((y<10) && (y>1))
//execute statement;
}
DIV的现有HTML
<div id="board_code">
<div>int main<span class="openParen bm1">(</span><span class="closeParen bm1">)</span></div>
<div></div>
<div>if<span class="openParen bm2">(</span><span class="openParen bm3">(</span>x<3 && x!=5<span class="closeParen bm3">)</span> || x>10<span class="closeParen bm2">)</span></div>
<div>//execute statement;</div>
<div>while<span class="openParen bm4">(</span><span class="openParen bm5">(</span>y<10<span class="closeParen bm5">)</span> && <span class="openParen bm6">(</span>y>1<span class="closeParen bm6">)</span><span class="closeParen bm4">)</span></div>
<div>//execute statement;</div>
<div>}</div>
</div>
TARGET HTML
<div id="board_code">
<div>int main<span class="parenWrap"><span class="openParen bm1">(</span><span class="closeParen bm1">)</span></span></div>
<div></div>
<div>if<span class="parenWrap"><span class="openParen bm2">(</span><span class="parenWrap"><span class="openParen bm3">(</span>x<3 && x!=5<span class="closeParen bm3">)</span></span> || x>10<span class="closeParen bm2">)</span></span></div>
<div>//execute statement;</div>
<div>while<span class="parenWrap"><span class="openParen bm4">(</span><span class="parenWrap"><span class="openParen bm5">(</span>y<10<span class="closeParen bm5">)</span></span> && <span class="parenWrap"><span class="openParen bm6">(</span>y>1<span class="closeParen bm6">)</span></span><span class="closeParen bm4">)</span></span></div>
<div>//execute statement;</div>
<div>}</div>
</div>
我已经通过拥有一对()
等来匹配bm1, bm2
。现在,我需要将openParen bm(n)
包裹到closeParen bm(n)
{{1} }}。看,我已经确定了paren对,现在我需要将它们作为一个整体包装,以便我可以在以后评估它们,它接近HIGHLIGHTING,但我不会真正突出它,我将评估两者之间的文本。
我怎样才能实现这个目标?
我尝试了这个,但它无法正常工作
span class = parenWrap