I have a document where I am adding color to various parts using a \newenvironment
which was adapted from this answer. While it appears to have worked fine in 430 places, it provided an unexpected result in one case by adding an extra line (2. in the image, below).
While I have ways to get around the problem, maybe there is a fix since I have a lot more work to do on the document, which could cause the problem to move.
Note: I also use the environment inside paragraphs, with no problem. For example: Some words \begin{LII}{more words}\end{LII} end of paragraph.
\documentclass[11pt,letterpaper,oneside,onecolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=1in,showframe]{geometry}
\usepackage{parskip}
\renewcommand\familydefault\sfdefault
\usepackage{xcolor}
\newenvironment{LII}{%% https://tex.stackexchange.com/a/207228/187997
\leavevmode\color{cyan}\ignorespaces%
}{%
}%
\begin{document}
1. Line before, no color.
(2) Identifier-1 must be defined as an alphanumeric data item such that its value can be a program name.
Line after.
2. Line before, color environment above and below paragraph.
\begin{LII}{%
(2) Identifier-1 must be defined as an alphanumeric data item such that its value can be a program name.
}\end{LII}
Line after.
3. Line before, color environment above and below with \% at end of paragraph.
\begin{LII}{%
(2) Identifier-1 must be defined as an alphanumeric data item such that its value can be a program name.%
}\end{LII}
Line after.
4. Line before, color environment within paragraph.
\begin{LII}{(2) Identifier-1 must be defined as an alphanumeric data item such that its value can be a program name.}\end{LII}
Line after.
\end{document}