When publishing content and designing templates in AnQi CMS, displaying the text entered in the background with line breaks and empty lines in the structured HTML format on the front-end page is a common requirement.linebreaksThe filter is designed for this purpose. However, during use, many users may be curious about when there are consecutive blank lines in the text,linebreaksHow will the filter process, will it generate multiple empty ones as a result?<p>What about the tags

Get to know in-depthlinebreaksThe mechanism of the filter, it is mainly responsible for converting line breaks in text to HTML tags to better adapt to web page layout habits. Specifically, it will convert a single line break (\nConverted to<br />Tags, while consecutive two newline characters (\n\n) are considered paragraph separators, and the text content before and after them is enclosed in <p>In tags. This method is designed to allow the background input of plain text, even if HTML tags are not manually added, to display structured paragraph effects on the front end.

Then, let's go back to the core issue: when text appearsConsecutive multiple blank linesthen,linebreaksHow will the filter handle it? According to its design logic, the answer is:Yes, it will generate multiple empty<p>.

We can understand through a simple example. Suppose your original content is as follows:

这是第一段文字。


这是第二段文字。

Here, there are three consecutive line breaks between the first paragraph of text and the second paragraph of text, which is equivalent to two visual blank lines.linebreaksThe filter will parse the first double newline character (\n\n) as the end of a paragraph and the start of a new paragraph (i.e.</p><p>)。And the next double newline, if there is no actual content between them, will also be considered as a new empty paragraph. Therefore, it may generate an HTML structure like this:

<p>这是第一段文字。</p>
<p></p> <!-- 这是因为额外的空行被解析为一个独立段落 -->
<p>这是第二段文字。</p>

This behavior originates fromlinebreaksThe filter identifies the logic of "paragraph" in text. It treats consecutive two newline characters as paragraph separators.If three or more consecutive newline characters occur, it is considered to have inserted one or more empty paragraphs between the text content.

If you do not want to generate these empty<p>Tags, or if you just need simple line breaks instead of semantic paragraph structures, Anqin CMS also provideslinebreaksbrfilter.linebreaksbrThe approach is more direct and simplified: it will simply replace all line breaks, whether single or consecutive<br />tags without creating any<p>.

For example, the same original text:

这是第一段文字。


这是第二段文字。

afterlinebreaksbrAfter filtering, it will generate:

这是第一段文字。<br /><br /><br />这是第二段文字。

UnderstandlinebreaksThis feature helps