• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

seth-brown/formd: A Markdown formatting tool

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

seth-brown/formd

开源软件地址(OpenSource Url):

https://github.com/seth-brown/formd

开源编程语言(OpenSource Language):

TypeScript 85.3%

开源软件介绍(OpenSource Introduction):

formd: a markdown formatting tool

Build Status

formd is a CLI tool for (for)matting (m)ark(d)own that allows interconversion between the two styles of Markdown links, inline and referenced. The tool conforms to the Github Flavored Markdown spec.

Installation

npm install -g @seth-brown/formd

If the default location npm installs packages to isn't in your path, you may need to add it to your path. For example:

echo 'export PATH="$HOME/.node/bin:$PATH"' >> ~/.zshrc

Motivation

Inline Markdown is difficult to read, but useful for writing and editing because the linked text and URLs are adjacent to the words you are writing. For example:

The quick brown [fox](http://en.wikipedia.org/wiki/Fox) jumped over the lazy [dog](http://en.wikipedia.org/wiki/Dog).

Referenced Markdown is awkward while writing because it requires jumping between links within the text and the reference section of the document. However, referenced Markdown is the superior syntax for reading because URLs do not breakup the flow of words or sentences. For example:

The quick brown [fox][1] jumped over the lazy [dog][2].

formd provides the best of both worlds by allowing users to quickly toggle Markdown formats between inline while writing and referenced while reading. formd reads and writes to standard streams, so it can be adapted to a wide-range of user workflows.

Usage

formd is a command line tool, but its primary use case is with text editors or in conjunction with system tools like snipper expanders or app launchers. From the command line formd can be used as follows:

For help:

formd -h

To generate referenced Markdown use the -r flag:

formd -r < <(echo "a line of text\na link with a [link]('www.foo.com')")

To generate inline Markdown use the -i flag:

cat my-markdown.md | formd -i

Usage with Text Editors

formd can be integrated with editors like Vim. The easiest option is to call it directly from within a Vim buffer. For example:

:%! formd -r

An easier approach is to use a function to execute formd and return the cursor back to it's original position within the buffer.

" a function to execute `formd` and return the cursor back
" to it's original position within the buffer. 
" This script assumes `formd` is in your path. 
function! Formd(option)
    :let save_view = winsaveview()
    :let flag = a:option
    :if flag == "-i"
        :%! formd -i
    :else
        :%! formd -r
    :endif
    :call winrestview(save_view)
endfunction
 
" formd mappings 
nmap <leader>fr :call Formd("-r")<CR>
nmap <leader>fi :call Formd("-i")<CR>

Usage with App Launchers

formd can be invoked with app launchers like Alfred. Two Alfred workflows are provided in the repo at system/alfred/. These workflows take the contents from the clipboard and covert them to either inline or reference markdown and then paste the converted text into the front most application.

Release History

  • 1.0.0 Initial release
  • 2.0.0 Ported library to Typescript/Node



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap