First off, thanks for an amazing and simple library! I like using oneLine to keep long text within 100 characters 🙌. However, (as far as I know) there is no way to add an intentional line break in a oneLine.
For example, I'll have a longer paragraph like so:
const longParagraph = oneLine`
Four score and seven years ago our fathers brought forth on this continent, a new nation,
conceived in Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived
and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to
dedicate a portion of that field, as a final resting place for those who here gave their lives
that that nation might live. It is altogether fitting and proper that we should do this.
`;
and my intention would be to add two intentional line breaks after "created equal." and maybe an additional line break after "should do this.".
I have three proposals to get this feature:
- add an extra directive to import that when
oneLine (or any other tag) sees it, it will add the intentional line break
import { oneLine, NEW_LINE } from 'common-tags';
const longParagraph = oneLine`
Four score and seven years ago our fathers brought forth on this continent, a new nation,
conceived in Liberty, and dedicated to the proposition that all men are created equal.${NEW_LINE}
${NEW_LINE}
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived
and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to
dedicate a portion of that field, as a final resting place for those who here gave their lives
that that nation might live. It is altogether fitting and proper that we should do this.${NEW_LINE}
`;
- import or add some special directive that allows you to escape new lines (or even other things like tabs).
import { oneLine, escape } from 'common-tags';
const longParagraph = oneLine`
Four score and seven years ago our fathers brought forth on this continent, a new nation,
conceived in Liberty, and dedicated to the proposition that all men are created equal.${escape('\n')}
${escape('\n')}
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived
and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to
dedicate a portion of that field, as a final resting place for those who here gave their lives
that that nation might live. It is altogether fitting and proper that we should do this.${escape('\n')}
`;
instead of importing escape, there could be an escape sequence similar to javascript's backslashes \
- create a brand new tag that will add insert a single line break when two line breaks are present (similar to how markdown works)
import { paragraph } from 'common-tags';
const longParagraph = paragraph`
Four score and seven years ago our fathers brought forth on this continent, a new nation,
conceived in Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived
and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to
dedicate a portion of that field, as a final resting place for those who here gave their lives
that that nation might live. It is altogether fitting and proper that we should do this.
`;
The logic for the paragraph tag (could use renaming) is for every two consecutive line breaks (without considering whitespace), it will insert one line break. The rest of the line breaks will be ignored.
I would be willing to work on the PRs after I get your blessing for any or all of the above proposals. I think both 2 and 3 are worth implementing.
Let me know what you think and I apologize if I missed something!
First off, thanks for an amazing and simple library! I like using
oneLineto keep long text within 100 characters 🙌. However, (as far as I know) there is no way to add an intentional line break in aoneLine.For example, I'll have a longer paragraph like so:
and my intention would be to add two intentional line breaks after "created equal." and maybe an additional line break after "should do this.".
I have three proposals to get this feature:
oneLine(or any other tag) sees it, it will add the intentional line breakinstead of importing
escape, there could be an escape sequence similar to javascript's backslashes\The logic for the
paragraphtag (could use renaming) is for every two consecutive line breaks (without considering whitespace), it will insert one line break. The rest of the line breaks will be ignored.I would be willing to work on the PRs after I get your blessing for any or all of the above proposals. I think both 2 and 3 are worth implementing.
Let me know what you think and I apologize if I missed something!