Adding documentation to literal.js
This commit is contained in:
parent
51c2f87765
commit
424eca0a2a
@ -1,13 +1,19 @@
|
|||||||
|
// Literal nodes are for plain strings in the regular expression. They are
|
||||||
|
// rendered as labels with the value of the literal quoted.
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
type: 'literal',
|
type: 'literal',
|
||||||
|
|
||||||
|
// Renders the literal into the currently set container.
|
||||||
_render() {
|
_render() {
|
||||||
return this.renderLabel(['\u201c', this.literal, '\u201d'])
|
return this.renderLabel(['\u201c', this.literal, '\u201d'])
|
||||||
.then(label => {
|
.then(label => {
|
||||||
var spans = label.selectAll('tspan');
|
var spans = label.selectAll('tspan');
|
||||||
|
|
||||||
|
// The quote marks get some styling to lighten their color so they are
|
||||||
|
// distinct from the actual literal value.
|
||||||
spans[0].addClass('quote');
|
spans[0].addClass('quote');
|
||||||
spans[2].addClass('quote');
|
spans[2].addClass('quote');
|
||||||
|
|
||||||
@ -20,12 +26,18 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Merges this literal with another. Literals come back as single characters
|
||||||
|
// during parsing, and must be post-processed into multi-character literals
|
||||||
|
// for rendering. This processing is done in [Match](./match.html).
|
||||||
merge(other) {
|
merge(other) {
|
||||||
this.literal += other.literal;
|
this.literal += other.literal;
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
// Value of the literal.
|
||||||
this.literal = this.properties.literal.textValue;
|
this.literal = this.properties.literal.textValue;
|
||||||
|
// Ordinal value of the literal for use in
|
||||||
|
// [CharsetRange](./charset_range.html).
|
||||||
this.ordinal = this.literal.charCodeAt(0);
|
this.ordinal = this.literal.charCodeAt(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user