···1313 * <bg_red> <bg_green> ... <bg_#RGB> <bg_#RRGGBB>
1414 * <bold> <dim> <ul> (underline)
1515 * <bold_red> <dim_cyan> etc - combine styles with underscores
1616+ * <bold+red> <dim+cyan+bg_blue> etc - combine styles with +
1617 * <#RRGGBB> or <#RGB> for arbitrary 24-bit foreground colors
1718 * <pad=N> ... </pad> - right-pad contents to N visible columns
1819 * <br/> - emit a newline, <br=N/> - emit N newlines
···367368}
368369369370static int compile_var_ref(program_t *p, var_table_t *vars, const char *tag, int len) {
371371+ const char *name = tag + 1;
370372 int nlen = len - 1;
373373+374374+ const char *plus = memchr(name, '+', nlen);
375375+ int var_nlen = plus ? (int)(plus - name) : nlen;
376376+371377 for (int i = 0; i < vars->count; i++) {
372372- if (nlen == vars->vars[i].nlen && memcmp(tag + 1, vars->vars[i].name, nlen) == 0) {
373373- emit_op(p, OP_STYLE_PUSH, 0);
374374- if (!compile_plus_segs(p, vars->vars[i].value, vars->vars[i].vlen)) return 0;
375375- emit_op(p, OP_STYLE_FLUSH, 0);
376376- return 1;
378378+ cprintf_var_t *v = &vars->vars[i];
379379+ if (var_nlen != v->nlen || memcmp(name, v->name, var_nlen) != 0) continue;
380380+381381+ emit_op(p, OP_STYLE_PUSH, 0);
382382+ if (!compile_plus_segs(p, v->value, v->vlen)) return 0;
383383+384384+ if (plus) {
385385+ const char *rest = plus + 1;
386386+ int rlen = nlen - var_nlen - 1;
387387+ if (rlen > 0 && !compile_plus_segs(p, rest, rlen)) return 0;
377388 }
389389+390390+ emit_op(p, OP_STYLE_FLUSH, 0);
391391+ return 1;
378392 }
393393+379394 return 0;
380395}
381396···431446 if (tag_prefix(tag, len, "bg_#")) {
432447 if (!compile_hex_bg(p, tag + 3, len - 3)) return 0;
433448 emit_op(p, OP_STYLE_FLUSH, 0); return 1;
449449+ }
450450+451451+ if (memchr(tag, '+', len)) {
452452+ if (compile_plus_segs(p, tag, len)) { emit_op(p, OP_STYLE_FLUSH, 0); return 1; }
434453 }
435454436455 const char *seg = tag;
+1-1
src/main.c
···304304 if (help->count > 0) {
305305 cprintf(
306306 "<let h=bold, arg=cyan/>"
307307- "<bold_red>Ant</> is a tiny JavaScript runtime and package manager (%s)<br=2/>"
307307+ "<$h+red>Ant</> is a tiny JavaScript runtime and package manager (%s)<br=2/>"
308308 "<$h>Usage: ant <yellow>[module.js]</yellow> <$arg>[...flags]</><reset/><br/>"
309309 "<$h><gap=7/>ant <<command>><gap=3/><$arg>[...args]</><reset/><br=2/>"
310310 "If no module file is specified, Ant starts in REPL mode.<br=2/>",