英文空格转中文空格的 javascript bookmark 脚本

2016-04-18 12:31:58 +08:00
 xuboying

发现 v 站上有不少萌妹子问 python 问题,每次遇到都忍不住要回答一下,但是 v 站的回复格式实在太闹心了,空格完全消失了。于是想到了一个 ugly 的办法,就是用中文空格替换英文空格,这样代码就不会乱七八糟了(至少看起来)

https://gist.github.com/xuboying/d732d9d4f509b07c8a2041ef6bc7c755

1914 次点击
所在节点    分享创造
6 条回复
xuboying
2016-04-18 12:32:25 +08:00
举个例子

prices = {'apple': 0.40, 'banana': 0.50}
my_purchase = {
  'apple': 1,
  'banana': 6}
grocery_bill = sum(prices[fruit] * my_purchase[fruit]
          for fruit in my_purchase)
print 'I owe the grocer $%.2f' % grocery_bill

### Warning: Above code may contain Chinese wide whitespace for human friendly reading in web browser.
### Do: replace them back to double space in your favorite text editor to satisfy you compiler/interpreted.
oott123
2016-04-18 12:49:04 +08:00
讲道理,还不如在自定义 css 里给帖子内容加个 white-space 属性来得方便快捷……
learnshare
2016-04-18 12:54:51 +08:00
是全角空格和半角空格吧
xuboying
2016-04-18 12:59:48 +08:00
@learnshare 哈哈哈,我完全忘记了半角和全角的术语了
xuboying
2016-04-18 13:00:50 +08:00
@oott123 能者多劳,做一个发布到 stylish 里呗,方便大家
sciooga
2016-04-21 14:56:12 +08:00
装上 V2EX plus 呗,早段时间已经添加了类似的功能

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/271944

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX