TeXworks / texworks

Main codebase for TeXworks, a simple interface for working with TeX documents
https://tug.org/texworks/
GNU General Public License v2.0
700 stars 130 forks source link

better coloring for the ConTeXt scheme #809

Open ousia opened 7 years ago

ousia commented 7 years ago

From the following source:

\mainlanguage[es]
\setuppapersize[A5]
\starttext

\chapter{Introducción}

\ConTeXt\ es {\en\em a document generation system} en palabras de {\sc Hans Hagen}.
\stoptext

TeXworks displays the following:

brackets-texworks

But ConTeXt itself displays:

brackets-context-1

The two differences are:

  1. Brackets are also marked.
  2. All marked syntax is typeset with the bold font.

Just in case it helps, the complete ConTeXt source was:

\starttext
\startTEXpage[offset=1em]
\startTEX
\mainlanguage[es]
\setuppapersize[A5]
\starttext

\chapter{Introducción}

\ConTeXt\ es {\en\em a document generation system} en palabras de {\sc Hans Hagen}.
\stoptext
\stopTEX
\stopTEXpage
\stoptext
josephwright commented 7 years ago

I'm planning to look at some of the highlighting patterns shortly (will log an issue): perhaps I could 'take' this?

josephwright commented 7 years ago

I think it's worth noting here that the scheme TeXworks uses for ConTeXt is similar to that for plain or LaTeX. That's what I think I'd expect: the general 'style' is a choice of the editor. One might add square brackets to the 'known' characters (possibly also for LaTeX). Not sure I see the 'boldness' you mention, and I think at least as-standard I'd avoid that: might mess up monospacing and that will annoy a reasonable number of users.

ousia commented 7 years ago

@josephwright, many thanks for your replies.

The bold font is used:

$ pdffonts context-code.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
CZEXLI+LMMonoLt10-Bold               CID Type 0C       Identity-H       yes yes yes     10  0
ELMVVJ+LMMono12-Regular              CID Type 0C       Identity-H       yes yes yes     11  0

But it might be clearer with Cousine:

context-code

Or even with Inconsolata:

context-code-1

If the fixed with of a monospace bold font is different from its regular counterpart, the font is poorly designed.

Could you test whether the possibility you mention happens with a font family? (It doesn’t happen with the typewriter typefaces I use.)

Many thanks for your help.

josephwright commented 7 years ago

With an editor/IDE you can't be sure of the font the user will pick: somewhat different from producing code listings for documentation.

ousia commented 7 years ago

Of course, one can never know what a single user will do 😄.

How about implementing the conventions that ConTeXt itself proposes for its own code, see what happens with the bold font, and then decide whether it should be removed (or kept)?

josephwright commented 7 years ago

@ousia I'll take a look (I've got a few other minor suggestions in this area, as I said). One thing I'd rather retain is the idea that \start.../\stop... really should be highlighted differently from other control sequences. (Hans might not agree, but they have a particular structural role.)

josephwright commented 7 years ago

BTW, I notice that WinEdt (my other favoured editor on Windows) does use bold for some LaTeX syntax so this is perhaps a better idea than I thought :) I wonder if we might want something similar, but it relies on having a list of all keywords: not much fun in a regex.