mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
add comment about trying capture groups in future.
This commit is contained in:
@@ -105,8 +105,8 @@ const CodeEditor = createClass({
|
||||
const isLink = /^\[(.*)(\]\()(.*)\)$/g;
|
||||
const selection = this.codeMirror.getSelection();
|
||||
if(isLink.test(selection) == true){
|
||||
const altText = selection.slice(1, selection.lastIndexOf(']('));
|
||||
const url = selection.slice(selection.lastIndexOf('](') + 2, -1);
|
||||
const altText = selection.slice(1, selection.lastIndexOf('](')); // could likely be done better with capture groups
|
||||
const url = selection.slice(selection.lastIndexOf('](') + 2, -1); // could likely be done better with capture groups
|
||||
this.codeMirror.replaceSelection(`${altText} ${url}`);
|
||||
const cursor = this.codeMirror.getCursor();
|
||||
this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch });
|
||||
|
||||
Reference in New Issue
Block a user