|
|
|
|
@ -3,7 +3,6 @@ import { x } from 'code-red';
|
|
|
|
|
|
|
|
|
|
/** @extends Wrapper */
|
|
|
|
|
export default class TextWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
/** @type {import('../../nodes/Text.js').default} */
|
|
|
|
|
node;
|
|
|
|
|
|
|
|
|
|
@ -27,7 +26,9 @@ export default class TextWrapper extends Wrapper {
|
|
|
|
|
super(renderer, block, parent, node);
|
|
|
|
|
this.skip = this.node.should_skip();
|
|
|
|
|
this._data = data;
|
|
|
|
|
this.var = /** @type {unknown} */ /** @type {import('estree').Identifier} */ (((this.skip ? null : x `t`)));
|
|
|
|
|
this.var = /** @type {unknown} */ /** @type {import('estree').Identifier} */ (
|
|
|
|
|
this.skip ? null : x`t`
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
use_space() {
|
|
|
|
|
return this.node.use_space();
|
|
|
|
|
@ -48,8 +49,7 @@ export default class TextWrapper extends Wrapper {
|
|
|
|
|
* @param {import('estree').Identifier} parent_nodes
|
|
|
|
|
*/
|
|
|
|
|
render(block, parent_node, parent_nodes) {
|
|
|
|
|
if (this.skip)
|
|
|
|
|
return;
|
|
|
|
|
if (this.skip) return;
|
|
|
|
|
const use_space = this.use_space();
|
|
|
|
|
const string_literal = {
|
|
|
|
|
type: 'Literal',
|
|
|
|
|
@ -59,14 +59,14 @@ export default class TextWrapper extends Wrapper {
|
|
|
|
|
end: this.renderer.locate(this.node.end)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
block.add_element(this.var, use_space ? x `@space()` : x `@text(${string_literal})`, parent_nodes &&
|
|
|
|
|
block.add_element(
|
|
|
|
|
this.var,
|
|
|
|
|
use_space ? x`@space()` : x`@text(${string_literal})`,
|
|
|
|
|
parent_nodes &&
|
|
|
|
|
(use_space
|
|
|
|
|
? x `@claim_space(${parent_nodes})`
|
|
|
|
|
: x `@claim_text(${parent_nodes}, ${string_literal})`),
|
|
|
|
|
/** @type {import('estree').Identifier} */ (parent_node));
|
|
|
|
|
? x`@claim_space(${parent_nodes})`
|
|
|
|
|
: x`@claim_text(${parent_nodes}, ${string_literal})`),
|
|
|
|
|
/** @type {import('estree').Identifier} */ (parent_node)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|