ui: better ogp meta on problem_detail page

This commit is contained in:
undefined committed 2025-02-15 20:41:50 +08:00
1 parent eaa38c6ba5
commit 1bd8ef5076
7 files changed
+39 -4

No files matched your search

@@ -1,5 +1,6 @@
import * as status from '@hydrooj/common/status';
import { findFileSync } from '@hydrooj/utils/lib/utils';
import { convert } from 'html-to-text';
import {
avatar, Context, fs, PERM, PRIV, STATUS, yaml,
} from 'hydrooj';
@@ -94,6 +95,14 @@ class Nunjucks extends nunjucks.Environment {
}
return ensureTag(html ? xss.process(s) : markdown.render(s));
});
this.addFilter('problemPreview', (html) => {
const res = convert(html, {
selectors: [
{ selector: 'math', format: 'skip' },
],
});
return res.split('\n').map((i) => i.trim()).join('\n').replace(/\n+/g, '\n');
});
this.addFilter('contentLang', (content) => {
let s: any = '';
try {