Skip to content

Commit

Permalink
Merge branch 'v0.3.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
糖饼 committed Aug 7, 2015
2 parents 74ce6a5 + 645bcda commit fc49626
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 更新日志

## 0.3.8

* 修复 CSS `@charset` 可能导致无法解析的 BUG

## 0.3.7

* 完善伪类选择器支持
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ font-spider [options] <htmlFile ...>

#### 示例

1. 使用通配符压缩多个 HTML 文件关联的 WebFont:
1\. 使用通配符压缩多个 HTML 文件关联的 WebFont:

``` shell
font-spider dest/*.html
```

2. 使用 `--map <remotePath,localPath>` 参数将线上的页面的 WebFont 映射到本地来进行压缩:
2\. 使用 `--map <remotePath,localPath>` 参数将线上的页面的 WebFont 映射到本地来进行压缩:

``` shell
font-spider --map http://font-spider.org/font,./font http://font-spider.org/index.html
```

3. 使用 `--ignore <pattern>` 忽略文件:
3\. 使用 `--ignore <pattern>` 忽略文件:

``` shell
font-spider --ignore *-icon.css,*.eot dest/*.html
Expand Down
8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "font-spider",
"description": "Webfont optimizer",
"version": "0.3.7",
"version": "0.3.8",
"homepage": "https://github.com/aui/font-spider",
"author": {
"name": "aui",
Expand All @@ -14,12 +14,6 @@
"bugs": {
"url": "https://github.com/aui/font-spider/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/aui/font-spider/blob/master/LICENSE-MIT"
}
],
"bin": {
"fs": "bin/font-spider",
"font-spider": "bin/font-spider"
Expand Down
14 changes: 10 additions & 4 deletions src/spider/css-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ function CssParser (resource /*,importLength*/) {
}


// CSSOM BUG?
content = content.replace(/@charset\b.+;/g, '');

content = getContent(content);

try {
ast = CSSOM.parse(content);
Expand Down Expand Up @@ -342,6 +340,8 @@ CssParser.Parser.prototype = {
id: [],
family: [],
files: [],
// TODO [data-name="ss,ss"]
// /((?:[^,"']|"[^"]*"|'[^']*')+)/
selectors: utils.commaToArray(selectorText),
chars: content.split(''),
options: {}
Expand Down Expand Up @@ -457,7 +457,13 @@ getFontId.alias = {




function getContent (content) {
// 去掉 @charset,因为它可能触发 cssom 库的 bug
// 使用空格占位避免改动代码位置
return content.replace(/^(\@charset\b.+?;)(.*?)/i, function ($0, $1, $2) {
return Array($1.length).join(' ') + $2
});
}



Expand Down

0 comments on commit fc49626

Please sign in to comment.