We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5091
    • 332 Posts
    I was thinking this is PHx question but since it’s for Jot I decided to post it here.

    In jot-message the code shows this:

    <div class="jot-message">[+comment.content:wordwrap:esc:nl2br+]</div>

    I understand "nl2br = Converts new lines to breaks."
    What can I do to use ’<p>’ instead?

    I don’t see there is a string in PHx modifiers.

    Thanks!

      • 7923
      • 4,213 Posts
      You would need to do a custom PHx modifier and replace the nl2br modifier in Jot templates with yours.

      EDIT: for example, create a snippet "phx:nl2p":
      <?php
      return nl2br(str_replace('<p></p>', '', '<p>' . preg_replace('#([\r\n]\s*?[\r\n]){2,}#', '</p>$0<p>', $output) . '</p>'));
      ?>
      


      That should modify:
      Paragraph1
      
      Paragraph2
      line1
      line2
      

      to:
      <p>Paragraph1</p>
      <p>Paragraph2<br/>
      line1<br/>
      line2<br/></p>
      

      The code is from nl2br php manual page.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 5091
        • 332 Posts
        Quote from: doze at Sep 12, 2007, 09:04 AM

        You would need to do a custom PHx modifier and replace the nl2br modifier in Jot templates with yours.

        EDIT: for example, create a snippet "phx:nl2p":
        <?php
        return nl2br(str_replace('<p></p>', '', '<p>' . preg_replace('#([\r\n]\s*?[\r\n]){2,}#', '</p>$0<p>', $output) . '</p>'));
        ?>
        


        Thank you very much. Is it possible to output <p> only, without line break>

        According to this msg:http://fi2.php.net/manual/en/function.nl2br.php#50294,
        Am I understand no line break for this call?

        <?php
        function nl2p($str)
        {
        return str_replace(’<p></p>’, ’’, ’<p>’ . preg_replace(’#\n|\r#’, ’</p>$0<p>’, $str) . ’</p>’);
        }
        ?>

        It looks very ’similar’ to your code, and I changed ’2’ to zero, and my page turns blank.