Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Vanilla 2.3 fully supports PHP 7. Get it now!
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

Horror in the code

This discussion is related to the AutoParagraph addon.
TiGRTiGR
edited November 2010 in Vanilla 2.1 & Earlier Help
Lincoln, why are you using 21 pcre calls for every post on page?! With 30 posts on page it takes 630 calls! This is a performance horror.

I've used less than 20 pcre calls for entire templating engine. Why this simple task should take that much of resources?
Tagged:

Comments

  • LincLinc Vanilla's Bard (and Lead Developer) Detroit Vanilla Staff
    edited November 2010
    I lifted the entire AutoParagraph method straight from Wordpress. If you come up with a better solution than them, let me know.

    If you think automatically adding 'p' tags is simple, then I'd bet you haven't tried it.
  • Is there anything in the markdown code that can do this, since one of markdown's functions is to put paragraphs into the text (which it does nicely).
  • LincLinc Vanilla's Bard (and Lead Developer) Detroit Vanilla Staff
    Unfortunately, I'm not familiar with the Markdown parsing.
  • SS ✭✭
    HtmlPurifier do it :p
  • judgejjudgej
    edited November 2010
    The Markdown parser is there in the core, and is very handy and easy to use. It can be told what features to apply, so paragraph tags can be enabled on their own.

    How many regexs it runs, I don't know.
  • judgejjudgej
    edited December 2010
    Just used the markdown processor myself (to display category descriptions in the discussions view) and it is incredibly simple to use. To convert a string to HTML using the markdown rules, the statement does the job:

    $html_string = Gdn_Format::To($markdown_string, 'markdown');

    That will put in paragraph marks, images, lists etc. That may be overkill just to handle paragraphs, but the markdown object can be instantiated by hand just to run specific parts of it.
  • It also doesn't add p tags to the first paragraph, only subsequent ones. just saying.
Sign In or Register to comment.