ModelicaSpecification icon indicating copy to clipboard operation
ModelicaSpecification copied to clipboard

How to mark short inline code listings

Open HansOlsson opened this issue 3 years ago • 2 comments

As noted we now have single quotes around small language fragments; as far as I can see it was added for some in https://github.com/modelica/ModelicaSpecification/pull/2726 in a commit named "Migrate remaining glossary entries".

I understand there might be some need for disambiguating small Modelica-fragments from non-Modelica code in the rendered text, but I don't see that there were any discussion about this change, and I also see suggestions for using special markings for spaces indicating that it doesn't suffice.

The issues I see with this solution are:

  • It is not automated.
  • There are no 100% clear rules when it applies; the ideal would be to apply the same rule to all for inline fragments - but having single quotes around all inline code fragments would be too much.
  • (A less important issue is that we cannot tell Modelica and grammar-fragments apart.)

The most obvious alternative would seem to be to have a slightly different background color for all inline fragments (think a whiter shader of lightgray - not yellow), but lstinline does not support that out of the box. However it seems possible: https://tex.stackexchange.com/questions/30845/how-to-redefine-lstinline-to-automatically-highlight-or-draw-frames-around-all/30851 (except that it fails for line-breaks).

HansOlsson avatar May 23 '22 09:05 HansOlsson

This style was not introduced in #2726. Before that commit, there were 48 occurrences of the pattern, and after the commit there were 49.

Sure, it can be seen as a pity that it isn't automated, but as long as we have guidelines in our style guide I am hopeful that we will manage to have the document in a decent shape.

I've searched the document, and there is currently only one place where the single quotes are used on something which isn't a single character piece of inline code, but this looks like a case where we could have used double quotes instead:

  • `\lstinline!2.!'

The document currently doesn't have quotes around variable names, even when they consist of just a single character. This makes sense to me, as the change of style is generally clear for letters.

The bigger inconsistency is that we haven't applied the strategy to all single character, non-letter, pieces of inline code.

henrikt-ma avatar May 23 '22 10:05 henrikt-ma

  • (A less important issue is that we cannot tell Modelica and grammar-fragments apart.)

To me this is a solved problem: As soon as there are identifiers in the code, you can tell grammar apart from Modelica.

henrikt-ma avatar May 23 '22 10:05 henrikt-ma

Phone meeting: Not for identifiers, but for other small arguments. Not urgent to make consistent - should be mentioned in notation section.

HansOlsson avatar Dec 14 '22 16:12 HansOlsson