Open GoogleCodeExporter opened 9 years ago
I too have noticed this issue,
Is it possible to prioritize or run prettify twice so it parses HTML first
before the enclosed PHP tags?
Maybe allow for two language hints in the class like the following so it runs
twice:
<code class="prettyprint lang-html lang-php"> ... </code>
Thanks
Original comment by karoloch...@gmail.com
on 5 Apr 2013 at 9:53
Found a temporary hack around which isn't ideal but does get the job done.
Split out the enclosed PHP tag into another pre tag and replace it with a
unique id which I also included as the id of the new pre, so for example using
OP's code:
<pre class="prettyprint linenums">
<meta charset="[php-replace-123]" />
</pre>
<pre class="prettyprint" id="php-replace-123">
<?php bloginfo('charset'); ?>
</pre>
My site has jQuery loaded, so used it to receive the prettify complete event
and then injected the PHP code into the original tag before destroying the
temporary pre tag:
<script type="text/javascript">
window['exports'] = {prettify_replace: {apply: function(win, arg) {
$('pre[id^=php-replace-].prettyprinted').each(function(i, ob) {
var id = $(ob).attr('id');
var html = $(ob).html();
$("pre").each(function () {
$(this).html($(this).html().replace('['+id+']',html));
});
$(ob).remove();
});
}}};
</script>
With the following for loading prettify's js file:
<script
src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?call
back=prettify_replace"></script>
Again, not ideal but does work.
Original comment by karoloch...@gmail.com
on 5 Apr 2013 at 11:24
Original issue reported on code.google.com by
shtrih.m...@gmail.com
on 1 Jul 2012 at 10:20