Simplify options syntax

This commit is contained in:
1computer1 2019-03-13 01:54:36 -04:00
parent d16942c0a7
commit b3a464c8d6
3 changed files with 12 additions and 8 deletions

View file

@ -15,7 +15,7 @@ code
With options: With options:
```` ````
>[options]```lang >options```lang
code code
``` ```
```` ````
@ -29,7 +29,7 @@ code
With options: With options:
```` ````
>[options]`lang code` >options`lang code`
```` ````
### Examples ### Examples
@ -42,7 +42,7 @@ main = print 1
```` ````
```` ````
>[harmony]```js >harmony```js
class Foo { class Foo {
bar = 1; bar = 1;
} }
@ -55,6 +55,10 @@ console.log(new Foo().bar);
>`py print('hello world')` >`py print('hello world')`
``` ```
```
>e`hs (+) <$> Just 1 <*> Just 2`
```
## Supported Languages ## Supported Languages
One of the following languages is set in `lang`. One of the following languages is set in `lang`.

View file

@ -12,7 +12,7 @@ class HelpCommand extends Command {
return message.util.send([ return message.util.send([
'**Usage:**', '**Usage:**',
'Put a `>` before a code block with a language or an inline code block that has a language to execute it.', '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:**', '**Examples:**',
'```', '```',
@ -22,9 +22,9 @@ class HelpCommand extends Command {
'', '',
'>`hs main = print (1 + 1)`', '>`hs main = print (1 + 1)`',
'', '',
'>[harmony]`\u200B``js', '>e; harmony`\u200B``js',
'class Foo { bar = 1; }', 'class Foo { bar = 1; }',
'console.log(new Foo().bar);', 'new Foo().bar;',
'`\u200B``', '`\u200B``',
'```', '```',
'**Supported languages:**', '**Supported languages:**',

View file

@ -37,8 +37,8 @@ class MessageInvalidListener extends Listener {
} }
parseMessage(message) { parseMessage(message) {
const regex1 = /^\s*>\s*(?:\[(.+?)\])?\s*```(.+?)\n([^]+)```\s*$/; const regex1 = /^\s*>\s*(?:(.+?))?\s*```(.+?)\n([^]+)```\s*$/;
const regex2 = /^\s*>\s*(?:\[(.+?)\])?\s*`(.+?) \s*([^]+)`\s*$/; const regex2 = /^\s*>\s*(?:(.+?))?\s*`(.+?) \s*([^]+)`\s*$/;
const match = message.content.match(regex1) || message.content.match(regex2); const match = message.content.match(regex1) || message.content.match(regex2);
if (!match) { if (!match) {
return null; return null;