Skip to content

Commit

Permalink
Merge pull request #8 from highlightjs/v11
Browse files Browse the repository at this point in the history
Update v11, relevance, bug fix
  • Loading branch information
jf990 authored Dec 30, 2021
2 parents 2492338 + 9f6e591 commit be69b45
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 110 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Load the `curl` module after loading Highlight.js. Use the minified version fou

```html
<script type="text/javascript"
src="https://unpkg.com/highlightjs-curl@1.2.0/dist/curl.min.js"></script>
src="https://unpkg.com/highlightjs-curl@1.3.0/dist/curl.min.js"></script>
```

- More info: <https://unpkg.com>
Expand All @@ -49,7 +49,7 @@ Once loaded, mark the code you want to highlight with the `language-curl` class:
<pre><code class="language-curl">...</code></pre>
```

Without specifying the language, Highlight.js will attempt to auto-detect the grammar. Since this curl grammar is an extension of bash, it may detect bash instead.
Without specifying the language, Highlight.js will attempt to auto-detect the grammar. Since this curl grammar is an extension of bash, it may detect bash or some other grammar instead. Therefore, always specify `curl` or `language-curl`.

For more information, follow instructions at [highlightjs.org](https://highlightjs.org/usage/) to learn how to include the library and CSS and other use cases. See [Getting started](https://github.com/highlightjs/highlight.js#getting-started) for different integration and module options.

Expand Down
72 changes: 0 additions & 72 deletions curl.js

This file was deleted.

14 changes: 14 additions & 0 deletions dist/curl.es.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*! `curl` grammar compiled for Highlight.js 11.3.1 */
var hljsGrammar=(()=>{"use strict";return e=>{const n={className:"string",
begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,{className:"variable",
begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]}],relevance:0},a={
className:"number",variants:[{begin:e.C_NUMBER_RE}],relevance:0};return{
name:"curl",aliases:["curl"],keywords:"curl",case_insensitive:!0,contains:[{
className:"literal",begin:/(--request|-X)\s/,contains:[{className:"symbol",
begin:/(get|post|delete|options|head|put|patch|trace|connect)/,end:/\s/,
returnEnd:!0}],returnEnd:!0,relevance:10},{className:"literal",begin:/--/,
end:/[\s"]/,returnEnd:!0,relevance:0},{className:"literal",begin:/-\w/,
end:/[\s"]/,returnEnd:!0,relevance:0},n,{className:"string",begin:/\\"/,
relevance:0},{className:"string",begin:/'/,end:/'/,relevance:0
},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,{match:/(\/[a-z._-]+)+/}]}}})()
;export default hljsGrammar;
15 changes: 14 additions & 1 deletion dist/curl.min.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
hljs.registerLanguage("curl",function(){"use strict";return function(e){var n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,{className:"variable",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]}],relevance:0},a={className:"number",variants:[{begin:e.C_NUMBER_RE}],relevance:0};return{name:"curl",aliases:["curl"],keywords:"curl",case_insensitive:!0,contains:[{className:"literal",begin:/(--request|-X)\s/,contains:[{className:"symbol",begin:/(get|post|delete|options|head|put|patch|trace|connect)/,end:/\s/,returnEnd:!0}],returnEnd:!0,relevance:10},{className:"literal",begin:/--/,end:/[\s"]/,returnEnd:!0,relevance:0},{className:"literal",begin:/-\w/,end:/[\s"]/,returnEnd:!0,relevance:0},n,{className:"string",begin:/\\"/,relevance:0},{className:"string",begin:/'/,end:/'/,relevance:0},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a]}}}());
/*! `curl` grammar compiled for Highlight.js 11.3.1 */
(()=>{var e=(()=>{"use strict";return e=>{const n={className:"string",begin:/"/,
end:/"/,contains:[e.BACKSLASH_ESCAPE,{className:"variable",begin:/\$\(/,
end:/\)/,contains:[e.BACKSLASH_ESCAPE]}],relevance:0},a={className:"number",
variants:[{begin:e.C_NUMBER_RE}],relevance:0};return{name:"curl",
aliases:["curl"],keywords:"curl",case_insensitive:!0,contains:[{
className:"literal",begin:/(--request|-X)\s/,contains:[{className:"symbol",
begin:/(get|post|delete|options|head|put|patch|trace|connect)/,end:/\s/,
returnEnd:!0}],returnEnd:!0,relevance:10},{className:"literal",begin:/--/,
end:/[\s"]/,returnEnd:!0,relevance:0},{className:"literal",begin:/-\w/,
end:/[\s"]/,returnEnd:!0,relevance:0},n,{className:"string",begin:/\\"/,
relevance:0},{className:"string",begin:/'/,end:/'/,relevance:0
},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,{match:/(\/[a-z._-]+)+/}]}}})()
;hljs.registerLanguage("curl",e)})();
163 changes: 151 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "highlightjs-curl",
"version": "1.2.1",
"version": "1.3.0",
"author": "John Foster",
"description": "Support for using highlight.js to syntax highlight cURL commands.",
"main": "src/languages/curl.js",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"homepage": "https://github.com/highlightjs/highlightjs-curl#readme",
"devDependencies": {
"highlight.js": "^10.7.1",
"jasmine": "^3.7.0"
"highlight.js": "^11.3.1",
"jasmine": "^3.10.0"
}
}
8 changes: 4 additions & 4 deletions spec/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<title>Test highlightjs curl grammar</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"></script>
<script src="../dist/curl.min.js"></script>
</head>
<body>
Expand All @@ -20,10 +20,10 @@ <h3>Code block</h3>
--range 3
-H "Auth: bearer 1234"
--header "Accept: ascii"
-O ftp://any.domain.com/public/xss.html
-O ftp://any.domain.com/public/path-to-resource/xss.html
</code></pre>
<pre><code class="language-curl">
curl --request post -u ftpuser:ftppass --proxy-header --range 3 -H "Auth: bearer 1234" --header "Accept: ascii" -O ftp://any.domain.com/public/xss.html https://example.com/v2/endpoint.php
curl --request post -u ftpuser:ftppass --proxy-header --range 3 -H "Auth: bearer 1234" --header "Accept: ascii" -O ftp://any.domain.com/public/path-to-resource/xss.html https://example.com/v2/endpoint.php
</code></pre>
</div>
<div>
Expand Down
Loading

0 comments on commit be69b45

Please sign in to comment.