https://github.com/fisothemes/highlightjs-iecst
This repository provides a Highlight.js language definition for TwinCAT Structured Text (ST), allowing for proper syntax highlighting in mdBook, web applications, and documentation.
https://github.com/fisothemes/highlightjs-iecst
beckhoff codesys documentation highlightjs iec-st iec61131-3 plc syntax-highlighting twincat
Last synced: about 1 year ago
JSON representation
This repository provides a Highlight.js language definition for TwinCAT Structured Text (ST), allowing for proper syntax highlighting in mdBook, web applications, and documentation.
- Host: GitHub
- URL: https://github.com/fisothemes/highlightjs-iecst
- Owner: fisothemes
- License: mit
- Created: 2025-03-20T07:15:51.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-23T04:17:00.000Z (about 1 year ago)
- Last Synced: 2025-03-23T05:18:40.658Z (about 1 year ago)
- Topics: beckhoff, codesys, documentation, highlightjs, iec-st, iec61131-3, plc, syntax-highlighting, twincat
- Language: JavaScript
- Homepage: https://fisothemes.github.io/highlightjs-iecst/
- Size: 1.09 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IEC-ST (IEC 61131-3 Structured Text) – Language Grammar for [Highlight.js](https://highlightjs.org/)
This repository provides a third-party language definition for **IEC 61131-3 Structured Text (ST)** for use with [Highlight.js](https://highlightjs.org/).
IEC 61131-3 Structured Text is a high-level programming language designed for industrial automation. It resembles Pascal, supports complex control logic, and is widely used in PLC programming across industries such as manufacturing, energy, and process control.
## Example Page
See an example implementation here: **[fisothemes/highlightjs-iecst](https://fisothemes.github.io/highlightjs-iecst/)**
## Usage
### mdBook Integration
1. In your `book.toml` root directory, create a `theme/` folder.
1. Copy `dist/highlight.min.js` into it, and rename it to `highlight.js`.
1. Your folder structure should look like:
```mathematica
my-book/
├── book/
├── theme/
│ └── highlight.js
└── book.toml
```
1. In your Markdown code blocks, use the language identifier `iecst`:
```markdown
```iecst
PROGRAM MAIN
VAR
fSpeed : LREAL := 0.0;
END_VAR
fSpeed := 100.5;
END_PROGRAM
```
```
### Browser Integration
To use the grammar in a standalone HTML page:
```html
hljs.registerLanguage("iecst", window.hljsDefineIecst);
hljs.highlightAll();
```
Then use:
```html
PROGRAM MAIN
VAR
fSpeed : LREAL := 0.0;
END_VAR
fSpeed := 100.5;
END_PROGRAM
```
> [!IMPORTANT]
> - `highlight.min.js` is the **Highlight.js core** (v10).
> - `iecst.min.js` is the **standalone language definition**.
> - If you use `dist/highlight.min.js` (bundled by this repo), you **do not need to include** `iecst.min.js` separately — it's already embedded.
> - Use the class name `language-iecst` in `` blocks to activate the grammar.
## Installation
```bash
git clone https://github.com/fisothemes/highlightjs-iecst.git
cd highlightjs-iecst
npm install
```
## Build
To build everything:
- `dist/iecst.min.js` — standalone language definition
- `dist/highlight.min.js` — Highlight.js v10 core with `iecst` bundled
- `example/mdbook/theme/highlight.js` — copied for use with mdBook
Run:
```bash
npm run build
```
This uses the local `tools/highlight.js` (v10-compatible), appends your language definition, and minifies the result using `terser`.