3
$\begingroup$

In a cell whose LanguageCategory option is "Input", boxes will be syntax-highlighted. Is there any way to diasble such cell-formatting behaviors for inner boxes?

Additional Requirement: No inline cells should be used. That makes the Tab key unable to be used for jumps between placeholders. (There're more side effects not mentioned for inline cells.)

Example

(* highlighted *)
CellPrint@Cell[BoxData@RowBox@{"boxA", "boxB"}, "Input"]

(* disable highlighting for one box with inline cells *)
CellPrint@Cell[BoxData@RowBox@{"boxA", Cell[BoxData@"boxB", LanguageCategory -> None]}, "Input"]

(* jumps between placeholders fails, so I don't want to use inline cells *)
CellPrint@Cell[BoxData@RowBox@{"boxA\[Placeholder]", Cell[BoxData@"boxB\[Placeholder]", LanguageCategory -> None]}, "Input"]

Other cell options to be screened

  • ShowStringCharacters
  • ... (Most of the options in StyleData["Input"] in Core.nb)
$\endgroup$

1 Answer 1

3
$\begingroup$

It seems that you can use the StyleBox:

StyleBox["boxB", LanguageCategory -> None]
(*highlighted*)CellPrint@
 Cell[BoxData @ RowBox @ {"boxA", StyleBox["boxB", LanguageCategory -> None]},   "Input"]

(*jumps between placeholders works*)
CellPrint @  Cell[ BoxData @ RowBox @ {
  "boxA\[Placeholder]", 
  StyleBox["boxB\[Placeholder]", LanguageCategory -> None]
},"Input"]

enter image description here

$\endgroup$
1
  • $\begingroup$ I find that I'd underestimated StyleBox so much after having tried Keys@Options@StyleBox. $\endgroup$
    – asd1dsa
    Oct 21, 2020 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.