How to treat single newline as real line break in PHP Markdown?

前端 未结 4 1703
说谎
说谎 2021-02-06 01:44

I was reading http://github.github.com/github-flavored-markdown/

I would like to implement that \"Newline modification\" in PHP Markdown:

Best I could think of

4条回答
  •  后悔当初
    2021-02-06 02:31

    PHP's nl2br -function doesn't cut it?

    nl2br — Inserts HTML line breaks before all newlines in a string

    http://php.net/manual/en/function.nl2br.php

    If you also want to remove all linebreaks (nl2br inserts
    ), you could do:

    str_replace('\n', '', nl2br($my_html));
    

    If not, please elaborate on how your solution fails, and what you'd like to fix.

提交回复
热议问题