支持项目符号的文本格式化程序

支持项目符号的文本格式化程序

我正在寻找一个与我的 git 提交一起使用的格式化程序。par几乎做了我想要的,但(重要的)限制是我无法让它正确格式化项目符号列表,这在提交消息中很常见。

例如:

% export PARINIT="rTbgqR B=.,?'_A_a_@ Q=_s>|"
% par << EOF                                                                                                                                            
heredoc> [JR-1234] This is a fix for the thing.

I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks.

  - I am a developer that doesn't like linebreaks. I also like bullet lists. I like bullet lists a lot.
  - I like bullet lists. I like bullet lists a lot. I am also a developer that doesn't like linebreaks.

I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks.
heredoc> EOF

这给出了输出:

[JR-1234] This is a fix for the thing.

I am a developer that doesn't like linebreaks. I am a developer that
doesn't like linebreaks. I am a developer that doesn't like linebreaks.

  - I am a developer that doesn't like linebreaks. I also like bullet
  - lists. I like bullet lists a lot.  I like bullet lists. I like
  - bullet lists a lot. I am also a developer that doesn't like
  - linebreaks.

I am a developer that doesn't like linebreaks. I am a developer that
doesn't like linebreaks. I am a developer that doesn't like linebreaks.

同时,我想要这样的东西:

[JR-1234] This is a fix for the thing.

I am a developer that doesn't like linebreaks. I am a developer that
doesn't like linebreaks. I am a developer that doesn't like linebreaks.

  - I am a developer that doesn't like linebreaks. I also like bullet
    lists. I like bullet lists a lot.
  - I like bullet lists. I like bullet lists a lot. I am also a
    developer that doesn't like linebreaks.

I am a developer that doesn't like linebreaks. I am a developer that
doesn't like linebreaks. I am a developer that doesn't like linebreaks.

这样做par是理想的,但其他一些同样的独立格式化程序也可以。

答案1

Pandoc 会这样做:

$ pandoc -t plain <<EOF
>  [JR-1234] This is a fix for the thing.
> 
> I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks.
> 
>   - I am a developer that doesn't like linebreaks. I also like bullet lists. I like bullet lists a lot.
>   - I like bullet lists. I like bullet lists a lot. I am also a developer that doesn't like linebreaks.
> 
> I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks. I am a developer that doesn't like linebreaks.
> EOF
[JR-1234] This is a fix for the thing.

I am a developer that doesn’t like linebreaks. I am a developer that
doesn’t like linebreaks. I am a developer that doesn’t like linebreaks.

-   I am a developer that doesn’t like linebreaks. I also like bullet
    lists. I like bullet lists a lot.
-   I like bullet lists. I like bullet lists a lot. I am also a
    developer that doesn’t like linebreaks.

I am a developer that doesn’t like linebreaks. I am a developer that
doesn’t like linebreaks. I am a developer that doesn’t like linebreaks.

相关内容