← 返回技术雷达
Hacker News tech

Preventing line breaks in <code> elements

Hacker News 热议:Preventing line breaks in <code> elements(11 赞 / 18 评论,来源 alexwlchan.net)

原文开头节选

One of my favourite tiny details in this website is my non-breaking spaces . I have code that looks for phrases like “5 cm”, “New York”, or “Objective‑C”, and inserts a non-breaking space/hyphen so they’ll never be split across multiple lines.

Previously I was only applying this detail to body text, but today I implemented something similar for elements.

I used a lot of inline code snippets in my last post , and while reviewing it I noticed that several of those snippets had unhelpful line breaks. For example, (?-u:…) was split into (?- and u:…) , while the flag —multiline was split with - on one line and -multiline on the other. These line breaks make the post harder to read, with no benefit.

I could fix this by replacing the hyphen in my with a non-breaking hyphen, but people copy/paste code snippets and that might change the meaning.

(以上为原文节选,完整内容见下方”原文来源”)

这条动态今日登上 Hacker News 首页(11 赞 / 18 评论,来源 alexwlchan.net)。技术雷达每日自动聚合 AI 工程、后端架构、DevOps 方向的前沿动态;相关工程落地可浏览下方的相关服务与延伸阅读,或直接与我们团队交流。

原文来源: Hacker News

相关服务