较少式减价观众对于UNIX系统 [英] less-style markdown viewer for UNIX systems

查看:114
本文介绍了较少式减价观众对于UNIX系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JavaScript中的降价字符串,我想以显示它(有加粗等)在(或者,我想,更多) - 风格浏览器的命令行

I have a Markdown string in JavaScript, and I'd like to display it (with bolding, etc) in a less (or, I suppose, more)-style viewer for the command line.

例如,用字符串

"hello\n" + 
"_____\n" + 
"*world*!"

我想有输出弹出一个滚动内容,看起来像

I would like to have output pop up with scrollable content that looks like

全球

这是可能的,如果又如何?

Is this possible, and if so how?

推荐答案

Pandoc 可降价转换为groff的手册页。

Pandoc can convert Markdown to groff man pages.

这(感谢nenopera的评论)

This (thanks to nenopera's comment):

 pandoc -s -f markdown -t man foo.md | man -l -

应该做的伎俩。在 -s 选项告诉它来生成正确的页眉和页脚。

should do the trick. The -s option tells it to generate proper headers and footers.

有可能是其他的降价,于─* roff的转换器在那里; Pandoc恰好是第一个,我发现。

There may be other markdown-to-*roff converters out there; Pandoc just happens to be the first one I found.

另一种方法是在降价命令(的apt-get安装降价在Debian系统),它转换降价到HTML。例如:

Another alternative is the markdown command (apt-get install markdown on Debian systems), which converts Markdown to HTML. For example:

markdown README.md | lynx -stdin

(假设你有猞猁终端基于Web浏览器)。

(assuming you have the lynx terminal-based web browser).

或者(感谢丹尼的建议),你可以做这样的事情:

Or (thanks to Danny's suggestion) you can do something like this:

markdown README.md > README.html && xdg-open README.html

其中, XDG-打开(在某些系统上)打开在preferred应用程序指定的文件或网址。这将可能打开的README.html 在preferred GUI网页浏览器(这不正是式的少,但也可能是有用)。

where xdg-open (on some systems) opens the specified file or URL in the preferred application. This will probably open README.html in your preferred GUI web browser (which isn't exactly "less-style", but it might be useful).

这篇关于较少式减价观众对于UNIX系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