Function convertToHtmlBreaks

  • Convert newline characters \n into HTML line breaks <br />.

    Usage:

    const ret1 = convertToHtmlBreaks('a\nb\nc');
    const ret2 = convertToHtmlBreaks('a\n\nbc');
    console.log(ret1);
    console.log(ret2);

    Output:

    a<br />b<br />c
    a<br /><br />bc
    

    Parameters

    • str: string

      The string to make a new line.

    Returns string

    A newline with br.