使用方法

引入jquery.js 和 text-autospace.js

<script src='https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js'/>
<script src='https://mastermay.github.io/text-autospace.js/text-autospace.min.js'/>

你还需要添加如下的css样式:

html.han-la hanla:after {
	content: " ";
	display: inline;
	font-family: Arial;
	font-size: 0.89em;
}

html.han-la code hanla,
html.han-la pre hanla,
html.han-la kbd hanla,
html.han-la samp hanla {
	display: none;
}

html.han-la ol > hanla,
html.han-la ul > hanla {
	display: none;
}
html.han-la tr > hanla {
    display: none;
}

你还需要给<html>添加class='han-la'属性

程序将会自动在所有的汉字与拉丁字母间添加一个空格,当然,这些空格不会被选中。如果你原本已经手动添加了空格,程序并不会在这之间再添加额外的空格。

同时,不会影响使用了等宽字体的code,pre等标签内的内容。

如果你有不想应用此js的区域,如blockquote,请添加:

html.han-la blockquote hanla {
	display: none;
}

演示(可使用CTRL+A查看区别)

不含空格的段落

Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理。在推出后,Git在其它项目中也取得了很大成功,尤其是在Ruby社区中。目前,包括Rubinius和Merb在内的很多知名项目都使用了Git。Git同样可以被诸如Capistrano和Vlad the Deployer这样的部署工具所使用。GitHub于2008年2月运行。

已手动添加了空格的段落

Git 是一个分布式的版本控制系统,最初由 Linus Torvalds 编写,用作 Linux 内核代码的管理。在推出后,Git 在其它项目中也取得了很大成功,尤其是在 Ruby 社区中。目前,包括 Rubinius 和 Merb 在内的很多知名项目都使用了 Git。Git 同样可以被诸如 Capistrano 和 Vlad the Deployer 这样的部署工具所使用。GitHub 于 2008 年 2 月运行。

代码样例

public class HelloWorld{
	public static void main(String[] args) {
		System.out.println("Hello World!你好,世界!");
	}
}

汉字标准格式 & findAndReplaceDOMText