Skip to content

替换中文题解中的 textit #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## version 2.17.8

- 替换中文题解中的 textit

## version 2.17.7

- filepath 格式可以保存在工作区,避免每次新环境还要配文件名
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "%main.description%",
"version": "2.17.7",
"version": "2.17.8",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
32 changes: 9 additions & 23 deletions src/controller/TreeViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,6 @@ class TreeViewController implements Disposable {
}

public async searchProblem(): Promise<void> {
if (!statusBarService.getUser()) {
promptForSignIn();
return;
}

const picks: Array<IQuickItemEx<string>> = [];
picks.push(
{
Expand All @@ -538,24 +533,19 @@ class TreeViewController implements Disposable {
// detail: `测试api`,
// value: `testapi`,
// }
// ,
// {
// label: `每日一题`,
// detail: `每日一题`,
// value: `today`,
// },
// {
// label: `查询自己竞赛信息`,
// detail: `查询自己竞赛信息`,
// value: `userContest`,
// }
);
const choice: IQuickItemEx<string> | undefined = await vscode.window.showQuickPick(picks, {
title: "选择查询选项",
});
if (!choice) {
return;
}

if (!statusBarService.getUser() && choice.value != "testapi") {
promptForSignIn();
return;
}

if (choice.value == "byid") {
await this.searchProblemByID();
} else if (choice.value == "range") {
Expand Down Expand Up @@ -637,14 +627,10 @@ class TreeViewController implements Disposable {
}

public async testapi(): Promise<void> {
if (!statusBarService.getUser()) {
promptForSignIn();
return;
}
try {
let problemInput = await getTextEditorFilePathByUri();
// vscode.window.showErrorMessage(twoFactor || "输入错误");
const solution: string = await executeService.getTestApi(problemInput || "");
let so = {};

const solution: string = JSON.stringify(so);
solutionService.show(solution);
} catch (error) {
logOutput.appendLine(error.toString());
Expand Down
10 changes: 9 additions & 1 deletion src/rpc/actionChain/chainNode/leetcode.cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,15 @@ function getSolutionBySlug(question_slug: string, articles_slug: string, lang: s
if (!solution) return reply.error("本题没有题解");

let link = URL_DISCUSS.replace("$slug", question_slug).replace("$articles_slug", articles_slug);
let content = solution.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t");
// let content = solution.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t");
let content = solution.content.replace(/\\n/g, "\n");

// content = content.replace(/\$\\textit/g, "$");
// content = content.replace(/\$\\texttt/g, "$");
// content = content.replace(/\$\\text/g, "$");
content = content.replace(/\\textit{/g, "{");
content = content.replace(/\\texttt{/g, "{");
content = content.replace(/\\text{/g, "{");

let solution_result: any = {};
solution_result.problem_name = solution.title;
Expand Down
6 changes: 3 additions & 3 deletions src/service/SolutionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class SolutionService extends BaseWebViewService {
);

// $\textit
this.solution.body = this.solution.body.replace(/\$\textit/g, "$");
this.solution.body = this.solution.body.replace(/\$\texttt/g, "$");
this.solution.body = this.solution.body.replace(/\$\text/g, "$");
// this.solution.body = this.solution.body.replace(/\$\\textit/g, "$");
// this.solution.body = this.solution.body.replace(/\$\\texttt/g, "$");
// this.solution.body = this.solution.body.replace(/\$\\text/g, "$");

const body: string = markdownService.render(this.solution.body, {
lang: this.solution.lang,
Expand Down