Skip to content

Commit 5e9f7b2

Browse files
committed
New structure
1 parent acff8a3 commit 5e9f7b2

File tree

6 files changed

+198
-258
lines changed

6 files changed

+198
-258
lines changed

README.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,78 @@ We want to provide ST syntax highlights in VS Code Markdown editor and Markdown
1212

1313
## Usage
1414

15+
### Browser
16+
1517
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.
1618

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

1921
```html
2022
<script type="text/javascript" src="/path/to/highlight.pack.js"></script>
21-
<script type="text/javascript" src="/path/to/highlightjs-structured-text/iecst.js"></script>
23+
<script type="text/javascript" src="/path/to/highlightjs-structured-text/dist/iecst.min.js"></script>
2224
<script type="text/javascript">
23-
hljs.registerLanguage('iecst', window.hljsDefineIECST);
2425
hljs.initHighlightingOnLoad();
2526
</script>
2627
```
2728

29+
### Nodejs
30+
2831
If you're using webpack / rollup / browserify / node:
2932

3033
```javascript
3134
var hljs = require('highlightjs');
32-
var hljsDefineCUrl = require('highlightjs-structured-text');
35+
var hljsDefineIECST = require('highlightjs-structured-text');
3336

34-
hljsDefineIECST(hljs);
37+
hljs.registerLanguage('iecst', hljsDefineIECST);
3538
hljs.initHighlightingOnLoad();
3639
```
3740

38-
Mark the code you want to highlight with the curl class:
41+
Mark the code you want to highlight with the ST class:
3942

4043
```html
4144
<pre><code class="iecst">...</code></pre>
4245
```
4346

44-
or use JavaScript to dynamically highlight text:
47+
### Programmatically
48+
49+
Or use JavaScript to programmatically highlight text string:
4550

4651
```javascript
47-
hljs.registerLanguage('iecst', window.hljsDefineIECST);
48-
var highlighted = hljs.highlightAuto(text, ["iecst"]);
52+
hljs.registerLanguage('iecst', hljsDefineIECST);
53+
var highlighted = hljs.highlightAuto(text_string, ["iecst"]);
54+
```
55+
56+
### React
57+
58+
59+
```js
60+
import React, {Component} from 'react'
61+
import 'highlight.js/scss/darcula.scss' # your favourite theme
62+
import cypher from './iecst'
63+
import hljs from 'highlight.js'
64+
hljs.registerLanguage('iecst', iecst);
65+
66+
class Highlighter extends Component
67+
{
68+
constructor(props)
69+
{
70+
super(props);
71+
hljs.initHighlightingOnLoad();
72+
}
73+
74+
render()
75+
{
76+
let {children} = this.props;
77+
return
78+
{
79+
<pre ref={(node) => this.node = node}>
80+
<code className="iecst">
81+
{children}
82+
</code>
83+
</pre>
84+
}
85+
}
86+
}
87+
88+
export default Highlighter;
4989
```

