修复katex角标漂移等问题

This commit is contained in:
undefined committed 2020-06-24 11:47:43 +08:00
1 parent 1f1efe900c
commit a248425db6
17 files changed
+491 -235

No files matched your search

+15
View File
@@ -34,4 +34,19 @@ module.exports = {
console.error('Cannot hack yargs');
}
},
'markdown-it-katex': () => {
const p = require.resolve('markdown-it-katex');
const file = fs.readFileSync(p).toString().split('\n');
if (file[27].includes('if (prevChar === 0x20/* " " */ || prevChar === 0x09/* \\t */ ||')) {
file[27] = 'if (prevChar === 0x09/* \\t */ ||';
} else if (!file[27].includes('if (prevChar === 0x09/* \\t */ ||')) {
console.error('Cannot hack markdown-it-katex');
}
if (file[31].includes('if (nextChar === 0x20/* " " */ || nextChar === 0x09/* \\t */) {')) {
file[31] = 'if (nextChar === 0x09/* \\t */) {';
} else if (!file[27].includes('if (nextChar === 0x09/* \\t */) {')) {
console.error('Cannot hack markdown-it-katex');
}
fs.writeFileSync(p, file.join('\n'));
},
};
+1 -1
View File
@@ -279,7 +279,7 @@ class ProblemEditHandler extends ProblemManageHandler {
async post({ domainId, title, content }) {
const pid = validator.checkPid(this.request.body.pid);
const pdoc = await problem.get(domainId, this.params.pid);
const pdoc = await problem.get(domainId, this.request.params.pid);
await problem.edit(domainId, pdoc.docId, { title, content, pid });
this.response.redirect = `/p/${pid}`;
}
+3 -2
View File
@@ -5,6 +5,7 @@ const fs = require('fs');
const os = require('os');
const path = require('path');
const download = require('./download');
const { folderSize } = require('../utils');
function root(name) {
return path.resolve(process.cwd(), name);
@@ -43,12 +44,12 @@ async function getDetail() {
const info = `${os.tmpdir()}/hydro/tmp/${file}/hydro.json`;
if (fs.existsSync(info)) {
const i = JSON.parse(fs.readFileSync(info).toString());
const f = fs.statSync(info);
const size = folderSize(`${os.tmpdir()}/hydro/tmp/${file}`);
modules.push({
id: i.id,
version: i.version,
description: i.description,
size: f.size,
size,
});
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ const md = MarkdownIt();
const Prism = require('prismjs');
// For math: $a\times b\eq 10$
const katex = require('markdown-it-katex');
const katex = require('@hydrooj/markdown-it-katex');
// Specific image size: ![image](image.png =100x100)
const Imsize = require('markdown-it-imsize');
/* Footnote support.
+1 -1
View File
@@ -52,7 +52,7 @@ perm.PERM_ALL = PERM_ALL;
const Permission = (family, key, desc) => ({ family, key, desc });
const PERMS = [
Permission('perm_general', perm.PERM_MANAGE, 'Manage the system'),
Permission('perm_general', perm.PERM_MANAGE, 'Manage domain'),
Permission('perm_general', perm.PERM_MOD_BADGE, 'Show MOD badge'),
Permission('perm_problem', perm.PERM_CREATE_PROBLEM, 'Create problems'),
Permission('perm_problem', perm.PERM_EDIT_PROBLEM, 'Edit problems'),
+1
View File
@@ -133,6 +133,7 @@ class Handler {
files: ctx.request.files,
query: ctx.query,
path: ctx.path,
params: ctx.params,
referer: ctx.request.headers.referer || '/',
};
this.response = {
+32
View File
@@ -1,3 +1,5 @@
const fs = require('fs');
const path = require('path');
const superagent = require('superagent');
const proxy = require('superagent-proxy');
@@ -72,3 +74,33 @@ Set.intersection = function Intersection(setA, setB) {
}
return intersection;
};
/**
* calculate size of a file or directory synchronously
* @param {String} folderPath path of the file or folder
* @param {fsizeOptions} opts additional options
* @returns {Number}
*/
function folderSize(folderPath) {
let size = 0;
const _next = function a(p) {
if (p) {
const stats = fs.statSync(p);
if (!stats.isDirectory() || stats.isSymbolicLink()) {
if (!stats.isSymbolicLink()) size += stats.size;
} else {
size += stats.size;
const files = fs.readdirSync(p);
if (Array.isArray(files)) {
files.forEach((file) => {
_next(path.join(p, file));
});
}
}
}
};
_next(folderPath);
return size;
}
exports.folderSize = folderSize;
+3 -1
View File
@@ -415,6 +415,7 @@ My Files: 我的文件
My Profile: 我的资料
My Recent Submissions: 我的最近递交记录
My Role: 我的角色
name: 名称
Name: 名称
Network error: 网络错误
Never expire: 从不过期
@@ -605,6 +606,7 @@ Set Roles for Selected User: 设置所选用户的角色
Set Roles for selected users: 为所选用户设置角色
setting_customize: 个性化
setting_display: 显示偏好
setting_domain: 域设置
setting_info_domain: 个人信息
setting_info: 个人信息
setting_privacy: 隐私
@@ -769,7 +771,7 @@ What's script?: 什么是脚本?
What's this?: 这是什么?
Whether to show tags in the problem list.: 是否在题目列表中显示题目的标签。
wiki_help: 帮助
Will be used as the system icon.: 将被用作系统图标。
Will be used as the domain icon.: 将被用作系统图标。
With this feature, you can copy problems that you can view from a domain to some other domain. Their title, content, tags and categories will be copied. However, their test data are not copied directly.: 您可以通过这个功能将某域下您能查看的题目复制到其它域中,题目的标题、描述、标签与分类将被复制过来。但是测试数据不会被直接复制。
Write Your Comment: 发表您的评论
Write Your Solution: 发表您的题解
+1 -1
View File
@@ -546,7 +546,7 @@ WeChat: 微信
What is domain?: 什麼是域?
What's domain?: 什麼是域?
Whether to show tags in the problem list.: 是否在題目列表中顯示題目的標籤。
Will be used as the system icon.: 將被用作圖示。
Will be used as the domain icon.: 將被用作圖示。
Without slashes or backslashes: 不含斜槓和反斜槓
Write Your Comment: 發表您的評論
Write Your Solution: 發表您的題解
+2 -2
View File
@@ -6,6 +6,7 @@
"author": "masnn",
"license": "GPL-3.0-only",
"dependencies": {
"@hydrooj/markdown-it-katex": "^2.1.0",
"adm-zip": "^0.4.14",
"ansi_up": "^4.0.4",
"bson": "^4.0.2",
@@ -23,7 +24,6 @@
"markdown-it-container": "^3.0.0",
"markdown-it-footnote": "^3.0.2",
"markdown-it-imsize": "^2.0.1",
"markdown-it-katex": "^2.0.3",
"markdown-it-mark": "^3.0.0",
"markdown-it-table-of-contents": "^0.4.4",
"moment-timezone": "^0.5.31",
@@ -64,4 +64,4 @@
]
},
"snyk": true
}
}
-1
View File
@@ -1,4 +1,3 @@
{# No Compression #}
<!DOCTYPE html>
<html>
<head>
-1
View File
@@ -1,4 +1,3 @@
{# No Compression #}
{% macro form_begin(args) %}
{% set label = args.label %}
{% set columns = args.columns %}
-1
View File
@@ -1,4 +1,3 @@
{# No Compression #}
{% extends "layout/basic.html" %}
{% block content %}
<div class="row">
+1 -5
View File
@@ -1,10 +1,6 @@
{% extends "domain_base.html" %}
{% block domain_content %}
<div class="section">
<div class="section__body">
<form method="post">
{% include "partials/setting.html" with context %}
</form>
</div>
{% include "partials/setting.html" %}
</div>
{% endblock %}
+16 -16
View File
@@ -5,10 +5,10 @@
"private": true,
"license": "AGPL-1.0",
"devDependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/cli": "^7.10.3",
"@babel/core": "^7.10.3",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-decorators": "^7.10.1",
"@babel/plugin-proposal-decorators": "^7.10.3",
"@babel/plugin-proposal-export-namespace-from": "^7.10.1",
"@babel/plugin-proposal-function-sent": "^7.10.1",
"@babel/plugin-proposal-json-strings": "^7.10.1",
@@ -16,26 +16,26 @@
"@babel/plugin-proposal-throw-expressions": "^7.10.1",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/plugin-transform-runtime": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@babel/preset-react": "^7.10.1",
"@babel/register": "^7.10.1",
"autoprefixer": "^9.8.0",
"@babel/register": "^7.10.3",
"autoprefixer": "^9.8.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.6",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-prismjs": "^2.0.1",
"chalk": "^4.1.0",
"copy-webpack-plugin": "^6.0.2",
"css-loader": "^3.5.3",
"css-loader": "^3.6.0",
"del": "^5.1.0",
"eslint": "^7.2.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-import-resolver-webpack": "^0.12.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-loader": "^4.0.2",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.0",
"file-loader": "^6.0.0",
"friendly-errors-webpack-plugin": "^1.7.0",
@@ -56,18 +56,18 @@
"style-loader": "^1.2.1",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"through2": "^3.0.1",
"through2": "^3.0.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"vinyl-buffer": "^1.0.1",
"webpack": "^4.43.0",
"yargs": "^15.3.1"
},
"dependencies": {
"@babel/runtime-corejs2": "^7.10.2",
"@babel/runtime-corejs2": "^7.10.3",
"base-64": "^0.1.0",
"classnames": "^2.2.6",
"clipboard": "^2.0.4",
"codemirror": "^5.54.0",
"codemirror": "^5.55.0",
"diff-dom": "^4.1.3",
"emojify.js": "^1.1.0",
"fancy-log": "^1.3.3",
@@ -78,7 +78,7 @@
"katex": "^0.11.1",
"lodash": "^4.17.13",
"mini-css-extract-plugin": "^0.9.0",
"moment": "^2.26.0",
"moment": "^2.27.0",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"pickadate": "^3.6.4",
@@ -103,7 +103,7 @@
"tether-drop": "^1.4.2",
"timeago-react": "^3.0.0",
"timeago.js": "^4.0.2",
"uuid": "^8.1.0",
"uuid": "^8.2.0",
"vj-simplemde": "0.0.8"
},
"scripts": {
+401 -184
View File
File diff suppressed because it is too large. Load diff
+13 -18
View File
@@ -23,6 +23,13 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
"@hydrooj/markdown-it-katex@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@hydrooj/markdown-it-katex/-/markdown-it-katex-2.1.0.tgz#6f7bddafff876327359bd41069767793ff7bd964"
integrity sha512-17b6Vd6ZNzRFkz3BKf+je2xJBfDhFYV46TbBwrpS6CGflIV2X41zv+a9n2/Sidn9E9JSYeEMtmVkM8jQx1HpKA==
dependencies:
katex "^0.11.1"
"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
@@ -1282,7 +1289,7 @@ combined-stream@^1.0.8:
dependencies:
delayed-stream "~1.0.0"
commander@^2.20.0:
commander@^2.19.0, commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
@@ -3084,12 +3091,12 @@ jszip@^3.2.2:
readable-stream "~2.3.6"
set-immediate-shim "~1.0.1"
katex@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/katex/-/katex-0.6.0.tgz#12418e09121c05c92041b6b3b9fb6bab213cb6f3"
integrity sha1-EkGOCRIcBckgQbazuftrqyE8tvM=
katex@^0.11.1:
version "0.11.1"
resolved "https://registry.yarnpkg.com/katex/-/katex-0.11.1.tgz#df30ca40c565c9df01a466a00d53e079e84ffaa2"
integrity sha512-5oANDICCTX0NqYIyAiFCCwjQ7ERu3DQG2JFHLbYOf+fXaMoH8eg/zOq5WSYJsKMi/QebW+Eh3gSM+oss1H/bww==
dependencies:
match-at "^0.1.0"
commander "^2.19.0"
keygrip@~1.1.0:
version "1.1.0"
@@ -3450,13 +3457,6 @@ markdown-it-imsize@^2.0.1:
resolved "https://registry.yarnpkg.com/markdown-it-imsize/-/markdown-it-imsize-2.0.1.tgz#cca0427905d05338a247cb9ca9d968c5cddd5170"
integrity sha1-zKBCeQXQUziiR8ucqdloxc3dUXA=
markdown-it-katex@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/markdown-it-katex/-/markdown-it-katex-2.0.3.tgz#d7b86a1aea0b9d6496fab4e7919a18fdef589c39"
integrity sha1-17hqGuoLnWSW+rTnkZoY/e9YnDk=
dependencies:
katex "^0.6.0"
markdown-it-mark@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/markdown-it-mark/-/markdown-it-mark-3.0.0.tgz#27c3e39ef3cc310b2dde5375082c9fa912983cda"
@@ -3478,11 +3478,6 @@ markdown-it@^11.0.0:
mdurl "^1.0.1"
uc.micro "^1.0.5"
match-at@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/match-at/-/match-at-0.1.1.tgz#25d040d291777704d5e6556bbb79230ec2de0540"
integrity sha512-h4Yd392z9mST+dzc+yjuybOGFNOZjmXIPKWjxBd1Bb23r4SmDOsk2NYCU2BMUBGbSpZqwVsZYNq26QS3xfaT3Q==
md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"