项目作者: highlightjs

项目描述 :
Highlightjs Structured Text language support IEC 61131-3
高级语言: JavaScript
项目地址: git://github.com/highlightjs/highlightjs-structured-text.git
创建时间: 2019-08-02T08:42:31Z
项目社区:https://github.com/highlightjs/highlightjs-structured-text

开源协议:Other

下载


ST Language Support

Greenkeeper badge

This repository provides syntax highlighting for Highlight.js for Structured Text. ST is one of the 6 languages of IEC 61131-3 standard developed in 1998 for developing PLC programs.

We want to provide ST syntax highlights in VS Code Markdown editor and Markdown preview. And other cases when tutorials are published in the web.

Install

  1. npm i highlightjs-structured-text --save

Usage

Browser

Include the highlight.js script package in your webpage or node app, load this module and register it with hljs. Follow instructions at highlightjs to learn how to include the library and CSS.

If you’re not using a build system and just want to embed this in your webpage:

  1. <script type="text/javascript" src="/path/to/highlight.pack.js"></script>
  2. <script type="text/javascript" src="/path/to/highlightjs-structured-text/dist/iecst.min.js"></script>
  3. <script type="text/javascript">
  4. hljs.highlightAll();
  5. </script>

Nodejs

If you’re using webpack / rollup / browserify / node:

  1. var hljs = require('highlightjs');
  2. var hljsDefineIECST = require('highlightjs-structured-text');
  3. hljs.registerLanguage('iecst', hljsDefineIECST);
  4. hljs.initHighlightingOnLoad();

Mark the code you want to highlight with the iecst class:

  1. <pre><code class="iecst">...</code></pre>

Programmatically

Or use JavaScript to programmatically highlight text string:

  1. hljs.registerLanguage('iecst', hljsDefineIECST);
  2. var highlighted = hljs.highlightAuto(text_string, ["iecst"]);

React

  1. import React, {Component} from 'react'
  2. import 'highlight.js/scss/darcula.scss' # your favourite theme
  3. import cypher from './iecst'
  4. import hljs from 'highlight.js'
  5. hljs.registerLanguage('iecst', iecst);
  6. class Highlighter extends Component
  7. {
  8. constructor(props)
  9. {
  10. super(props);
  11. hljs.initHighlightingOnLoad();
  12. }
  13. render()
  14. {
  15. let {children} = this.props;
  16. return
  17. {
  18. <pre ref={(node) => this.node = node}>
  19. <code className="iecst">
  20. {children}
  21. </code>
  22. </pre>
  23. }
  24. }
  25. }
  26. export default Highlighter;

Marp

To use in marp

First create file engine.js

  1. const { Marp } = require('@marp-team/marp-core')
  2. const hljs = require('highlight.js')
  3. const iecst = require('highlightjs-structured-text')
  4. hljs.registerLanguage("iecst", iecst)
  5. module.exports = (opts) => {
  6. const marp = new Marp(opts)
  7. marp.highlighter = (code, lang) => {
  8. if (lang) {
  9. return hljs.getLanguage(lang)
  10. ? hljs.highlight(lang, code, true).value
  11. : ''
  12. }
  13. return hljs.highlightAuto(code).value
  14. }
  15. return marp
  16. }

And now when you build with CLI add engine parameter,

  1. npx marp --engine ./enjine.js ./slides.md