prism README

The project's README from github.com/PrismJS/prism. As one markdown file: README.md.

Prism

Build Status npm

Prism is a lightweight, robust, and elegant syntax highlighting library. It's a spin-off project from Dabblet.

You can learn more on prismjs.com.

Why another syntax highlighter?

More themes for Prism!

Contribute to Prism!

Important Notice

We are currently working on Prism v2 and will only accept security-relevant PRs for the time being.

Once work on Prism v2 is sufficiently advanced, we will accept PRs again. This will be announced on our Discussion page and mentioned in the roadmap discussion.

Prism v1 contributing notes

Prism depends on community contributions to expand and cover a wider array of use cases. If you like it, consider giving back by sending a pull request. Here are a few tips:

  • Read the documentation. Prism was designed to be extensible.
  • Do not edit prism.js, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the components/ folder. prism.js and all minified files are generated by our build system (see below).
  • Use npm ci to install Prism's dependencies. Do not use npm install because it will cause non-deterministic builds.
  • The build system uses gulp to minify the files and build prism.js. With all of Prism's dependencies installed, you just need to run the command npm run build.
  • Please follow the code conventions used in the files already. For example, I use tabs for indentation and spaces for alignment. Opening braces are on the same line, closing braces on their own line regardless of construct. There is a space before the opening brace. etc etc.
  • Please try to err towards more smaller PRs rather than a few huge PRs. If a PR includes changes that I want to merge and also changes that I don't, handling it becomes difficult.
  • My time is very limited these days, so it might take a long time to review bigger PRs (small ones are usually merged very quickly), especially those modifying the Prism Core. This doesn't mean your PR is rejected.
  • If you contribute a new language definition, you will be responsible for handling bug reports about that language definition.
  • If you add a new language definition or plugin, you need to add it to components.json as well and rebuild Prism by running npm run build, so that it becomes available to the download build page. For new languages, please also add a few tests and an example in the examples/ folder.
  • Go to prism-themes if you want to add a new theme.

Thank you so much for contributing!!

Software requirements

Prism will run on almost any browser and Node.js version but you need the following software to contribute:

  • Node.js >= 10.x
  • npm >= 6.x

Translations

prism (PrismJS/prism)

Searching Database…

13.1K ·GitHub
这是什么东西?Prism 是一个轻量、健壮且优雅的网页语法高亮库,是从 Dabblet 分出来的一个衍生项目。
它是加到我的网页里的东西,还是要单独运行的工具?它是一个 JavaScript 库,不是独立应用:Prism 几乎能在任何浏览器或 Node.js 版本中运行,你只需把它引入到页面上,它就会当场对代码进行高亮。
我怎么把它装到我的网站上?在 prismjs.com 的下载页面上构建自定义包,精确选择你需要语言和插件,或者从 npm 安装 prismjs 包。
无论是使用它还是参与开发,我都需要安装什么?使用它什么都不用装——Prism 没有任何运行时依赖,几乎能在任何浏览器中运行。要参与贡献,你需要 Node.js >= 10.x 和 npm >= 6.x,并且必须用 npm ci 安装依赖,因为 npm install 会导致构建结果不确定。
为什么还要再做一个语法高亮工具?README 里正好提出了这个问题,它的简短回答首先就是:更多主题。Prism 的设计是可扩展的,语言和插件都是独立的组件,可以在构建包时按需挑选。
开箱即用它能高亮哪些语言?支持的语言相当多——语言定义以独立组件的形式发布,覆盖范围通过社区贡献不断增长,而且下载页可以让你只勾选恰好需要的那些。
我怎么为一种全新的语言添加支持?把未压缩的定义文件加到 components/ 文件夹,在 components.json 中注册,然后运行 npm run build,它就会出现在下载页上。最好再附上几个测试和一个示例——另外请注意,从此有关你的语言定义的 bug 反馈就由你负责了。
我可以自己创建配色主题吗?可以——新主题应放在单独的 prism-themes 仓库里,而不是 Prism 主仓库。
Creator
PrismJS
Size
14.7 MB
Stars
13.1K
Age
14y
Commits · 90 Days