Simplify options syntax
This commit is contained in:
parent
d16942c0a7
commit
b3a464c8d6
3 changed files with 12 additions and 8 deletions
10
README.md
10
README.md
|
@ -15,7 +15,7 @@ code
|
|||
With options:
|
||||
|
||||
````
|
||||
>[options]```lang
|
||||
>options```lang
|
||||
code
|
||||
```
|
||||
````
|
||||
|
@ -29,7 +29,7 @@ code
|
|||
With options:
|
||||
|
||||
````
|
||||
>[options]`lang code`
|
||||
>options`lang code`
|
||||
````
|
||||
|
||||
### Examples
|
||||
|
@ -42,7 +42,7 @@ main = print 1
|
|||
````
|
||||
|
||||
````
|
||||
>[harmony]```js
|
||||
>harmony```js
|
||||
class Foo {
|
||||
bar = 1;
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ console.log(new Foo().bar);
|
|||
>`py print('hello world')`
|
||||
```
|
||||
|
||||
```
|
||||
>e`hs (+) <$> Just 1 <*> Just 2`
|
||||
```
|
||||
|
||||
## Supported Languages
|
||||
|
||||
One of the following languages is set in `lang`.
|
||||
|
|
|
@ -12,7 +12,7 @@ class HelpCommand extends Command {
|
|||
return message.util.send([
|
||||
'**Usage:**',
|
||||
'Put a `>` before a code block with a language or an inline code block that has a language to execute it.',
|
||||
'You can add options inside `[]` after the `>`.',
|
||||
'You can add options, separated by semicolons, after the `>`.',
|
||||
'',
|
||||
'**Examples:**',
|
||||
'```',
|
||||
|
@ -22,9 +22,9 @@ class HelpCommand extends Command {
|
|||
'',
|
||||
'>`hs main = print (1 + 1)`',
|
||||
'',
|
||||
'>[harmony]`\u200B``js',
|
||||
'>e; harmony`\u200B``js',
|
||||
'class Foo { bar = 1; }',
|
||||
'console.log(new Foo().bar);',
|
||||
'new Foo().bar;',
|
||||
'`\u200B``',
|
||||
'```',
|
||||
'**Supported languages:**',
|
||||
|
|
|
@ -37,8 +37,8 @@ class MessageInvalidListener extends Listener {
|
|||
}
|
||||
|
||||
parseMessage(message) {
|
||||
const regex1 = /^\s*>\s*(?:\[(.+?)\])?\s*```(.+?)\n([^]+)```\s*$/;
|
||||
const regex2 = /^\s*>\s*(?:\[(.+?)\])?\s*`(.+?) \s*([^]+)`\s*$/;
|
||||
const regex1 = /^\s*>\s*(?:(.+?))?\s*```(.+?)\n([^]+)```\s*$/;
|
||||
const regex2 = /^\s*>\s*(?:(.+?))?\s*`(.+?) \s*([^]+)`\s*$/;
|
||||
const match = message.content.match(regex1) || message.content.match(regex2);
|
||||
if (!match) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue