Preventing line breaks in <code> elements
3 hours ago
- The author uses non-breaking spaces/hyphens in body text to prevent awkward line breaks for phrases like '5 cm' or 'New York'.
- They extended this practice to <code> elements to avoid unhelpful line breaks in code snippets, such as splitting '--multiline' or '(?-u:…)'.
- To prevent line breaks, they add the 'nowrap' class to short <code> elements (15 characters or less) that contain hyphens or spaces, using a Python regex.
- A CSS rule with 'text-wrap: nowrap' is applied to the 'code.nowrap' class to enforce no line wrapping, though it's a minor improvement.