Merge pull request #898 from tidalcycles/fix-autocomplete

fix: autocomplete / tooltip code example bug
This commit is contained in:
Felix Roos 2024-01-10 13:55:39 +01:00 committed by GitHub
commit f768e1eece
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,12 @@ import jsdoc from '../../doc.json';
import { autocompletion } from '@codemirror/autocomplete'; import { autocompletion } from '@codemirror/autocomplete';
import { h } from './html'; import { h } from './html';
function plaintext(str) {
const div = document.createElement('div');
div.innerText = str;
return div.innerHTML;
}
const getDocLabel = (doc) => doc.name || doc.longname; const getDocLabel = (doc) => doc.name || doc.longname;
const getInnerText = (html) => { const getInnerText = (html) => {
var div = document.createElement('div'); var div = document.createElement('div');
@ -21,7 +27,7 @@ ${doc.description}
)} )}
</ul> </ul>
<div> <div>
${doc.examples?.map((example) => `<div><pre>${example}</pre></div>`)} ${doc.examples?.map((example) => `<div><pre>${plaintext(example)}</pre></div>`)}
</div> </div>
</div>`[0]; </div>`[0];
/* /*