PrismJS / prism

Lightweight, robust, elegant syntax highlighting.

Home Page:https://prismjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autoloader Plugin causes Command Line Plugin to run twice when used from CDN breaking data-filter-* on <pre>

Soyvolon opened this issue · comments

Information:

  • Prism version: v1.29.0 via CDN
  • Plugins: Autoloader, Command Line
  • Environment: Browser

Description

This bug occurs when Prism is loaded from a CDN or in a manner similar to a CDN. It does not occur when using a packaged bundle from the website.

When the Autoloader and Command Line plugins are both loaded, the Autoloader plugin causes Prism to scan a document for code boxes twice. When using the Command Line plugin with the data-filter-output="(out)" or the data-filter-continuation="(con)" attribute, the plugin outputs the expected result on the first pass - removing the prefixes and setting the lines to outputs. When Autoloader causes it to run a second time (once the grammar loads, I would assume), there are no longer any prefix on the code block lines, causing the Command Line plugin to think that every line is an input line.

Example

GitLab - contains example .html files and download copy of the Autoloader and Command Line plugins for testing. The files ending in from_git have a copy and pasted version of this file that I used to try and debug what was happening.

JSFiddles (for the .html files in the repo):