自动生成下一级的内容
(bookId, docId int, isSummary ...bool)
| 590 | |
| 591 | //自动生成下一级的内容 |
| 592 | func (m *Document) BookStackAuto(bookId, docId int, isSummary ...bool) (md, cont string) { |
| 593 | //自动生成文档内容 |
| 594 | var docs []Document |
| 595 | orm.NewOrm().QueryTable("md_documents").Filter("book_id", bookId).Filter("parent_id", docId).OrderBy("order_sort").All(&docs, "document_id", "document_name", "identify") |
| 596 | var newCont []string //新HTML内容 |
| 597 | var newMd []string //新markdown内容 |
| 598 | for _, doc := range docs { |
| 599 | newMd = append(newMd, fmt.Sprintf(`- [%v]($%v)`, doc.DocumentName, doc.Identify)) |
| 600 | newCont = append(newCont, fmt.Sprintf(`<li><a href="%v">%v</a></li>`, doc.Identify, doc.DocumentName)) |
| 601 | } |
| 602 | md = strings.Join(newMd, "\n") |
| 603 | cont = "<ul>" + strings.Join(newCont, "") + "</ul>" |
| 604 | return |
| 605 | } |
| 606 | |
| 607 | //爬虫批量采集 |
| 608 | //@param html html |
no test coverage detected