Viewing 1 post (of 1 total)
  • Author
    Posts
  • #21919
    Yang Yang
    Participant

    Hello Yutaka,

    There is a trick I always want to play but failed every time. Could you kindly provide some enlightenment?

    Consider a simplistic scenario: to use ‘#’ as single-line comment marker in Highlight (2) for the Text configuration, like Markdown. Then, the “titles” can be nicely highlighted. But there is a problem: when ‘#’ appears inside a paragraph, the display is a mess:

    mess

    OK, just forget about Highlight (2), go to Highlight (1), and use a regular expression. But I really like Ctrl-K/Ctrl-Shift-K to toggle comments.

    Oh, why not use a trick?

    1. In Highlight (2), configure the comment marker.
    2. In Display, display the comment line nonhighlighted (black on white).
    3. In Highlight (1), add a regular expression ‘^#’ with a highlight color for its line.

    But this fails miserably. It turns out that Display has a higher priority over Highlight (1). This is quite reasonable; otherwise, Python strings like ‘hello#world’ won’t (easily) render right.

    Text is simple. A real-world scenario is LaTeX. Many URLs contain ‘%’, and when one appears inside a long paragraph, the display is hilarious. (Yes, I wrote my thesis and a book in LaTeX in EmEditor. Many thanks.)

    The “perfect” solution may be some dynamic engine to parse each type of language, but that’s too much. Instead, I can think of two practical workarounds:

    1. In Highlight (2), add an option to allow regular expressions as comment markers.
    2. In Highlight (1), add an option to allow a highlight word to take precedence over Display.

    Both methods can use look-behind regex to distinguish escaped comment markers (like ‘\%’ for LaTeX).

    What’s your idea, please?

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.