Plugin for post parsing


  • Community Rep

    I'm in the process of developing a plugin, and I noticed that any link formatted string gets turned into a hyperlink before the plugin gets it; I had to form my regex to account for this and noticed that psychobunny's youtube plugin does the same thing. Is there a way to grab the post content before any hyperlinks are processed?

    Also @psychobunny I made a modification to the youtube plugin that makes it work a lot nicer in the mobile version if you haven't seen it yet.


  • GNU/Linux Admin

    Hey @BDHarrington7, great question!

    You'll notice in the youtube plugin that the post.parse hook is registered with a priority of 6:

    { "hook": "filter:post.parse", "method": "parse", "callbacked": true, "priority": 6 }
    

    6 is chosen because all of the parsers (Markdown, in this case) also listen for the post.parse hook, at a priority of 5. We specifically use a higher priority (which, ironically, means it gets parsed later*) because the Markdown parser also strips HTML, meaning if we parsed the URLs into the <embed> code, it would just get immediately removed after it hits the Markdown parser.

    If your plugin's return to post.parse does not actually contain HTML, then it would be perfectly acceptable to use a priority level of 4 or less.

    * one of my brighter moments...


  • Community Rep

    The priority makes sense, if you sort in ascending order 🙂


  • Admin

    thanks for the responsive fix @BDHarrington7

    @julian

    • one of my brighter moments...

    haha if we do change it we should change that now, while the list of plugins are short (and list of plugins that utilize priority sequence is shorter)


  • Community Rep

    @psychobunny Yes, the sooner the better...


Log in to reply
 

Suggested Topics

  • 4
  • 1
  • 1
  • 2
  • 6
| |