diff --git a/ui/src/SyntaxResult.js b/ui/src/SyntaxResult.js index 7b6317f0..f937f4e2 100644 --- a/ui/src/SyntaxResult.js +++ b/ui/src/SyntaxResult.js @@ -14,12 +14,34 @@ export default function SyntaxResult({ content, status }) { const handleChangePage = (_, newPage) => { setPage(newPage); - }; + }; useEffect(() => { setRows(content.slice(page * 10, page * 10 + 10)) }, [page, content]); + function renderMessage(error_instance, numWhitespace, numHighlight) { + const beforeHighlight = error_instance.substring(0, numWhitespace); + const highlightedChar = error_instance.substring(numWhitespace, numWhitespace + numHighlight); + const afterHighlight = error_instance.substring(numWhitespace + numHighlight); + return ( + + {beforeHighlight} + + {highlightedChar} + + {afterHighlight} + + ); + }; + return ( { rows.length ? rows.map(item => { + const msg_parts = item.msg.split('\n'); + const [_, numWhitespace, numHighlight] = msg_parts[msg_parts.length -1].match(/(\s*)(\^+)/).map(s => s.length); + const error_instance = msg_parts[msg_parts.length - 2]; + + const errorMessage = renderMessage( + error_instance, + numWhitespace, + numHighlight + ); + + return } defaultExpandIcon={}> {(item.error_type || 'syntax_error').replace('_', ' ')}}> @@ -61,7 +97,8 @@ export default function SyntaxResult({ content, status }) { {item.column} {item.msg.split('\n').slice(0, -2).join('\n')} - {item.msg.split('\n').slice(-2).join('\n')} +
{} + {errorMessage}