/ clis / douyin / _shared / text-extra.js
text-extra.js
 1  export function parseTextExtra(_text, hashtags) {
 2      return hashtags.map((h) => ({
 3          type: 1,
 4          hashtag_id: h.id,
 5          hashtag_name: h.name,
 6          start: h.start,
 7          end: h.end,
 8          caption_start: 0,
 9          caption_end: h.end - h.start,
10      }));
11  }
12  /** Extract hashtag names from text (e.g. "#话题" → ["话题"]) */
13  export function extractHashtagNames(text) {
14      return [...text.matchAll(/#([^\s#]+)/g)].map((m) => m[1]);
15  }