Skip to content
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

能否提供将 markdown 转换成 html 的API? #123

Open
hasbai opened this issue Jan 27, 2022 · 14 comments
Open

能否提供将 markdown 转换成 html 的API? #123

hasbai opened this issue Jan 27, 2022 · 14 comments
Labels
enhancement New feature or request

Comments

@hasbai
Copy link

hasbai commented Jan 27, 2022

No description provided.

@yanglbme
Copy link
Member

目前没有哈

@yanglbme yanglbme added the enhancement New feature or request label Jan 29, 2022
@wll8
Copy link
Collaborator

wll8 commented Feb 12, 2022

如果你需要获取转换后的 html ,目前平台上的【导出HTML页面】是否满足?如果不是,请描述一下期望的功能。

@chenxizhang
Copy link

我也想要用这个API,就是说,目前https://doocs.github.io/md/ 这里提供的用户界面很漂亮,复制得到的文本也确实符合需求,但我们有一些场景是希望自动化来发布文章,不是人工复制粘贴的,也不会在这个编辑器里面直接编辑。那么,此时如果有一个API可以直接调用,就很酷了。输入是 markdown,输出的公众号能接受的东西就可以了。 @yanglbme 能否考虑一下

@wll8
Copy link
Collaborator

wll8 commented May 11, 2024

以一个 exe 文件方式提供是否接受?

@chenxizhang
Copy link

以一个 exe 文件方式提供是否接受?

完全可以的,如果能分享一下大致怎么做,我甚至可以帮忙做。我很熟悉自动化脚本这块 。 @wll8

@wll8
Copy link
Collaborator

wll8 commented May 11, 2024

该 exe 使用 webview 框架加载 https://doocs.github.io/md/ 页面,exe 自动读取需要发布的 markdown 加载到页面中,然后调用页面 api 输出 html 到本地或其他逻辑。预计 exe 体积 2M 以内。

@chenxizhang
Copy link

@wll8 能否分享一下这个exe? 所以,用户其实不需要手工去打开浏览器,而是直接运行这个exe,传入必要的参数(markdown文本),然后就可以得到渲染后的html对吧。

@wll8
Copy link
Collaborator

wll8 commented May 11, 2024

exe 有,但保存 html 为文件的逻辑还没有。我开发 exe 框架和逻辑,你可以参与吗?只需要使用 js 脚本模拟点击元素获取 html 保存到本地即可。

@chenxizhang
Copy link

exe 有,但保存 html 为文件的逻辑还没有。我开发 exe 框架和逻辑,你可以参与吗?只需要使用 js 脚本模拟点击元素获取 html 保存到本地即可。

好的啊,我很乐意参与。

@wll8
Copy link
Collaborator

wll8 commented May 11, 2024

ok,我现在搭建项目,大概1小时不到即可完成,然后会把代码仓库发到这里,稍等。

@wll8
Copy link
Collaborator

wll8 commented May 11, 2024

仓库地址: https://github.com/wll8/doocs-md-2-html

可能你重点补充这个逻辑即可:

/**
 * 读取本地 markdown 文本并设置到 md 区域
 */
async function setText(path = `./readme.md`) {
  const [, res] = await native.string.load(path)
  console.log(`todo`, this.name, res)
}


/**
 * 读取渲染好的 html 保存到文件
 */
async function getHtml() {
  const html = `${Date.now()}`
  await native.string.save(`./out.html`, html)
}

@chenxizhang
Copy link

仓库地址: https://github.com/wll8/doocs-md-2-html

可能你重点补充这个逻辑即可:

/**
 * 读取本地 markdown 文本并设置到 md 区域
 */
async function setText(path = `./readme.md`) {
  const [, res] = await native.string.load(path)
  console.log(`todo`, this.name, res)
}


/**
 * 读取渲染好的 html 保存到文件
 */
async function getHtml() {
  const html = `${Date.now()}`
  await native.string.save(`./out.html`, html)
}

好的,我处理完手头的一点事情,马上就看一下

@chenxizhang
Copy link

@wll8 感谢你的分享,我研究了一下你的那个工具。有几个反馈

  1. 你的意思是不是我在那个preload.js中去模拟输入,然后去点击那个”复制“按钮?
  2. 我想问一下,这个exe 运行时是否还支持传入其他自定义参数,而且在脚本中能读取到?
  3. 它运行时打开的那个浏览器窗口能否隐身,以及如何关闭呢?

image

@wll8
Copy link
Collaborator

wll8 commented May 11, 2024

  1. 对于要如何操作页面元素,看你以怎么样的方式实现,对于自动化脚本方面,使用 js 是完全模拟点击/输入的。建议可以使用 js 实现。

  2. exe 运行时可以传入其他参数,包括:

    • webview 启动参数
    • exe 配置等
    • 详细参数参考这里,不过对于此功能应该用不到这些参数。
    • 当然,在 preload.js 中,你是可以使用 string.load 来读取你的任意文件的参数内容的。
    • 使用 await main.nativeMain.G api 来读取当前程序所加载的配置项
  3. exe 提供了操作系统相关的 api, 例如:

    • 可以使用 main.nativeMain.win.quitMessage() api 来退出程序。
    • 可以使用 main.nativeMain.win.show(main.hwnd, false) api 来隐藏程序。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants