PHP Markdown \\n Question

2019-06-02 17:12发布

问题:

I'm using http://michelf.com/projects/php-markdown/ for my markdown library and my question is that if i edit and remove the \n\n functionality would this work

Because the users that i have, are quite probably not allowed to run JavaScript therefore i cant count on the preview to be generated dynamically therefore they will make allot of mistakes using \n instead of \n\n

So the question is: is it essential for the library to use the \n\n for the reg ex manipulation?

回答1:

After doing some research and looking at the markdown convertion, ive noticed that it can be done in such way:

Say for example we have text:

asdf
asdf
asdf

asdf
asdf
asdf

The output of this in Pure text Markup will be:

<p>asdf
asdf
asdf</p>

<p>
asdf
asdf
asdf</p>

So to replace the \n must only be done inside the <p> tags