Skip to content

Commit

Permalink
typings: bump marked version
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 15, 2022
1 parent 0368272 commit 1377d57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/frontend/manager/client/components/k-markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script lang="ts" setup>
import marked from 'marked'
import { marked } from 'marked'
defineProps({
source: String,
Expand Down
4 changes: 3 additions & 1 deletion plugins/frontend/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"@koishijs/plugin-console": "^1.0.0",
"@octokit/openapi-types": "^11.2.0",
"@types/cross-spawn": "^6.0.2",
"@types/throttle-debounce": "^2.1.0"
"@types/marked": "^4.0.1",
"@types/throttle-debounce": "^2.1.0",
"marked": "^4.0.10"
},
"dependencies": {
"cross-spawn": "^7.0.3",
Expand Down
8 changes: 4 additions & 4 deletions plugins/github/src/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { segment } from 'koishi'
import marked, { Token, lexer } from 'marked'
import { marked } from 'marked'

declare module 'marked' {
namespace Tokens {
Expand All @@ -13,7 +13,7 @@ declare module 'marked' {
}
}

function renderToken(token: Token) {
function renderToken(token: marked.Token) {
if (token.type === 'code') {
return token.text + '\n'
} else if (token.type === 'paragraph') {
Expand All @@ -26,11 +26,11 @@ function renderToken(token: Token) {
return token.raw
}

function render(tokens: Token[]) {
function render(tokens: marked.Token[]) {
return tokens.map(renderToken).join('')
}

export function transform(source: string) {
source = source.replace(/^<!--(.*)-->$/gm, '')
return render(lexer(source)).trim().replace(/\n\s*\n/g, '\n')
return render(marked.lexer(source)).trim().replace(/\n\s*\n/g, '\n')
}

0 comments on commit 1377d57

Please sign in to comment.