Skip to content

Commit 87429c4

Browse files
committed
增加github
1 parent 1a8a51a commit 87429c4

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ markdownDownload(websiteConfigs.juejin, {
4242
```
4343

4444
## 已支持的网站
45+
[Github Issue](https://github.com/)
4546
[掘金](https://juejin.cn/)
4647
[知乎专栏](https://zhuanlan.zhihu.com/)
4748
[思否专栏](https://segmentfault.com/)

src/mathjax.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require('mathjax/es5/tex-svg')
2+
const tex2svg = (markdownDoc) => {
3+
return markdownDoc.replace(/<ztext>(.*?)<\/ztext>/g, (s, s1) => {
4+
const tex = decodeURIComponent(s1)
5+
const svg = MathJax.tex2svg(tex)
6+
svg.setAttribute('data-tex', tex)
7+
svg.style.display = 'inline'
8+
return svg.outerHTML
9+
})
10+
}
11+
Object.assign(module.exports, Object.assign(exports, {
12+
tex2svg
13+
}))

src/websites/github.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const hosts = ['github.com']
2+
3+
export const options = {
4+
origin: 'github',
5+
link: false,
6+
br: true,
7+
code: false,
8+
selectors: {
9+
title: '#partial-discussion-header .markdown-title',
10+
body: '.js-quote-selection-container .markdown-body',
11+
copyBtn: '.copy-btn',
12+
userName: '[data-hovercard-type="user"]',
13+
userLink: '[data-hovercard-type="user"]',
14+
invalid: '',
15+
unpack: '',
16+
tag: '.js-issue-labels .IssueLabel'
17+
}
18+
}
19+
20+
export const hook = {
21+
}
22+
23+
export const config = {
24+
hosts,
25+
options,
26+
hook
27+
}
28+
29+
export default config

src/websites/zhihu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { tex2svg } from '../utils'
21
export const hosts = ['zhuanlan.zhihu.com']
32

43
export const options = {
@@ -28,6 +27,7 @@ export const hook = {
2827
})
2928
},
3029
formatContent (context, { markdownDoc }) {
30+
const { tex2svg } = require('../mathjax')
3131
return tex2svg(markdownDoc)
3232
}
3333
}

0 commit comments

Comments
 (0)