0.1.0 • Published 10 months ago

highlightjs_fenl v0.1.0

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
10 months ago

License

NPM Version

CDN download

Fenl syntax highlighting for highlight.js

Fenl is the query language for Kaskada specialized for processing timestamped event data. This repository contains the Fenl syntax highlighting for highlight.js.

Usage

Static web pages

Simply load this module after loading Highlight.js. See below on how to generate the minified version for fenl.

<script type="text/javascript" src="/path/to/highlight.min.js"></script>
<script type="text/javascript" src="/path/to/fenl.min.js"></script>
<!-- Use any stylesheet you'd like - though it's best to choose from 
	those in highlightjs core repo -->
<link rel="stylesheet" href="https://unpkg.com/highlightjs/styles/vs.css" />
<script type="text/javascript">
  hljs.highlightAll();
</script>

This will find and highlight code inside <pre><code> tags; it does not to detect the language automatically so please specify fenl for the language.

<pre>
    <code class="language-fenl">
        # How many big purchases happen each hour and where?
        # Anything can be named and re-used
        let hourly_big_purchases = Purchase
        | when(Purchase.amount > 10)
        
        # Filter anywhere
        | count(window=since(hourly()))
        
        # Aggregate anything
        | when(hourly())
        
        # Shift timelines relative to each other
        let purchases_now = count(Purchase)
        let purchases_yesterday =
           purchases_now | shift_by(days(1))
        
        # Records are just another type
        in { hourly_big_purchases, purchases_in_last_day: purchases_now - purchases_yesterday }
    </code>
</pre>

For more details on usage, see highlight.js usage.

Using directly from jsDelivr

<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script>
<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/highlightjs_fenl/dist/fenl.min.js"></script>

With Node or another build system

If you're using Node / Webpack / Rollup / Browserify, etc, simply require the language module, then register it with Highlight.js.

var hljs = require('highlightjs');
var hljsFenl = require('highlightjs_fenl');

hljs.registerLanguage('fenl', hljsFenl);
hljs.highlightAll();

Development Setup

For the full details please read the highlightjs documentation,

Quickstart

  1. Make sure node and npm are available to you.
  2. Clone the main highlight.js repository:

    git clone https://github.com/highlightjs/highlight.js.git
  3. Install dependencies

    $ cd .../highlight.js
    $ npm install
  4. Clone this repo (or create a fork) into the extra directory:

    $ cd extra
    $ git clone https://github.com/USERNAME/highlightjs-chapel
  5. Make sure things work as expected:

    npm run build_and_test

    Specifically, at the end of this test run, you should see output for each of the tests in test/markup/chapel/, e.g.

 fenl
    ✔ have a name
    ✔ have 27 regex matchers
    ✔ should not use octal escapes
    ✔ should not cause exponential backtracking
    ✔ should not cause polynomial backtracking

NOTE: fenl currently does not support autodetection, one test will fail but you can ignore it for now. 1. Run

npm run build-cdn
  1. Copy build/languages/fenl.min.js to this repo's dist folder and commit the changes.

Build minified version

Run

npm run build-cdn

Once the build is complete you can find the minified version in build/languages/fenl.min.js

0.1.0

10 months ago