ericcornelissen/wordrow

Treat newlines plus indentation as a space

Closed this issue · 0 comments

Make it so that newlines, plus indentation(/leading whitespace), is treated as a space when the mapping value contains a space.

Proposal

For the mapping:

hello world, hey planat

A text containing "hello" and "world" with a newline in between, instead of a space, should be converted as:

- Lorem ipsum hello
- world dolor sit amet.
+ Lorem ipsum hey
+ planet dolor sit amet.

Similarly, if the text is indented the leading whitespace of the sentence shouldn't affect the mapping.

- Lorem ipsum hello
-   world dolor sit amet.
+ Lorem ipsum hey
+   planet dolor sit amet.

In the case that the "to" value contains more spaces as the "from" value, the newline is inserted at the same space as the "from" value. Some examples:

# for "hello world, hey beautiful planet"
- Lorem ipsum hello
- world dolor sit amet.
+ Lorem ipsum hey
+ beautiful planet dolor sit amet.

# for "hello beautiful world, hey amazingly beautiful planet"
#  1.
- Lorem ipsum hello beautiful
- world dolor sit amet.
+ Lorem ipsum hey amazingly
+ beautiful planet dolor sit amet.

#  2.
- Lorem ipsum hello
- beautiful world dolor sit amet.
+ Lorem ipsum hey
+ amazingly beautiful planet dolor sit amet.

In the case that the "to" value contains fewer spaces as the "from" value, the newline is inserted at the same space if possible, or after the value otherwise. Some examples:

# for "foo bar, foobar"
- Lorem ipsum foo
- bar dolor sit amet.
+ Lorem ipsum foobar
+ dolor sit amet.

# for "hello beautiful world, hey planet"
#  1.
- Lorem ipsum hello beautiful
- world dolor sit amet.
+ Lorem ipsum hey planet
+ dolor sit amet.

#  2.
- Lorem ipsum hello
- beautiful world dolor sit amet.
+ Lorem ipsum hey
+ planet dolor sit amet.

Discussion

This is perhaps not always a desired feature, therefore it may be needed to add an option to enable/disable it.