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)
| 185 | // embeds through a reference definition. Rewriting one would produce an image |
| 186 | // embed of a video, which renders as a broken image. |
| 187 | func checkVideoReferenceImages(refs []attachmentRef, attachmentArgs []attachmentArg) error { |
| 188 | var paths []string |
| 189 | seen := map[int]bool{} |
| 190 | for _, r := range refs { |
| 191 | if !r.referenceStyle() || !r.isEmbed { |
| 192 | continue |
| 193 | } |
| 194 | if !attachmentArgs[r.attachmentArg].RendersAsPlayer || seen[r.attachmentArg] { |
| 195 | continue |
| 196 | } |
| 197 | seen[r.attachmentArg] = true |
| 198 | paths = append(paths, attachmentArgs[r.attachmentArg].Path) |
| 199 | } |
| 200 | if len(paths) == 0 { |
| 201 | return nil |
| 202 | } |
| 203 | return fmt.Errorf("cannot embed a video as a reference-style image: %s", strings.Join(paths, ", ")) |
| 204 | } |
| 205 | |
| 206 | // attachmentRef is one markdown reference to an attached file: the markdown |
| 207 | // half of this package, paired to an argument by attachmentArgForDestination. |
no test coverage detected