MCPcopy
hub / github.com/IvanMathy/Boop / readTagProperty

Function readTagProperty

Boop/Boop/scripts/lib/js-yaml.js:2135–2227  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

2133}
2134
2135function readTagProperty(state) {
2136 var _position,
2137 isVerbatim = false,
2138 isNamed = false,
2139 tagHandle,
2140 tagName,
2141 ch;
2142
2143 ch = state.input.charCodeAt(state.position);
2144
2145 if (ch !== 0x21/* ! */) return false;
2146
2147 if (state.tag !== null) {
2148 throwError(state, 'duplication of a tag property');
2149 }
2150
2151 ch = state.input.charCodeAt(++state.position);
2152
2153 if (ch === 0x3C/* < */) {
2154 isVerbatim = true;
2155 ch = state.input.charCodeAt(++state.position);
2156
2157 } else if (ch === 0x21/* ! */) {
2158 isNamed = true;
2159 tagHandle = '!!';
2160 ch = state.input.charCodeAt(++state.position);
2161
2162 } else {
2163 tagHandle = '!';
2164 }
2165
2166 _position = state.position;
2167
2168 if (isVerbatim) {
2169 do { ch = state.input.charCodeAt(++state.position); }
2170 while (ch !== 0 && ch !== 0x3E/* > */);
2171
2172 if (state.position < state.length) {
2173 tagName = state.input.slice(_position, state.position);
2174 ch = state.input.charCodeAt(++state.position);
2175 } else {
2176 throwError(state, 'unexpected end of the stream within a verbatim tag');
2177 }
2178 } else {
2179 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2180
2181 if (ch === 0x21/* ! */) {
2182 if (!isNamed) {
2183 tagHandle = state.input.slice(_position - 1, state.position + 1);
2184
2185 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2186 throwError(state, 'named tag handle cannot contain such characters');
2187 }
2188
2189 isNamed = true;
2190 _position = state.position + 1;
2191 } else {
2192 throwError(state, 'tag suffix cannot contain exclamation marks');

Callers 1

composeNodeFunction · 0.85

Calls 2

throwErrorFunction · 0.85
is_WS_OR_EOLFunction · 0.85

Tested by

no test coverage detected