Question

I'm trying to use PrismJS while not attaching it as a strict dependency to any functions. All iI needed it to do is render the syntax highlighting on the page but, unfortunately, the full styling isn't being passed to the page.

I did read this SO thread and confirmed that Prism is attached to the window object, but the styling isn't showing up on the page.

Here's my code (prism.css is concatenated with other styles via Sass):

The HTML:

<pre><code class="language-css">
git rm 'myFile.html'
</code></pre>`

The script tag:

<script data-main="/js/config.js" src="/js/require.js"></script>

config.js

requirejs.config({

  baseUrl: "/js",

  deps: ["prism"],

  paths: {
    prism: "vendor/prism"
  },

  shim: {
    "prism": {
      "exports": "Prism"
    }
  }
});

prism.js

define("prism", ["prism"],function(Prism) {
  return Prism; //probably redundant
});

I have a feeling that doing something in prism.js is what's needed, but am not 100% sure.

Was it helpful?

Solution

Most likely you don't need this anymore, but I have stumbled on this question while faced with similar problem.

What you need, most likely, is Prism.highlightAll(); function call. My solution was found at http://schier.co/blog/2013/01/07/how-to-re-run-prismjs-on-ajax-content.html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top