dist/iecst.min.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
hljs.registerLanguage("iecst",(()=>{"use strict";return e=>({
2+
aliases:["iecst","scl","stl","structured-text"],name:"Structured Text",
3+
case_insensitive:!0,keywords:{
4+
keyword:"if then end_if elsif else case of end_case to do by while repeat end_while end_repeat for end_for from public private protected or and not xor le ge eq ne ge lt constant return exit at retain non_retain task with until using extend",
5+
title:"program end_program function end_function function_block end_function_block configuration end_configuration action end_action transition end_transition type end_type struct end_struct step end_step initial_step namespace end_namespace channel end_channel library end_library folder end_folder resource end_resource var var_global end_var var_input VAR_EXTERNAL var_out var_output var_in_out var_temp var_interval var_access var_config method end_method property end_property interface end_interface",
6+
literal:"false true null ",
7+
built_in:"array pointer int sint dint lint usint uint udint ulint real lreal time date time_of_day date_and_time dt tod wstring string bool byte word dword lword ref_to any_num any_int any_string",
8+
function:"mod abs acos asin atan cos exp expt ln log sin sqrt tan sel max min limit mux shl shr rol ror indexof sizeof adr ref adrinst bitadr add mul div sub trunc move"
9+
},contains:[{className:"string",begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE,{
10+
begin:"''"}],relevance:0},{className:"string",begin:'"',end:'"',
11+
contains:[e.BACKSLASH_ESCAPE,{begin:'""'}],relevance:0},{className:"symbol",
12+
begin:"(D|T|DT|TOD)#[0-9:\\-_shmyd]*"},{className:"symbol",
13+
begin:"[a-zA-Z_]+#[a-zA-Z]*"},{className:"symbol",
14+
begin:"[A-Za-z]{1,6}#[0-9_\\.e\\-]*",relevance:0},{className:"number",
15+
begin:"[0-9]+#\\-?[0-9_]*",relevance:0},{className:"number",
16+
begin:"[a-zA-Z_]+#\\-?[0-9_]*",relevance:0},{className:"symbol",
17+
begin:"%(I|Q|M)(X|B|W|D|L)[0-9.]*"},{className:"symbol",begin:"%(I|Q|M)[0-9.]*"
18+
},e.C_NUMBER_MODE,e.COMMENT("//","$"),e.C_BLOCK_COMMENT_MODE,e.COMMENT("\\(\\*","\\*\\)")]
19+
})})());

iecst.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

package-lock.json

Lines changed: 0 additions & 118 deletions
This file was deleted.

package.json

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
{
2-
"name": "highlightjs-structured-text",
3-
"version": "1.0.0",
4-
"description": "highlight.js syntax definition for Structured Text IEC 61131-3 language",
5-
"main": "iecst.js",
6-
"scripts": {
7-
"test": "jasmine"
8-
},
9-
"files": [
10-
"iecst.js"
11-
],
12-
"repository": {
13-
"type": "git",
14-
"url": "https://github.com/highlightjs/highlightjs-structured-text.git"
15-
},
16-
"keywords": [
17-
"ST",
18-
"Structured Text",
19-
"IEC 61131-3",
20-
"CoDeSys",
21-
"PLC",
22-
"highlight.js",
23-
"highlightjs",
24-
"syntax-highlight",
25-
"syntax"
26-
],
27-
"author": "Sergey Romanov",
28-
"license": "MIT",
29-
"bugs": {
30-
"url": "https://github.com/highlightjs/highlightjs-structured-text/issues"
31-
},
32-
"homepage": "https://github.com/highlightjs/highlightjs-structured-text#readme",
33-
"devDependencies": {
34-
"highlight.js": "^10.0.2",
35-
"jasmine": "^3.5.0"
36-
}
2+
"name": "highlightjs-structured-text",
3+
"version": "1.1.0",
4+
"description": "highlight.js syntax definition for Structured Text IEC 61131-3 language",
5+
"main": "src/iecst.js",
6+
"scripts": {
7+
"test": "jasmine"
8+
},
9+
"files": [
10+
"src/iecst.js",
11+
"dist/iecst.min.js"
12+
],
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/highlightjs/highlightjs-structured-text.git"
16+
},
17+
"keywords": [
18+
"ST",
19+
"Structured Text",
20+
"IEC 61131-3",
21+
"CoDeSys",
22+
"PLC",
23+
"highlight.js",
24+
"highlightjs",
25+
"syntax-highlight",
26+
"syntax"
27+
],
28+
"author": "Sergey Romanov",
29+
"license": "MIT",
30+
"bugs": {
31+
"url": "https://github.com/highlightjs/highlightjs-structured-text/issues"
32+
},
33+
"homepage": "https://github.com/highlightjs/highlightjs-structured-text#readme",
34+
"devDependencies": {
35+
"highlight.js": "^10.0.2",
36+
"jasmine": "^3.5.0"
37+
}
3738
}

0 commit comments

Comments
 (0)