css-tree
Version:
A tool set for CSS: fast detailed parser (CSS → AST), walker (AST traversal), generator (AST → CSS) and lexer (validation and matching) based on specs and browser implementations
19 lines (15 loc) • 406 B
JavaScript
import { Percentage } from '../../tokenizer/index.js';
export const name = 'Percentage';
export const structure = {
value: String
};
export function parse() {
return {
type: 'Percentage',
loc: this.getLocation(this.tokenStart, this.tokenEnd),
value: this.consumeNumber(Percentage)
};
}
export function generate(node) {
this.token(Percentage, node.value + '%');
}