linebreaks
過(guò)濾器可以將多行文本按換行符轉(zhuǎn)換成html標(biāo)簽。每行開頭和結(jié)尾采用<p>
和</p>
包裹,中間有空行則采用 <br/>
。
還可以使用 linebreaksbr
來(lái)進(jìn)行處理。與 linebreaks
不同的地方是,linebreaksbr
只是直接將換行符替換成 <br/>
,并且不在開頭和結(jié)尾添加p標(biāo)簽。
還可以使用 linenumbers
來(lái)給多行文本的每一行進(jìn)行標(biāo)號(hào),符號(hào)從1開始。如 1.
。
linebreaks
過(guò)濾器的使用方法:
}
linebreaksbr
過(guò)濾器的使用方法:
}
linenumbers
過(guò)濾器的使用方法:
}
比如處理字符串 this is a text\nwith a new line in it
,則可以這么寫:
}顯示結(jié)果
<p>this is a text<br />with a new line in it</p>
linebreaks
過(guò)濾器
} } } }顯示結(jié)果
<p>this is a text<br />with a new line in it</p> <p>This is a simple text.</p><p>This too, as a paragraph.<br />Right?</p><p>Yep!</p> <p>john doe</p>
linebreaksbr
過(guò)濾器
} } } }顯示結(jié)果
this is a text<br />with a new line in it This is a simple text.</p><p>This too, as a paragraph.<br />Right?</p><p>Yep! john doe
linenumbers
過(guò)濾器
}顯示結(jié)果
- This is a simple text.
- This too, as a paragraph.
- Right?
- Yep!