Skip to content

Commit

Permalink
lexer: add escape sequences to attribute values
Browse files Browse the repository at this point in the history
Add some simple escape sequence processing to the value loop.
Allows users to write things like:

    meta(name=description content='Don\'t you think this is awesome?')
  • Loading branch information
matheusmoreira committed Aug 27, 2023
1 parent 64c316f commit df56854
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/pugneum-lexer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,27 @@ Lexer.prototype = {
i++;
break;
}
if (str[i] === '\\') {
++i;
switch (str[i]) {
case '\'':
value += '\'';
break;
case '"':
value += '"';
break;
case 'n':
value += '\n';
break;
case 't':
value += '\t';
break;
default:
value += str[i];
break;
}
++i;
}
} else {
if (this.whitespaceRe.test(str[i])) {
break;
Expand Down

0 comments on commit df56854

Please sign in to comment.