-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run a completion block after text() has processed lines() #338
Comments
Wouldn't it work if you overrode the function text($text)
{
$markup = parent::text($text);
// modify $markup here
return $markup;
} |
I tried doing that, but I tried overriding the Example: (Sorry, forgot to mention i'm using ParsedownExtra)
Then init it:
In the above example, the
Inside the The offending line is in
What I want to doI want Parsedown to parse the entire document, then I want my extension to take the final markup and manipulate it (e.g: count the number of tags, and replace I know I can write an extension to replace the placeholder, but my current use case requires that I do it AFTER the ENTIRE document has been parsed into HTML (as I want to manipulate HTML elements and such after parsing). - Ideally I want to do this in my extension as opposed to adding the extra lines of code in my application (so the extension can be reusable across projects). Hopefully that all makes sense! |
I see. I'll look into this next week. |
When #576 is finished you will be able to traverse the entire AST, which I think should give you what you are looking for? :) |
I was building an extension and I wanted to run something after the blocks have been parsed by
lines
intext
, thelines
method is private (inParsedown
), and I wanted to do something after everything has been processed (but within my extension and not within my app).A
Complete
callback to thetext()
function.in Parsedown.php
Currently, I do something like this (This is within my app, I want to do this within my extension, once all the parsing is complete, I want to do some other stuff).
ParsedownExtension
is a child ofParsedown
, which I add thecompleteCallback
and call it manually.It would be great to have a function which is called after all processing is done which we could override to do custom things after, the other option is for me to override all the other blocks and count the lines to see where we are, and on the last line I could do whatever I wanted - obviously this is quite alot of work!
Currently, I'm using my solution above and doing this in my app, but If I want to use this in another app or publish it online, I would have to instruct everyone to call the callback (when I would really want my extension to do this - run a callback when everything is finished so I can do any custom processing in my extension before passing the
$markup
back to the client application).Thoughts or ideas for a workaround? - I have to do it after everything is processed as the
processTag
messes things up when inside adiv
(markdown="1"
).The text was updated successfully, but these errors were encountered: