forked from emacs-lsp/lsp-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsp-ui-doc.html
52 lines (45 loc) · 1.63 KB
/
lsp-ui-doc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/default.min.css">
<style>
:root {
--webkit-max-width-px: 600px;
}
.markdown-body {
box-sizing: border-box;
min-width: var(--webkit-max-width-px);
max-width: var(--webkit-max-width-px);
margin: 0 auto;
padding: 10px;
}
.markdown-body pre code {
white-space: pre-wrap;
}
</style>
</head>
<body>
<div id="lsp-ui-webkit" class="markdown-body">
</div>
<script>
var converter = new showdown.Converter({simpleLineBreaks: true});
var lastSymbol = "";
var elem = document.getElementById('lsp-ui-webkit');
function renderMarkdown(symbol, markedString) {
if (symbol == lastSymbol) return [elem.offsetWidth, elem.offsetHeight];
decodedString = decodeURIComponent(markedString);
html = converter.makeHtml(decodedString);
elem.innerHTML = html;
lastSymbol = symbol;
document.querySelectorAll('pre code').forEach(function(codeBlock) {
hljs.highlightBlock(codeBlock);
});
return [elem.offsetWidth, elem.offsetHeight];
}
</script>
</body>
</html>