Skip to content

Commit

Permalink
feat(parser): allow hyphen in keys
Browse files Browse the repository at this point in the history
  • Loading branch information
naiyerasif committed Apr 17, 2024
1 parent a8adb33 commit 284489c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:

- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ The following options are available. All of them are optional.

- The key and value must be separated by equality sign `=`.
- The value must be wrapped within single-quotes `'`, double-quotes `"` or backticks `` ` ``.
- The key can contain letters, digits, underscore, and hyphen.

#### Ranges

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microflash/fenceparser",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"description": "A metadata parser for code fences in markdown",
"main": "src/index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"devDependencies": {
"ava": "^6.1.2"
},
"packageManager": "pnpm@8.15.6",
"packageManager": "pnpm@9.0.1",
"ava": {
"files": [
"test/**/*.test.js"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createToken, Lexer } from "chevrotain";
import defu from "defu";

const keyValuePairPattern = /(\w+)=(?:'([^']*)'|"([^"]*)"|\`([^`]*)\`)/;
const keyValuePairPattern = /([-\w]+)=(?:'([^']*)'|"([^"]*)"|\`([^`]*)\`)/;

const WhiteSpace = createToken({ name: "WhiteSpace", pattern: /\s+/, group: Lexer.SKIPPED });
const Range0 = createToken({ name: "Range0", pattern: /\w*{\d+}/, label: "range" });
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/combinations.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ const fixtures = [
}
},
{
input: ['showCopy="true"', "dataMotion=`reduced`", 'app_context="root"'],
input: ['showCopy="true"', "data-motion=`reduced`", 'app_context="root"'],
output: {
app_context: 'root',
dataMotion: 'reduced',
'data-motion': 'reduced',
showCopy: 'true'
}
},
Expand All @@ -121,14 +121,14 @@ const fixtures = [
'{9..11, 88}',
'{92, 109..112}',
'caption="Hello, World"',
"textColor='--text-default'",
"text-color='--text-default'",
'syntax_theme="nord"',
'css=`{ *: { display: none }}`',
'prompt{3, 9..11}',
],
output: {
caption: 'Hello, World',
textColor: '--text-default',
'text-color': '--text-default',
syntax_theme: 'nord',
css: '{ *: { display: none }}',
highlight: [
Expand Down

0 comments on commit 284489c

Please sign in to comment.