aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast.h1
-rw-r--r--src/compile.c3
-rw-r--r--src/parse.c3
3 files changed, 5 insertions, 2 deletions
diff --git a/src/ast.h b/src/ast.h
index 441fde81..44698628 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -179,6 +179,7 @@ struct ast_s {
struct {
const char *lang;
ast_list_t *children;
+ bool colorize:1;
} TextJoin;
struct {
const char *path;
diff --git a/src/compile.c b/src/compile.c
index 6cb25de0..40d9ed4e 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -2775,6 +2775,7 @@ CORD compile(env_t *env, ast_t *ast)
}
case TextJoin: {
const char *lang = Match(ast, TextJoin)->lang;
+ const char *colorize = Match(ast, TextJoin)->colorize ? "yes" : "no";
type_t *text_t = lang ? Table$str_get(*env->types, lang) : TEXT_TYPE;
if (!text_t || text_t->tag != TextType)
@@ -2811,7 +2812,7 @@ CORD compile(env_t *env, ast_t *ast)
if (chunk_t->tag == TextType)
chunk_code = compile(env, chunk->ast);
else
- chunk_code = compile_string(env, chunk->ast, "no");
+ chunk_code = compile_string(env, chunk->ast, colorize);
} else {
code_err(chunk->ast, "I don't know how to convert ", type_to_str(chunk_t), " to ", type_to_str(text_t));
}
diff --git a/src/parse.c b/src/parse.c
index d142e780..fd37fec7 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1306,7 +1306,8 @@ PARSER(parse_text) {
bool allow_escapes = (open_quote != '`');
ast_list_t *chunks = _parse_text_helper(ctx, &pos, open_quote, close_quote, open_interp, allow_escapes);
- return NewAST(ctx->file, start, pos, TextJoin, .lang=lang, .children=chunks);
+ bool colorize = match(&pos, "~") && match_word(&pos, "colorized");
+ return NewAST(ctx->file, start, pos, TextJoin, .lang=lang, .children=chunks, .colorize=colorize);
}
PARSER(parse_path) {