tag:support.markedapp.com,2011-09-11:/discussions/questions/10896-script-to-add-spans-to-h2-if-they-contain-the-string-sectionMarked: Discussion 2022-09-24T14:19:20Ztag:support.markedapp.com,2011-09-11:Comment/558478522022-09-23T21:07:10Z2022-09-23T21:07:11ZScript to add spans to h2 if they contain the string "Section"<div><p>Backticks were removed in the code in the previous post.<br>
Here is the image</p></div>Dayjutag:support.markedapp.com,2011-09-11:Comment/558478522022-09-24T07:55:42Z2022-09-24T07:55:42ZScript to add spans to h2 if they contain the string "Section"<div><p>This is because as of version 2.6, Marked no longer does a page refresh when updating, it simply injects the modified/updated content into the DOM directly. This makes for much faster and smoother refreshes, but it means scripts that rely on DOM load won't get triggered unless a refresh is forced.</p>
<p>I may add "hooks" at some point that scripts like this could subscribe to which would be triggered on a content update, but I don't have immediate plans for that.</p>
<p>The alternative would be to use Marked's custom preprocessor or processor functionality to inject the spans directly into the markup. You could use Python or Ruby to grep for ## lines containing Section and inject the spans before it ever got to the browser window.</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/558478522022-09-24T12:08:48Z2022-09-24T12:08:49ZScript to add spans to h2 if they contain the string "Section"<div><p>Thanks for the Reply.</p>
<p>Never thought about using pre-processors for Markdown. Just curious, but can I use gulpJS as a pre-processor for Markdown ?</p></div>Dayjutag:support.markedapp.com,2011-09-11:Comment/558478522022-09-24T14:19:20Z2022-09-24T14:19:20ZScript to add spans to h2 if they contain the string "Section"<div><p>You can use anything that you can execute on the commands line, as long as it can accept input on STDIN and return on STDOUT.</p>
<p>Thanks,<br>
Brett</p></div>Brett