Give user feedback when options is not parsing.

This commit is contained in:
Aprotim Sanyal 2018-10-18 00:56:29 -07:00
parent 56c216a3fd
commit a95b5bcb27
2 changed files with 7 additions and 0 deletions

View File

@ -65,3 +65,8 @@ header h1 {
#preview iframe { #preview iframe {
flex-grow: 1; flex-grow: 1;
} }
#options.badParse {
border-color: red;
background-color: #FEE
}

View File

@ -181,7 +181,9 @@ function checkForChanges() {
var optionsString = $optionsElem.value || '{}'; var optionsString = $optionsElem.value || '{}';
var newOptions = JSON.parse(optionsString); var newOptions = JSON.parse(optionsString);
options = newOptions; options = newOptions;
$optionsElem.classList.remove('badParse');
} catch (err) { } catch (err) {
$optionsElem.classList.add('badParse');
} }
var lexed = marked.lexer($markdownElem.value, options); var lexed = marked.lexer($markdownElem.value, options);