Marked
Marked 是一款 macOS Markdown 预览应用。Protocol Launcher 允许你为 Marked 生成深度链接。
使用方式
提供两种使用方式:
- 按需加载(通过子路径导入),支持 Tree Shaking,体积更小。
- 全量导入(从根包导入),使用简单,但会包含所有应用模块。
生产环境建议使用按需加载以减小体积;快速脚本或演示可选择全量导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
URL 方法
以下 helper 严格对应 Marked 官方文档中列出的命令和参数。
添加自定义样式
ts
import { addStyle } from 'protocol-launcher/marked'
const cssUrl = addStyle({
name: 'My new style',
css: 'body { color: red; }',
})
const fileUrl = addStyle({
file: '/Users/myuser/Custom Styles/Unicorn.css',
})设置 Defaults
ts
import { defaults } from 'protocol-launcher/marked'
const url = defaults({
syntaxHighlight: 1,
includeMathJax: 0,
})
const noRefreshUrl = defaults({
syntaxHighlight: 1,
refresh: 0,
})运行 JavaScript
ts
import { runJavaScript } from 'protocol-launcher/marked'
const url = runJavaScript({
js: 'Marked.file.refresh()',
})
const pathUrl = runJavaScript({
path: 'filename1/filename2',
syntax: 'path',
js: 'Marked.file.refresh()',
})打开帮助
ts
import { help } from 'protocol-launcher/marked'
const pageUrl = help({
page: 'Document_Statistics',
})
const pathUrl = help({
path: 'Keyword_Highlighting:editingkeywords',
syntax: 'path',
})打开文档
ts
import { open } from 'protocol-launcher/marked'
const fileUrl = open({
file: '/Users/username/Desktop/report.md',
})
const pathUrl = open({
path: '~/nvALT2.2',
syntax: 'path',
})
const directPathUrl = open({
path: '/Users/username/Desktop/report.md',
syntax: 'direct',
})
const raiseUrl = open({
file: 'filename.md',
raise: true,
})预览剪贴板
ts
import { paste } from 'protocol-launcher/marked'
const url = paste()预览文本
ts
import { preview } from 'protocol-launcher/marked'
const url = preview({
text: 'Some text to preview\n',
})刷新预览
ts
import { refresh } from 'protocol-launcher/marked'
const allUrl = refresh()
const fileUrl = refresh({
file: '/Users/username/Desktop/report.md',
})
const explicitAllUrl = refresh({
file: 'all',
})
const pathUrl = refresh({
path: 'filename1/filename2',
syntax: 'path',
})设置预览样式
ts
import { style } from 'protocol-launcher/marked'
const url = style({
css: 'Github',
})
const fileUrl = style({
file: 'filename1,filename2',
css: 'Github',
})
const pathUrl = style({
path: 'all',
syntax: 'path',
css: 'Github',
})