(rawLine)
| 106 | } |
| 107 | |
| 108 | function parseTableRow(rawLine) { |
| 109 | const trimmed = rawLine.trim(); |
| 110 | if ( |
| 111 | !trimmed.startsWith('|') || |
| 112 | trimmed === '| --- | --- | ---: | --- |' || |
| 113 | trimmed === '| --- | ---: | --- |' || |
| 114 | trimmed === '| 名称 | 链接 | 订阅数 | 简介 |' || |
| 115 | trimmed === '| 资源 | 人数 | 简介 |' |
| 116 | ) { |
| 117 | return null; |
| 118 | } |
| 119 | |
| 120 | const parts = trimmed |
| 121 | .split('|') |
| 122 | .slice(1, -1) |
| 123 | .map(part => part.trim()); |
| 124 | |
| 125 | if (parts.length < 3) { |
| 126 | return null; |
| 127 | } |
| 128 | |
| 129 | let title; |
| 130 | let url; |
| 131 | let countStr; |
| 132 | let desc; |
| 133 | |
| 134 | if (parts.length >= 4) { |
| 135 | const [titleCell, linkCell, countCell, descCell] = parts; |
| 136 | const urlMatch = linkCell.match(/\[(.*?)\]\((.*?)\)/); |
| 137 | if (!urlMatch) { |
| 138 | return null; |
| 139 | } |
| 140 | title = cleanMarkdownText(titleCell); |
| 141 | url = urlMatch[2]; |
| 142 | countStr = countCell; |
| 143 | desc = descCell; |
| 144 | } else { |
| 145 | const [resourceCell, countCell, descCell] = parts; |
| 146 | const resourceMatch = resourceCell.match(/\[(.*?)\]\((.*?)\)/); |
| 147 | if (!resourceMatch) { |
| 148 | return null; |
| 149 | } |
| 150 | title = cleanMarkdownText(resourceMatch[1]); |
| 151 | url = resourceMatch[2]; |
| 152 | countStr = countCell; |
| 153 | desc = descCell; |
| 154 | } |
| 155 | |
| 156 | const parsedDesc = extractDesc(desc); |
| 157 | |
| 158 | return normalizeItem({ |
| 159 | title, |
| 160 | url, |
| 161 | countStr, |
| 162 | desc: parsedDesc === '-' ? '' : parsedDesc, |
| 163 | id: getItemId(title, url) |
| 164 | }); |
| 165 | } |
no test coverage detected