Add comment support. Rename tags to tag.
Showing
1 changed file
with
14 additions
and
5 deletions
1 | /***** Start *****/ | 1 | /***** Start *****/ |
2 | start | 2 | start |
3 | = tags:tags+ .* { | 3 | = tags:lines+ .* { |
4 | var obj = {}; | 4 | var obj = {}; |
5 | tags.forEach(function(tag) { for (var p in tag) { obj[p] = tag[p]; }}); | 5 | tags.forEach(function(tag) { for (var p in tag) { obj[p] = tag[p]; }}); |
6 | return obj; | 6 | return obj; |
7 | } | 7 | } |
8 | 8 | ||
9 | tags | 9 | lines |
10 | = tag:m3uTag _ { return tag; } | 10 | = comment:comment _ { var obj = {}; obj["comment" + line] = comment; return obj; } |
11 | / ! comment tag:tag _ { return tag; } | ||
12 | |||
13 | tag | ||
14 | = & comment | ||
15 | / tag:m3uTag _ { return tag; } | ||
11 | / tag:extinfTag _ { return tag; } | 16 | / tag:extinfTag _ { return tag; } |
12 | / tag:targetDurationTag _ { return tag; } | 17 | / tag:targetDurationTag _ { return tag; } |
13 | / tag:mediaSequenceTag _ { return tag; } | 18 | / tag:mediaSequenceTag _ { return tag; } |
... | @@ -26,6 +31,9 @@ tags | ... | @@ -26,6 +31,9 @@ tags |
26 | / tag:startTag _ { return tag; } | 31 | / tag:startTag _ { return tag; } |
27 | / tag:versionTag _ { return tag; } | 32 | / tag:versionTag _ { return tag; } |
28 | 33 | ||
34 | comment "comment" | ||
35 | = & "#" ! "#EXT" text:text+ { return text.join(); } | ||
36 | |||
29 | /***** Tags *****/ | 37 | /***** Tags *****/ |
30 | 38 | ||
31 | m3uTag | 39 | m3uTag |
... | @@ -71,7 +79,7 @@ mediaTag | ... | @@ -71,7 +79,7 @@ mediaTag |
71 | = tag:'#EXT-MEDIA' ":" attrs:mediaAttributes { return {media: attrs}; } | 79 | = tag:'#EXT-MEDIA' ":" attrs:mediaAttributes { return {media: attrs}; } |
72 | 80 | ||
73 | streamInfTag | 81 | streamInfTag |
74 | = tag:'#EXT-X-STREAM-INF' ":" attrs:streamInfAttrs _ file:mediaFile { | 82 | = tag:'#EXT-X-STREAM-INF' ":" attrs:streamInfAttrs _ file:mediaFile? { |
75 | var fileObj = {}; | 83 | var fileObj = {}; |
76 | fileObj[file] = { | 84 | fileObj[file] = { |
77 | attributes: attrs, | 85 | attributes: attrs, |
... | @@ -104,7 +112,8 @@ versionTag | ... | @@ -104,7 +112,8 @@ versionTag |
104 | /***** Helpers *****/ | 112 | /***** Helpers *****/ |
105 | 113 | ||
106 | mediaFile | 114 | mediaFile |
107 | = file:[ -~]+ { return file.join(''); } | 115 | = & tag |
116 | / ! tag file:[ -~]+ { return file.join(''); } | ||
108 | 117 | ||
109 | keyAttributes | 118 | keyAttributes |
110 | = attrs:keyAttribute+ | 119 | = attrs:keyAttribute+ | ... | ... |
-
Please register or sign in to post a comment