(value: string, opts: BaseLibraryOptions = {})
| 134 | } |
| 135 | |
| 136 | get(value: string, opts: BaseLibraryOptions = {}): string { |
| 137 | const stringifyLineBreaks = value.replace(/\n/g, '\\n'); |
| 138 | const [beginningWhitespace] = stringifyLineBreaks.match(/^(\\.| )+/) || ['']; |
| 139 | const [endWhitespace] = stringifyLineBreaks.match(/(\\.| )+$/) || ['']; |
| 140 | const modifiedValue = stringifyLineBreaks.replace(beginningWhitespace, '').replace(endWhitespace, ''); |
| 141 | const hasType = AttributeLibrary.isSelector(modifiedValue); |
| 142 | |
| 143 | const reconstructValue = (v: string): string => ( |
| 144 | (beginningWhitespace + v + endWhitespace).replace(/\\n/g, '\n') |
| 145 | ); |
| 146 | |
| 147 | if (!hasType) { |
| 148 | const ret = this.selectors[0].get(modifiedValue, opts); |
| 149 | |
| 150 | return reconstructValue(( |
| 151 | ret === modifiedValue |
| 152 | ? this.selectors[1].get(modifiedValue, opts) |
| 153 | : ret |
| 154 | )); |
| 155 | } |
| 156 | |
| 157 | if (this.selectors[0].isValidSelector(modifiedValue)) { |
| 158 | return reconstructValue(this.selectors[0].get(modifiedValue, opts)); |
| 159 | } |
| 160 | |
| 161 | return reconstructValue(this.selectors[1].get(modifiedValue, opts)); |
| 162 | } |
| 163 | |
| 164 | // If it's reserved in any case, consider it reserved everywhere |
| 165 | isReserved(...args: Parameters<BaseLibrary['isReserved']>): ReturnType<BaseLibrary['isReserved']> { |
nothing calls this directly
no test coverage detected