ui: select closest sample output (#634)

This commit is contained in:
panda authored and GitHub committed 2023-08-06 10:18:54 +08:00
1 parent 20fe72a708
commit 45c5642db3
1 file changed
+2 -1
@@ -17,12 +17,13 @@ const highlighterPage = new AutoloadPage('highlighterPage', () => {
$container.find('pre code').get().forEach((code) => {
const $code = $(code);
const $root = $code.parent().parent();
const $typo = $code.closest('.typo');
const language = ($(code).attr('class') || '').trim();
const m = language.match(/language-input([0-9]+)/);
if (m?.[1]) {
const id = +m[1];
if (Number.isSafeInteger(id)) {
const $output = $container.find(`pre.language-output${id}`);
const $output = ($typo.length ? $typo : $container).find(`pre.language-output${id}`);
if ($output.length) {
const $c = $(document.createElement('div')).addClass('row');
$root.after($c);