Navigation Menu

Skip to content
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

Unable to highlight dynamically created content #1328

Closed
runsun opened this issue Oct 17, 2016 · 2 comments
Closed

Unable to highlight dynamically created content #1328

runsun opened this issue Oct 17, 2016 · 2 comments

Comments

@runsun
Copy link

runsun commented Oct 17, 2016

Have a html that downloads code from the internet and displays it using the following javascript callback:

function display_file(fileInfo)
{
    $('#div_pygments_loadfiles')[0].innerHTML +=
    ` <details class="fileContent">
      <summary><b>${fileInfo.path}</b></summary>
      <pre><code class="python hljs">${fileInfo.data}</code></pre>
     </details>
    `   
}

It creates a <pre><code class="python hljs"> block to hold the code. The element inspection using the developer tools shows that it is classed with "python hljs" as expected, but the code is not highlighted, only the background is painted with the desired color/pattern. Tried several styles but all behave the same way.

The same downloaded code, if copied and pasted to the <body> section with the same <pre><code class="python hljs"> tags, is highlighted normally.

@runsun
Copy link
Author

runsun commented Oct 17, 2016

You can download the file demo.html from my Bitbucket snippet to check it out:

https://bitbucket.org/snippets/runsun/bMKzz

or copy and paste its raw file:

https://bitbucket.org/!api/2.0/snippets/runsun/bMKzz/f64fda6945c927511d7e6e96f2387fd185e7caa1/files/demo.html

@fsharpasharp
Copy link

You have to use the highlightBlock function after you have added new content. The default behavior is highlighting only when the page loads.

@runsun runsun closed this as completed Nov 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants