diff --git a/src/app/static/ws_listener.js b/src/app/static/ws_listener.js index 9e19225..5f69055 100644 --- a/src/app/static/ws_listener.js +++ b/src/app/static/ws_listener.js @@ -1,5 +1,9 @@ let ws = new WebSocket('ws://' + document.location.host + '/ws'); +let converter = new showdown.Converter(); + +hljs.initHighlightingOnLoad(); + $('#container').on('click', '.anchor', ( function (event) { let anchorName = $(this).attr('id').replace('_event', ''); @@ -37,5 +41,15 @@ ws.onopen = function () { ws.onmessage = function (messageEvent) { let message = JSON.parse(messageEvent.data); - $('#' + message['anchor']).text(message['data']); + console.log('Receiving: '); + console.log(message); + let $anchor = $('#' + message['anchor']); + if (message['anchor'] === 'anchor_webide') { + let code = hljs.highlightAuto(message['data']); + $anchor.html(code.value); + } + else { + let formatted_message = converter.makeHtml(message['data']); + $anchor.html(formatted_message); + } }; \ No newline at end of file