GitHub

Original file line numberDiff line numberDiff line change

@@ -443,7 +443,12 @@ mirb_highlight_print_line(mirb_highlighter *hl, const char *line)

443443
444444

size_t len = (size_t)(p - token_start);

445445
446-

if (is_const) {

446+

/* Check for hash key symbol syntax: identifier followed by ': ' */

447+

if (*p == ':' && (p[1] == ' ' || p[1] == '\0' || p[1] == ',' || p[1] == '}')) {

448+

p++; /* include the colon */

449+

print_colored(hl, token_start, (size_t)(p - token_start), MIRB_TOK_SYMBOL);

450+

}

451+

else if (is_const) {

447452

print_colored(hl, token_start, len, MIRB_TOK_CONSTANT);

448453

}

449454

else if (!after_dot && is_keyword(token_start, len)) {

@@ -476,16 +481,16 @@ mirb_highlight_print_result(mirb_highlighter *hl, const char *result)

476481

return;

477482

}

478483
484+

/* Print arrow in gray */

479485

if (hl->theme == MIRB_THEME_DARK) {

480486

fputs(DARK_ARROW " => " COLOR_RESET, stdout);

481-

fputs(DARK_RESULT, stdout);

482487

}

483488

else {

484489

fputs(LIGHT_ARROW " => " COLOR_RESET, stdout);

485-

fputs(LIGHT_RESULT, stdout);

486490

}

487-

fputs(result, stdout);

488-

fputs(COLOR_RESET "\n", stdout);

491+

/* Syntax highlight the result value */

492+

mirb_highlight_print_line(hl, result);

493+

putchar('\n');

489494

}

490495
491496

/*

Read the original on github.com ↗