Skip to content

Commit

Permalink
refactor: create walker to track our tree state
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Nov 20, 2020
1 parent 0ff6f1f commit 1f30a3a
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 325 deletions.
52 changes: 47 additions & 5 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func NewGlob(pat string) (Glob, error) {
// A Block represents a section of text.
type Block struct {
Context string // parent content - e.g., sentence -> paragraph
Text string // text content
Raw string // text content without any processing
Line int // Line of the block
Scope Selector // section selector
Text string // text content
}

// NewBlock makes a new Block with prepared text and a Selector.
Expand All @@ -66,7 +66,22 @@ func NewBlock(ctx, txt, sel string) Block {
ctx = txt
}
return Block{
Context: ctx, Text: txt, Scope: Selector{Value: sel}}
Context: ctx,
Text: txt,
Scope: Selector{Value: sel},
Line: -1}
}

// NewLinedBlock ...
func NewLinedBlock(ctx, txt, sel string, line int) Block {
if ctx == "" {
ctx = txt
}
return Block{
Context: ctx,
Text: txt,
Scope: Selector{Value: sel},
Line: line}
}

// A File represents a linted text file.
Expand Down Expand Up @@ -299,14 +314,41 @@ func FormatAlert(a *Alert, limit int, level, name string) {
a.Message = WhitespaceToSpace(a.Message)
}

func (f *File) assignLoc(ctx string, blk Block, pad int, a Alert) (int, []int) {
loc := a.Span
for idx, l := range strings.SplitAfter(ctx, "\n") {
if idx == blk.Line {
length := utf8.RuneCountInString(l)
pos, substring := initialPosition(l, blk.Text, a)

loc[0] = pos + pad
loc[1] = pos + utf8.RuneCountInString(substring) - 1

extent := length + pad
if loc[1] > extent {
loc[1] = extent
}

return blk.Line + 1, loc
}
}
return blk.Line + 1, a.Span
}

