Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/highlightjs/highlightjs-structured-text
Highlightjs Structured Text language support IEC 61131-3
https://github.com/highlightjs/highlightjs-structured-text
61131-3 highlight highlight-js highlightjs plc structured-text syntax-highlighting
Last synced: 8 days ago
JSON representation
Highlightjs Structured Text language support IEC 61131-3
- Host: GitHub
- URL: https://github.com/highlightjs/highlightjs-structured-text
- Owner: highlightjs
- License: bsd-3-clause
- Created: 2019-08-02T08:42:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-25T20:46:38.000Z (over 2 years ago)
- Last Synced: 2024-04-24T22:41:59.293Z (7 months ago)
- Topics: 61131-3, highlight, highlight-js, highlightjs, plc, structured-text, syntax-highlighting
- Language: JavaScript
- Homepage:
- Size: 129 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ST Language Support
[![Greenkeeper badge](https://badges.greenkeeper.io/highlightjs/highlightjs-structured-text.svg)](https://greenkeeper.io/)
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
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](https://highlightjs.org/) 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:
```html
hljs.highlightAll();
```
### Nodejs
If you're using webpack / rollup / browserify / node:
```javascript
var hljs = require('highlightjs');
var hljsDefineIECST = require('highlightjs-structured-text');hljs.registerLanguage('iecst', hljsDefineIECST);
hljs.initHighlightingOnLoad();
```Mark the code you want to highlight with the iecst class:
```html
...
```### Programmatically
Or use JavaScript to programmatically highlight text string:
```javascript
hljs.registerLanguage('iecst', hljsDefineIECST);
var highlighted = hljs.highlightAuto(text_string, ["iecst"]);
```### React
```js
import React, {Component} from 'react'
import 'highlight.js/scss/darcula.scss' # your favourite theme
import cypher from './iecst'
import hljs from 'highlight.js'
hljs.registerLanguage('iecst', iecst);class Highlighter extends Component
{
constructor(props)
{
super(props);
hljs.initHighlightingOnLoad();
}render()
{
let {children} = this.props;
return
{
this.node = node}>
{children}
}
}
}export default Highlighter;
```### Marp
To use in [marp](https://marp.app)
First create file `engine.js`
```js
const { Marp } = require('@marp-team/marp-core')
const hljs = require('highlight.js')
const iecst = require('highlightjs-structured-text')
hljs.registerLanguage("iecst", iecst)module.exports = (opts) => {
const marp = new Marp(opts)marp.highlighter = (code, lang) => {
if (lang) {
return hljs.getLanguage(lang)
? hljs.highlight(lang, code, true).value
: ''
}
return hljs.highlightAuto(code).value
}return marp
}
```And now when you build with CLI add engine parameter,
```bash
npx marp --engine ./enjine.js ./slides.md
```