Git Product home page Git Product logo

Comments (4)

koyal13 avatar koyal13 commented on June 16, 2024

Right now I solved it removing html tags on php... But is there any better way to avoid markdown processing?

from grav-plugin-shortcode-core.

rhukster avatar rhukster commented on June 16, 2024

You can disable markdown processing at the page level with:

process:
  markdown: false

You can also set it programitically on the page with:

$page->process(['markdown' => false']);

of course this would need to be set prior to the $page->content() method being called as that's where markdown is processed if enabled.

The better option is to do some work in onPageContentRaw() event which is called prior to processMarkdown() function in the content() method.

from grav-plugin-shortcode-core.

koyal13 avatar koyal13 commented on June 16, 2024

So, I think it would be interesting to see an option or function to retrieve shortcode content without formatting. Anyway I'm going to make some attemps with onPageContentRaw() and onShortcodeHandlers Wish me luck! ;)

from grav-plugin-shortcode-core.

hamiltont avatar hamiltont commented on June 16, 2024

Years late, but I had the same issue and figured I would share what worked OK for me:

    public static function getSubscribedEvents()
    {
        require_once(__DIR__.'/vendor/autoload.php');        
        return [ 'onShortcodeHandlers' => ['onShortcodeHandlers', 0] ,
                 'onPageContentRaw' => ['getRaw', 0]];
    }
    public function getRaw(Event $e) {
        $page = $e['page'];
        $content = $page->content();
        // <snip> 
        // Some simple "find my shortcode" string processing
        // logic, since "$content" is just a big unparsed string at this point
        // </snip>
       $page->addContentMeta('customSCMeta', $scContents);
    }

Later on in my extension I just check if that meta key is set. If it is set, I completely ignore the result of shortcode->getContent() and instead use the raw contents pulled from the meta

HTH

from grav-plugin-shortcode-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.