mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-11-25 12:02:08 +00:00
Merge pull request #247 from Nyvryl/Nyvryl-patch-1
Revise chapter 5.5 on function values in Go
This commit is contained in:
@@ -119,7 +119,7 @@ $ ./outline2 http://gopl.io
|
|||||||
|
|
||||||
**练习 5.7:** 完善startElement和endElement函数,使其成为通用的HTML输出器。要求:输出注释结点,文本结点以及每个元素的属性(< a href='...'>)。使用简略格式输出没有孩子结点的元素(即用`<img/>`代替`<img></img>`)。编写测试,验证程序输出的格式正确。(详见11章)
|
**练习 5.7:** 完善startElement和endElement函数,使其成为通用的HTML输出器。要求:输出注释结点,文本结点以及每个元素的属性(< a href='...'>)。使用简略格式输出没有孩子结点的元素(即用`<img/>`代替`<img></img>`)。编写测试,验证程序输出的格式正确。(详见11章)
|
||||||
|
|
||||||
**练习 5.8:** 修改pre和post函数,使其返回布尔类型的返回值。返回false时,中止forEachNoded的遍历。使用修改后的代码编写ElementByID函数,根据用户输入的id查找第一个拥有该id元素的HTML元素,查找成功后,停止遍历。
|
**练习 5.8:** 修改pre和post函数,使其返回布尔类型的返回值。返回false时,中止forEachNode的遍历。使用修改后的代码编写ElementByID函数,根据用户输入的id查找第一个拥有该id元素的HTML元素,查找成功后,停止遍历。
|
||||||
|
|
||||||
```Go
|
```Go
|
||||||
func ElementByID(doc *html.Node, id string) *html.Node
|
func ElementByID(doc *html.Node, id string) *html.Node
|
||||||
@@ -130,3 +130,4 @@ func ElementByID(doc *html.Node, id string) *html.Node
|
|||||||
```Go
|
```Go
|
||||||
func expand(s string, f func(string) string) string
|
func expand(s string, f func(string) string) string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user