2

I would like to justify a plain text file (actually a markdown file) where some lines end in a double space:

some lines which
can be justified with a little care
and attention. 

The following tough should not 
be changed as this line ends in a double space:  
some new line

I would also like to have some itemised list:  
 * The above line also ends in a double space.
 However, this line ends in a single space.
 * A new bullet.  
    - Some sub item.

enter image description here

Some of the above lines end in a double space, which should indicate in markdown a new line. I would like a command line command (or bash script?) to justify this, such as when using par for example, par j1w50 < misc.markdown > misc_new.markdown, where the output of the command is

some lines  which can  be justified with  a little
care and attention.

The following tough should  not be changed as this
line ends in a double space: some new line

I would  also like to  have some itemised  list: *
The  above  line  also  ends in  a  double  space.
However, this line ends in a single space. * A new
bullet. - Some sub item.

which does not preserve the markdown formatting:

enter image description here

I was attracted to the par solution because of its simplicity, so would like to avoid creating any big scripts myself.

The following Qs are similar/related, but aren't specific to the double space issue for markdown languages: - Par: justify text without joining lines - How can I justify plain text in Linux?

oliversm
  • 121
  • 3
  • did you try fmt utility from shell ? – Alex Nov 23 '17 at 01:23
  • I had a brief look but the `par` solution worked. I don't know if `fmt` is able to justify the lines (a nice visual feature I would like to retain), but if it can I would consider it. Can you provide an example? – oliversm Nov 23 '17 at 01:50

0 Answers0