mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
ui: better ogp meta on problem_detail page
This commit is contained in:
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 {
|
||||
|
||||
Reference in new issue
Block a user