Skip to content

Commit 044867b

Browse files
committed
fix: convert html to markdown.
1 parent 591163d commit 044867b

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,14 @@
148148
"nanoid": "^3.1.20",
149149
"react": "^17.0.0",
150150
"react-dom": "^17.0.0",
151-
"styled-components": "^5.2.1"
151+
"styled-components": "^5.2.1",
152+
"turndown": "^7.0.0"
152153
},
153154
"devDependencies": {
154155
"@svgr/webpack": "^5.5.0",
155156
"@types/react": "^16.9.53",
156157
"@types/react-dom": "^16.9.8",
158+
"@types/turndown": "^5.0.0",
157159
"@typescript-eslint/eslint-plugin": "^3.0.2",
158160
"@typescript-eslint/parser": "^3.0.2",
159161
"babel-plugin-styled-components": "^1.12.0",

src/extension.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'module-alias/register';
22
import * as vscode from 'vscode';
3+
import * as TurndownService from 'turndown';
34

45
import { uriHandler, CodingServer } from 'src/codingServer';
56
import { Panel } from 'src/panel';
@@ -45,6 +46,7 @@ export async function activate(context: vscode.ExtensionContext) {
4546
showCollapseAll: true,
4647
});
4748

49+
const tdService = new TurndownService();
4850
const commentController = vscode.comments.createCommentController(
4951
'mr-comment',
5052
'Merge request diff comments',
@@ -236,11 +238,11 @@ export async function activate(context: vscode.ExtensionContext) {
236238
const lineNum = isLeft ? rootLine.leftNo : rootLine.rightNo;
237239
const range = new vscode.Range(lineNum, 0, lineNum, 0);
238240
const commentList: vscode.Comment[] = i.map((c) => {
239-
const body = new vscode.MarkdownString(`${c.content}`);
241+
const body = new vscode.MarkdownString(tdService.turndown(c.content));
240242
body.isTrusted = true;
241243
const comment: vscode.Comment = {
242244
mode: vscode.CommentMode.Preview,
243-
body: c.content,
245+
body,
244246
author: {
245247
name: `${c.author.name}(${c.author.global_key})`,
246248
iconPath: vscode.Uri.parse(c.author.avatar, false),

yarn.lock

+17
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,11 @@
14451445
dependencies:
14461446
"@types/node" "*"
14471447

1448+
"@types/turndown@^5.0.0":
1449+
version "5.0.0"
1450+
resolved "https://registry.yarnpkg.com/@types/turndown/-/turndown-5.0.0.tgz#2b763b36f783e4e237cea62cdc8f8592b72b9285"
1451+
integrity sha512-Y7KZn6SfSv1vzjByJGijrM9w99HoUbLiAgYwe+sGH6RYi5diIGLYOcr4Z1YqR2biFs9K5PnxKv/Fbkmh57pvzg==
1452+
14481453
"@typescript-eslint/eslint-plugin@^3.0.2":
14491454
version "3.10.1"
14501455
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz#7e061338a1383f59edc204c605899f93dc2e2c8f"
@@ -3138,6 +3143,11 @@ domelementtype@^2.0.1:
31383143
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.1.0.tgz#a851c080a6d1c3d94344aed151d99f669edf585e"
31393144
integrity sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==
31403145

3146+
domino@^2.1.6:
3147+
version "2.1.6"
3148+
resolved "https://registry.yarnpkg.com/domino/-/domino-2.1.6.tgz#fe4ace4310526e5e7b9d12c7de01b7f485a57ffe"
3149+
integrity sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==
3150+
31413151
domutils@^1.7.0:
31423152
version "1.7.0"
31433153
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"
@@ -7295,6 +7305,13 @@ tunnel-agent@^0.6.0:
72957305
dependencies:
72967306
safe-buffer "^5.0.1"
72977307

7308+
turndown@^7.0.0:
7309+
version "7.0.0"
7310+
resolved "https://registry.yarnpkg.com/turndown/-/turndown-7.0.0.tgz#19b2a6a2d1d700387a1e07665414e4af4fec5225"
7311+
integrity sha512-G1FfxfR0mUNMeGjszLYl3kxtopC4O9DRRiMlMDDVHvU1jaBkGFg4qxIyjIk2aiKLHyDyZvZyu4qBO2guuYBy3Q==
7312+
dependencies:
7313+
domino "^2.1.6"
7314+
72987315
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
72997316
version "0.14.5"
73007317
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"

0 commit comments

Comments
 (0)