You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the --before/-b flags are used to comment out Markdown content, awk prints a space after the character that begins the comment. This is fine when there is a line to comment out:
# let's **create a variable** now
# ```python
x = 'hello world'
# ```
But awk also inserts the space for line breaks when there is nothing to comment out, which is to say, for line breaks in the Markdown content:
# MY PROGRAM
#
# let's **create a variable** now
# ```python
x = 'hello world'
# ```
This is happening because awk has a built in variable called OFS, for "output file separator," which is set to the space character by default.
Linters do not like the trailing space on empty comment lines, and often complain about empty space at the end of a line. Whether this problem occurs will depend on your language, your linter, and your specific linter configuration, but prohibiting this in developer tooling is very common.
Instead of relying on the awkOFS variable to supply the space, OFS should be set to an empty string so as not to pad empty comment lines, and then the space can be explicitly added.
This will require measuring the length of the Markdown content being commented out. If the length greater than 0 characters, then the space should be added before the Markdown content is appended to the. If the length of the Markdown content is zero characters, then it's just an empty line, and the space should not be appended.
When the
--before
/-b
flags are used to comment out Markdown content,awk
prints a space after the character that begins the comment. This is fine when there is a line to comment out:But
awk
also inserts the space for line breaks when there is nothing to comment out, which is to say, for line breaks in the Markdown content:This is happening because
awk
has a built in variable calledOFS
, for "output file separator," which is set to the space character by default.Linters do not like the trailing space on empty comment lines, and often complain about empty space at the end of a line. Whether this problem occurs will depend on your language, your linter, and your specific linter configuration, but prohibiting this in developer tooling is very common.
Instead of relying on the
awk
OFS
variable to supply the space,OFS
should be set to an empty string so as not to pad empty comment lines, and then the space can be explicitly added.This will require measuring the length of the Markdown content being commented out. If the length greater than 0 characters, then the space should be added before the Markdown content is appended to the. If the length of the Markdown content is zero characters, then it's just an empty line, and the space should not be appended.
This is related to the need to generally clean up the
awk
logic.The text was updated successfully, but these errors were encountered: