Prism: add latex support and line number


Well-known member
@Chris D suggested that I post a suggestion here. (I found one already so I just second the motion but found it's under closed suggestion due to lack of interest)

Since XF2 has now increased support of numbers of coding languages, it makes sense for include latex since it's a language supported by prism. The level of work to add this would be very minimal for XF developer.
I imagine this will be much appreciated by those running sites that are academic and technical oriented since many math formula needs latex to display properly.

The current solution in XF 1.x is to load mathjax script in the header. Including Latex in the code would eliminate loading extra scripts.

The second suggestion is to display line number since it's very useful where people can specify the exact line where the code is not correct. See image
Screen Shot 2017-10-21 at 8.31.25 AM.png


Well-known member
@Chris D
Looks like adding the line number is pretty trivial according to the link above?
Add class line-numbers to your desired <pre> and line-numbers plugin will take care.


Active member
Some notes that might be helpful if/when implementing this:

1) XenForo 2.0 doesn't initialize PrismJS for unknown languages (like [CODE]…[/CODE]). This needs to change because otherwise those code blocks won't get line numbers.

2) But you have to keep PrismJS (and hence line-numbers) disabled for [CODE=rich]…[/CODE] because otherwise PrismJS would strip all rich formatting from the code.

3) I tried to use the URL in the first line of "code_block-compiled.js" as a starting point for generating the new PrismJS code. That didn't work because a dependency ("Markup templating") wasn't included automatically. You have to tick this checkbox manually.

4) (Another suggestion in our forum was to add PowerShell support.)