Skip to main content

linebreaks_filter

Replace line breaks in plain text with appropriate HTML; a single newline becomes an HTML line break (< br >) and a new line followed by a blank line becomes a paragraph break (< /p >).

def linebreaks_filter(
value: string,
autoescape: boolean = True
) - > string

Replace line breaks in plain text with appropriate HTML; a single newline becomes an HTML line break (< br >) and a new line followed by a blank line becomes a paragraph break (< /p >).

Parameters

NameTypeDescription
valuestringThe plain text content to be converted into HTML-formatted paragraphs and line breaks.
autoescapeboolean = TrueDetermines whether to escape HTML characters in the input text before processing line breaks.

Returns

TypeDescription
stringThe HTML-formatted string containing paragraph and line break tags, marked as safe for template rendering.