(parser)
| 108 | } |
| 109 | |
| 110 | export function readPiExp(parser) { |
| 111 | let inSingleQuotes = false; |
| 112 | let inDoubleQuotes = false; |
| 113 | let i; |
| 114 | let EOE = false; |
| 115 | |
| 116 | for (i = 0; parser.source.canRead(i) ; i++) { |
| 117 | const currentChar = parser.source.readChAt(i); |
| 118 | const nextChar = parser.source.readChAt(i+1); |
| 119 | |
| 120 | if (currentChar === "'" && !inDoubleQuotes) { |
| 121 | inSingleQuotes = !inSingleQuotes; |
| 122 | } else if (currentChar === '"' && !inSingleQuotes) { |
| 123 | inDoubleQuotes = !inDoubleQuotes; |
| 124 | } |
| 125 | |
| 126 | if (!inSingleQuotes && !inDoubleQuotes) { |
| 127 | if (currentChar === '?' && nextChar === '>') { |
| 128 | EOE = true; |
| 129 | break; // Exit the loop when '?>' is found |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | if(inSingleQuotes || inDoubleQuotes){ |
| 134 | throw new Error("Invalid attribute expression. Quote is not properly closed in PI tag expression"); |
| 135 | }else if(!EOE) throw new Error("Unexpected closing of source. Waiting for '?>'"); |
| 136 | |
| 137 | if(!parser.options.attributes.ignore){ |
| 138 | //TODO: use regex to verify attributes if not set to ignore |
| 139 | } |
| 140 | |
| 141 | const exp = parser.source.readStr(i); |
| 142 | parser.source.updateBufferBoundary(i + 1); |
| 143 | return buildTagExpObj(exp, parser) |
| 144 | } |
| 145 | |
| 146 | function buildTagExpObj(exp, parser){ |
| 147 | const tagExp = { |
no test coverage detected