Giter VIP home page Giter VIP logo

highlightjs-structured-text's Introduction

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

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:

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

Nodejs

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

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:

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

Programmatically

Or use JavaScript to programmatically highlight text string:

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

React

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
    {
      <pre ref={(node) => this.node = node}>
        <code className="iecst">
          {children}
        </code>
      </pre>
    }
  }
}

export default Highlighter;

Marp

To use in marp

First create file engine.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,

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.