lint: metadata parsing

This commit is contained in:
Roipoussiere 2023-06-05 21:15:59 +02:00
parent 372e33c066
commit 98a89aea11
4 changed files with 5 additions and 4 deletions

View file

@ -2,13 +2,13 @@ export function getMetadata(raw_code) {
// https://stackoverflow.com/a/15123777
const comment_regexp = /\/\*([\s\S]*?)\*\/|([^\\:]|^)\/\/(.*)$/gm;
const tag_regexp = /@([a-z]*):? (.*)/gm
const tag_regexp = /@([a-z]*):? (.*)/gm;
const tags = {};
for (const match of raw_code.matchAll(comment_regexp)) {
const comment = match[1] ? match[1] : '' + match[3] ? match[3] : '';
for (const tag_match of comment.trim().matchAll(tag_regexp)) {
tags[tag_match[1]] = tag_match[2].trim()
tags[tag_match[1]] = tag_match[2].trim();
}
}