admin管理员组

文章数量:1638921

Atom 是一款不错的编辑器,插件多的几乎能覆盖你的想象。
Markdown-pdf 是 Atom 的一个插件,作用是将 markdown 转换为 pdf 文件。
当我们按照好该插件后,一般来说还不能直接使用,因为其依赖 phantomjs ,在不按照 phantomjs 的情况下,直接对 markdown 进行 pdf 转换,你可能会遇到下面这个图片的错误:

在提示中可以看到缺少 phantomjs 下面进行安装:
去官网 http://phantomjs/download.html 手动下载安装包(建议用迅雷下载会比较快一些)
然后将下载的文件 phantomjs-2.1.1-windows.zip (版本号下载最新的就行),放置缓存位置 C:\Users\Administrator\AppData\Local\Temp\phantomjs (根据自己路径放置)。

然后打开 cmd 窗口,执行 npm install phantomjs-prebuilt 即可完成安装,如下所示:

C:\Users\Administrator>npm install phantomjs-prebuilt
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated

> phantomjs-prebuilt@2.1.16 install C:\Users\Administrator\node_modules\phantomjs-prebuilt
> node install.js

PhantomJS not found on PATH
Download already available at C:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip
Verified checksum of previously downloaded file
Extracting zip contents
Removing C:\Users\Administrator\node_modules\phantomjs-prebuilt\lib\phantom
Copying extracted folder C:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip-extract-1572884268064\phantomjs-2.1.1-windows -> C:\Users\Administrator\node_modules\phantomjs-prebuilt\lib\phantom
Writing location.js file
Done. Phantomjs binary available at C:\Users\Administrator\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Administrator\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Administrator\package.json'
npm WARN Administrator No description
npm WARN Administrator No repository field.
npm WARN Administrator No README data
npm WARN Administrator No license field.

+ phantomjs-prebuilt@2.1.16
updated 1 package and audited 381 packages in 2.213s
found 0 vulnerabilities

命令执行成功后,如果你的 Atom 是打开的,记得关闭重新打开一下。
然后就可以执行 md 转换 pdf 了,生成的 pdf 文件和你的 md 文件在一起(转换之前你需要先保存你的文件内容为 md 文件)。

PS:使用 npm 命令需要你先安装和配置 nodejs,这个自己百度一下很简单。


(END)

本文标签: 插件错误MarkdownPDFAtom