// AddAlert calculates the in-text location of an Alert and adds it to a File.
func (f *File) AddAlert(a Alert, blk Block, lines, pad int) {
func (f *File) AddAlert(a Alert, blk Block, lines, pad int, lookup bool) {
ctx := blk.Context
if old, ok := f.ChkToCtx[a.Check]; ok {
ctx = old
}

a.Line, a.Span = f.FindLoc(ctx, blk.Text, pad, lines, a)
if !lookup {
a.Line, a.Span = f.assignLoc(ctx, blk, pad, a)
}
if (!lookup && a.Span[0] < 0) || lookup {
a.Line, a.Span = f.FindLoc(ctx, blk.Text, pad, lines, a)
}

if a.Span[0] > 0 {
f.ChkToCtx[a.Check], _ = Substitute(ctx, a.Match, '#')
if !a.Hide {
Expand Down
212 changes: 0 additions & 212 deletions fixtures/i18n/zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,215 +5,3 @@
为贯彻落实《中华人民共和国反恐怖主义法》、《中华人民共和国网络安全法》、《互联网信息服务管理办法》、《互联网域名管理办法》等法律法规和规章的要求,进一步规范互联网信息服务域名使用。自2018年01月01日起,从事互联网信息服务使用的域名应为其依法依规注册所有,个人性质备案域名注册者应为本人,单位性质备案域名注册者应为单位(含公司股东)、单位主要负责人或高级管理人员。
根据要求,当腾讯云将您的备案信息提至管局审核时,所在省通信管理局将对域名注册信息进行核验,如核验未通过,腾讯云将不得为您提供接入服务。
腾讯云将会定期查验域名的状态,对于域名不存在、域名过期且未提供真实身份信息等情形的,根据通知要求,腾讯云将停止提供接入服务。


## 待备案的域名要求
备案域名需满足表格里的条件,才能通过备案域名核验:
<table>
<tr>
<th width="55%">需 “同时符合” 以下条件</th>
<th>相关参考</th>
</tr>
<tr>
<td>备案的域名要求在域名注册有效期内</td>
<td>域名有效期查询请参考 <a href="https://whois.cloud.tencent.com/">WHOIS</a> 信息中的过期时间。</td>
</tr>
<tr>
<td>备案的域名要求为已通过实名认证的域名</td>
<td>域名实名认证请参考 <a href="https://cloud.tencent.com/document/product/242/6707">实名认证</a> 进行操作。</td>
</tr>
<tr>
<td>备案的域名要求为国家批复的顶级域名</td>
<td>顶级域名后缀可参考 <a href="#beian">可备案的域名后缀</a>。</td>
</tr>
<tr>
<td>境外注册商所注册的域名不能直接备案</td>
<td>请转入境内有资质的服务商,例如腾讯云。具体操作可参考 <a href="https://cloud.tencent.com/document/product/242/3645">域名转入腾讯云</a>。</td>
</tr>
</table>

## 备案主体与域名所有者的关系
申请备案时填报的备案主体信息应与域名所有者实名认证信息相符。
- 个人备案:备案负责人信息与域名所有者实名认证信息需保持一致(比对信息为:姓名、证件类型、证件号码)。
- 单位备案:备案主办单位名称或法定代表人需要与域名所有者实名认证信息保持一致(比对信息为:姓名、证件类型、证件号码)。
- 一般情况下,企业备案域名所有者需要与企业备案主体名称或者法定代表人一致。
- 存在部分特殊情况,例如,国家机密单位、大型公司进行备案,域名所有者可以是单位主要负责人或者高级管理人员,但需提供相关证明材料(仅部分省份,具体可参考 [各省管局规则](https://cloud.tencent.com/document/product/243/3474)),示例如下:
>?该证明材料为工信部系统统一模板,请您单击 [有关网站备案域名注册人的证明](https://upload-dianshi-1255598498.file.myqcloud.com/%E6%9C%89%E5%85%B3%E7%BD%91%E7%AB%99%E5%A4%87%E6%A1%88%E5%9F%9F%E5%90%8D%E6%B3%A8%E5%86%8C%E4%BA%BA%E7%9A%84%E8%AF%81%E6%98%8E-f29116ceb18fb8a55cd768caabc6b6f5861d35e7.docx) 下载证明材料。
>
![](https://mc.qcloudimg.com/static/img/1de29091970a2848726430faad17b84e/image.png)

## 备案只针对一级域名

进行网站备案时,只需要对一级域名进行备案,一级域名备案后对应的二级域名、三级域名可以正常使用。

以腾讯为例,一级域名为:`tencent.com`,备案完成后对应的二级域名:`cloud.tencent.com`、三级域名`market.cloud.tencent.com``buy.cloud.tencent.com`均可正常使用。


## 小程序备案入口
请使用微信扫一扫小程序码进入备案小程序,并登录您的腾讯云账号。备案流程请参考 [首次备案](https://cloud.tencent.com/document/product/243/37402)
![](https://main.qcloudimg.com/raw/27cee122dba1d90a03c38ceaf65fb3f3.jpg)


<span id="beian"></span>
## 可备案的域名后缀
更新于2020年7月24日,具体信息可查看 [工业和信息化部域名行业管理信息公示](http://xn--eqrt2g.xn--vuq861b/#)

| 后缀 | 备注 |
| ---- | ---- |
| .中国 |- |
| .cn |- |
| .政务.cn | 中国党政群机关等各级政务部门 |
| .公益.cn | 非营利性机构 |
| .gov.cn | 中国政府机构 |
| .org.cn | 非营利性组织 |
| .ac.cn | 科研机构 |
| .mil.cn | 中国国防机构 |
| .net.cn | 提供互联网服务的机构 |
| .edu.cn | 教育机构 |
| .com.cn | 工、商、金融等企业 |
| .bj.cn | 北京市 |
| .tj.cn | 天津市 |
| .sh.cn | 上海市 |
| .cq.cn | 重庆市 |
| .he.cn | 河北省 |
| .sx.cn | 山西省 |
| .nm.cn | 内蒙古自治区 |
| .ln.cn | 辽宁省 |
| .jl.cn | 吉林省 |
| .hl.cn | 黑龙江省 |
| .js.cn | 江苏省 |
| .zj.cn | 浙江省 |
| .ah.cn | 安徽省 |
| .fj.cn | 福建省 |
| .jx.cn | 江西省 |
| .sd.cn | 山东省 |
| .ha.cn | 河南省 |
| .hb.cn | 湖北省 |
| .hn.cn | 湖南省 |
| .gd.cn | 广东省 |
| .gx.cn | 广西壮族自治区 |
| .hi.cn | 海南省 |
| .sc.cn | 四川省 |
| .gz.cn | 贵州省 |
| .yn.cn | 云南省 |
| .xz.cn | 西藏自治区 |
| .sn.cn | 陕西省 |
| .qh.cn | 青海省 |
| .nx.cn | 宁夏回族自治区 |
| .xj.cn | 新疆维吾尔自治区 |
| .tw.cn | 中国台湾 |
| .hk.cn | 中国香港特别行政区 |
| .mo.cn | 中国澳门特别行政区 |
| .政务 | 中国党政群机关等各级政务部门 |
| .公益 | 非营利性机构 |
| .公司 |- |
| .网络 |- |
| .网址 |- |
| .商城 |- |
| .网店 |- |
| .中信 |- |
| .商标 |- |
| .广东 |- |
| .佛山 |- |
| .信息 |- |
| .手机 |- |
| .在线 |- |
| .中文网 |- |
| .集团 |- |
| .我爱你 |- |
| .商店 |- |
| .企业 |- |
| .娱乐 |- |
| .游戏 |- |
| .购物 |- |
| .餐厅 |- |
| .招聘 |- |
| .时尚 |- |
| .移动 |- |
| .网站 |- |
| .ren |- |
| .wang |- |
| .citic |- |
| .top |- |
| .sohu |- |
| .xin |- |
| .com |- |
| .net |- |
| .club |- |
| .xyz |- |
| .vip |- |
| .site |- |
| .shop |- |
| .ink |- |
| .info |- |
| .mobi |- |
| .red |- |
| .pro |- |
| .kim |- |
| .ltd |- |
| .group |- |
| .biz |- |
| .auto |- |
| .link |- |
| .work |- |
| .law |- |
| .beer |- |
| .store |- |
| .tech |- |
| .fun |- |
| .online |- |
| .art |- |
| .design |- |
| .wiki |- |
| .love |- |
| .center |- |
| .video |- |
| .social |- |
| .team |- |
| .show |- |
| .cool |- |
| .zone |- |
| .world |- |
| .today |- |
| .city |- |
| .chat |- |
| .company |- |
| .live |- |
| .fund |- |
| .gold |- |
| .plus |- |
| .guru |- |
| .run |- |
| .pub |- |
| .email |- |
| .life |- |
| .co |- |
| .fashion |- |
| .fit |- |
| .luxe |- |
| .yoga |- |
| .baidu |- |
| .cloud |- |
| .host |- |
| .space |- |
| .press |- |
| .website |- |
| .archi |- |
| .asia |- |
| .bio |- |
| .black |- |
| .blue |- |
| .green |- |
| .lotto |- |
| .organic |- |
| .pet |- |
| .pink |- |
| .poker |- |
| .promo |- |
| .ski |- |
| .vote |- |
| .voto |- |
| .icu |- |
| .fans |- |
| .tv |- |
| .cc |- |

0 comments on commit 1f30a3a

Please sign in to comment.