When publishing content and designing templates in AnQi CMS, it is a common requirement to display the text input on the backend, which includes line breaks and spaces, in a structured HTML format on the frontend page.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 handle it, will it generate multiple empty ones?<p>tags?

Deeply UnderstandlinebreaksThe working mechanism of the filter, it is mainly responsible for converting newline characters in text to HTML tags to better adapt to web page formatting habits. Specifically, it will convert a single newline character (\n) Convert to<br />Tags, while two consecutive newline characters (\n\n) are considered as paragraph separators, and the text content before and after them is wrapped in<p>Label in. This processing method is designed to allow the background input of plain text to be presented in a structured paragraph effect on the front-end, even if HTML tags are not manually added.

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

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

这是第一段文字。


这是第二段文字。

Here, there are three consecutive newline characters between 'the first text' and 'the second text', which is two visual blank lines.linebreaksFilter processes the first double newline ("auto" to a paragraph end and the start of a new paragraph (i.e., "English"),\n\n}) as the end of a paragraph and the start of a new paragraph (i.e., "English").</p><p>)。而接下来的每一个双换行符,如果其间没有实际内容,也会被视为一个新的空段落。因此,它可能会生成类似这样的HTML结构:

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

This behavior originates fromlinebreaksFilter recognizes the logic of "paragraph" in the text.It treats two consecutive newline characters as paragraph separators.If three or more consecutive newline characters are found, it will be considered as inserting one or more paragraphs with empty content.

If you do not want to generate these empty<p>Tags, or just need simple line breaks instead of semantic paragraph structures, Anqi CMS also provideslinebreaksbrFilter.linebreaksbrThe handling method is more direct and simplified: it will simply replace all line breaks in the text, whether single or consecutive<br />tags and will not create any<p>Label.

For example, the same original text:

这是第一段文字。


这是第二段文字。

AfterlinebreaksbrAfter the filter is processed, it will generate:

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

UnderstandlinebreaksThis feature is helpful for