extractSectionTitle 提取段落标题
(section string)
| 443 | |
| 444 | // extractSectionTitle 提取段落标题 |
| 445 | func (s *DefaultCompressionService) extractSectionTitle(section string) string { |
| 446 | lines := strings.Split(section, "\n") |
| 447 | if len(lines) > 0 { |
| 448 | firstLine := strings.TrimSpace(lines[0]) |
| 449 | if strings.HasPrefix(firstLine, "##") { |
| 450 | return strings.TrimSpace(strings.TrimLeft(firstLine, "#")) |
| 451 | } |
| 452 | if strings.HasPrefix(firstLine, "#") { |
| 453 | return strings.TrimSpace(strings.TrimLeft(firstLine, "#")) |
| 454 | } |
| 455 | } |
| 456 | return "" |
| 457 | } |
| 458 | |
| 459 | // shouldPreserve 判断是否应该保留该段落 |
| 460 | func (s *DefaultCompressionService) shouldPreserve(title string, preserveSections []string) bool { |
no outgoing calls