checkVideoReferenceImages returns an error naming every video the markdown embeds through a reference definition. Rewriting one would produce an image embed of a video, which renders as a broken image.
(refs []attachmentRef, attachmentArgs []attachmentArg)
| 199 | // embeds through a reference definition. Rewriting one would produce an image |
| 200 | // embed of a video, which renders as a broken image. |
| 201 | func checkVideoReferenceImages(refs []attachmentRef, attachmentArgs []attachmentArg) error { |
| 202 | var paths []string |
| 203 | seen := map[int]bool{} |
| 204 | for _, r := range refs { |
| 205 | if !r.referenceStyle() || !r.isEmbed { |
| 206 | continue |
| 207 | } |
| 208 | if !attachmentArgs[r.attachmentArg].RendersAsPlayer || seen[r.attachmentArg] { |
| 209 | continue |
| 210 | } |
| 211 | seen[r.attachmentArg] = true |
| 212 | paths = append(paths, attachmentArgs[r.attachmentArg].Path) |
| 213 | } |
| 214 | if len(paths) == 0 { |
| 215 | return nil |
| 216 | } |
| 217 | return fmt.Errorf("cannot embed a video as a reference-style image: %s", strings.Join(paths, ", ")) |
| 218 | } |
| 219 | |
| 220 | // attachmentRef is one markdown reference to an attached file: the markdown |
| 221 | // half of this package, paired to an argument by attachmentArgForDestination. |
no test coverage detected