将文本导入标记文件中的代码块。
pipe2codeblock的Python项目详细描述
pipe2代码块
将文本导入标记文件中的代码块。
最初设计用于将终端命令的--help
文本放入README.md
。
用法
用信息字符串help
在目标文件中放置一个受保护的代码块。
fenced代码块是由CommonMark定义的, 但不能缩进的情况除外(以防止块内的空格被lstrip)。
然后执行
your_awesome_tool --help | p2c README.md
输入文本,或
p2c README.md input_file.txt
从文件中读取。
--tgt
选项允许您选择要作为目标的信息字符串(而不是"help"
)。
只使用第一个实例。
用法
usage: p2c [-h] [--tgt TGT] outfile [infile] Pipe text into a code block in a markdown file. positional arguments: outfile infile optional arguments: -h, --help show this help message and exit --tgt TGT Target a code block with a different info string (default 'help')
由dogfooding生成:p2c --help | p2c README.md