Skip to content

Commit fb5c5e6

Browse files
authored
feat: spring24 Apex updates (#51)
null coalesce operator new namespaces fix: "this" variables fix: method names starting with "get" or "set" now highlighted correctly Before, the keyword highlighter wasn't checking for word boundaries (may be a bug with main library)
1 parent 133be56 commit fb5c5e6

File tree

11 files changed

+144
-83
lines changed

11 files changed

+144
-83
lines changed

.github/workflows/release-please.yml

+5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ on:
33
push:
44
branches:
55
- main
6+
#paths:
7+
# - 'src/**'
68
workflow_dispatch:
9+
710
permissions:
811
contents: write
912
pull-requests: write
1013
id-token: write
1114
jobs:
1215
release-please:
16+
# Only run for non-Dependabot PRs
17+
# if: ${{ github.actor != 'dependabot[bot]' }}
1318
runs-on: ubuntu-latest
1419
steps:
1520
- uses: google-github-actions/release-please-action@v4

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 David Schach
3+
Copyright (c) David Schach
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+42-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,32 @@
44

55
[![NPM](https://nodei.co/npm/highlightjs-apex.png)](https://www.npmjs.com/package/highlightjs-apex)
66

7-
[![npm](https://img.shields.io/npm/v/highlightjs-apex)](https://www.npmjs.com/package/highlightjs-apex)
8-
[![npm](https://img.shields.io/npm/dt/highlightjs-apex)](https://www.npmjs.com/package/highlightjs-apex)
7+
![Salesforce Version](https://img.shields.io/badge/Spring_'24-0d9dda?style=flat&logo=salesforce&logoColor=white&label=Salesforce%20Release)
8+
[![npm version](https://img.shields.io/npm/v/highlightjs-apex)](https://www.npmjs.com/package/highlightjs-apex)
9+
[![npm downloads](https://img.shields.io/npm/dt/highlightjs-apex)](https://www.npmjs.com/package/highlightjs-apex)
910
![install size](https://badgen.net/packagephobia/install/highlightjs-apex)
10-
[![GitHub](https://img.shields.io/github/license/highlightjs/highlightjs-apex)](https://github.com/highlightjs/highlightjs-apex/blob/main/LICENSE.md)
11-
![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/highlightjs-apex)
11+
[![License](https://img.shields.io/github/license/highlightjs/highlightjs-apex)](https://github.com/highlightjs/highlightjs-apex/blob/main/LICENSE.md)
1212
[![CDN download](https://badgen.net/badge/jsDelivr/download/blue?icon=jsdelivr)](https://cdn.jsdelivr.net/npm/highlightjs-apex/dist/apex.min.js)
1313

14+
<!-- [![jsDelivr CDN downloads](https://badgen.net/jsdelivr/hits/gh/highlightjs/highlightjs-apex?label=jsDelivr+CDN&color=purple)](https://www.jsdelivr.com/package/gh/highlightjs/highlightjs-apex) -->
15+
16+
[![open issues](https://badgen.net/github/open-issues/highlightjs/highlightjs-apex?label=issues)](https://github.com/highlightjs/highlightjs-apex/issues)
17+
1418
## Demo
1519

1620
The screenshot was captured from a webpage using `apex.min.js` from the `dist` folder and the main `highlight.min.js` library.
1721
(Code is from [Salesforce Trigger Framework](https://dschach.github.io/salesforce-trigger-framework/))
1822
![Demo](assets/ApexHighlighting.png)
1923
Feel free to use any css library you'd like!
2024

25+
## Apex code requirements
26+
27+
This library will highlight Apex as used in Apex classes and triggers.
28+
29+
## SOQL requirements
30+
31+
To highlight a SOQL query, it MUST be enclosed in square brackets (`[` and `]`). While creating a SOQL parser as a standalone sub-language (like javascript in html/Visualforce) would be ideal, this would require users to install both packages in a project and would get too messy. Each language can contain the other, so dependencies in the parsing become unwieldy.
32+
2133
## Usage
2234

2335
Simply include the Highlight.js library in your webpage or Node app, then load this module. For more complex usage, see [highlight.js usage](https://github.com/highlightjs/highlight.js#basic-usage).
@@ -26,12 +38,16 @@ Simply include the Highlight.js library in your webpage or Node app, then load t
2638

2739
Simply load this module after loading Highlight.js. You'll use the minified version found in the `dist` directory. This module is just a CDN build of the language, so it will register itself as the Javascript is loaded.
2840

41+
For more details see [Highlight.js main page](https://github.com/highlightjs/highlight.js#highlightjs).
42+
2943
```html
3044
<script type="text/javascript" src="/path/to/highlight.min.js"></script>
3145
<script type="text/javascript" src="/path/to/apex.min.js"></script>
3246
<!-- <link rel="stylesheet" href="https://unpkg.com/highlightjs/styles/vs.css" /> -->
3347
<!-- Use any stylesheet you'd like - though Apex developers may want to use the custom theme based on MavensMate's Monokai -->
34-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlightjs-apex/src/styles/monokai-sublime-apex.css" />
48+
<link
49+
rel="stylesheet"
50+
href="https://cdn.jsdelivr.net/npm/highlightjs-apex/src/styles/monokai-sublime-apex.css" />
3551

3652
<script type="text/javascript">
3753
hljs.highlightAll();
@@ -48,17 +64,36 @@ This will find and highlight code inside of `<pre><code>` tags; it tries to dete
4864
</pre>
4965
```
5066

51-
For more details see [Highlight.js main page](https://github.com/highlightjs/highlight.js#highlightjs).
67+
#### Ignoring a Code Block
68+
69+
To skip highlighting of a code block completely, use the `nohighlight` class:
70+
71+
```html
72+
<pre><code class="nohighlight">...</code></pre>
73+
```
5274

5375
### Using directly from jsDelivr
5476

5577
```html
5678
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script>
57-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/highlightjs-apex/dist/apex.min.js"></script>
79+
<script
80+
type="text/javascript"
81+
src="https://cdn.jsdelivr.net/npm/highlightjs-apex/dist/apex.min.js"></script>
5882
```
5983

6084
- More info: <https://www.jsdelivr.com/>
6185

86+
### Using directly from the unpkg CDN
87+
88+
```html
89+
<script src="https://unpkg.com/@highlightjs/[email protected]/highlight.min.js"></script>
90+
<script
91+
type="text/javascript"
92+
src="https://unpkg.com/highlightjs-apex/dist/apex.min.js"></script>
93+
```
94+
95+
- More info: <https://unpkg.com/>
96+
6297
### With Node or another build system
6398

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

demo/testcode.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<script charset="UTF-8" src="../dist/apex.min.js"></script>
88
<link rel="stylesheet" href="./testcode.css" />
99
<!-- <link rel="stylesheet" href="../src/styles/monokai-sublime-apex.css" /> -->
10-
<link rel="stylesheet" href="vs.css" />
10+
<link rel="stylesheet" href="vs.css" />
1111
<script>
1212
hljs.debugMode();
1313
hljs.highlightAll();

0 commit comments

Comments
 (0)