Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Italicizing non-literal syntax? #1500

Open
paroche opened this issue Oct 22, 2019 · 4 comments
Open

Italicizing non-literal syntax? #1500

paroche opened this issue Oct 22, 2019 · 4 comments

Comments

@paroche
Copy link
Collaborator

paroche commented Oct 22, 2019

How about, when showing syntax like:

node.append(...nodes or strings) – append nodes or strings at the end of node,
node.prepend(...nodes or strings) – insert nodes or strings into the beginning of node,

that "node" (in this case), or whatever syntax is not literal, that is, that stands for some general type of thing, be put in italics, i.e., in this case, to have instead:

node.append(...nodes or strings) – append nodes or strings at the end of node,
node.prepend(...nodes or strings) – insert nodes or strings into the beginning of node,

(From: https://javascript.info/modifying-document)

I think that would make the meaning of the syntax clearer. Also, this is what MDN does in their Syntax descriptions, e.g.:

element.appendChild(aChild);
https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild

This would also address some of my earlier concerns with the use of "str", "array", "obj", etc. from a couple months ago.

@paroche
Copy link
Collaborator Author

paroche commented Oct 22, 2019

Or does that not work when entering code? Let me see:

attempt 1: node.append...

attempt 2: _node_.append....

Hmm. Seems to be hard to get them to work nicely together, to mix italicized and unitalicized in code block. Understandable, I guess, <code> mode being literal and unformatted and all. But maybe there's a nice elegant way?

@iliakan
Copy link
Member

iliakan commented Oct 29, 2019

Indeed, making things italic isn't a very good idea, because it doesn't look good.

Is there a real need and confusion here?

@paroche
Copy link
Collaborator Author

paroche commented Nov 5, 2019

I don't see why it has to not look good. It doesn't seem to work with backticks, but in regular HTML, having, for instance, <code><var>elem</var>.getElementById</code>, looks like this:

elem.getElementById

Which I think looks fine, and is also the way, for instance, Mozilla represents such things on their MDN web docs site.

And yes, I think it really helps to have the variable/shorthand portion of the code easily distinguished from the literal syntax part, especially when the syntax is being encountered for the first time and/or the reader is not accustomed to the conventions being used for variables and shorthand expressions. And that not having that can lead to confusion. This was, for instance, the case when I was having issues some time back with the use of 'var', 'arr', 'obj', etc. in code examples. I figured it out, but it slowed me down.

@Zearin
Copy link
Contributor

Zearin commented Jan 21, 2020

I strongly agree with the previous comment. I think <var> is one of the most under-used elements in HTML, and it is incredibly helpful for cases like the above.

Furthermore, although I also think italics are fine, they are just a default styling. Using <var> means you can style it with CSS like any other element. You can still use <var> to distinguish the “non-literal” syntax from its surroundings, but you could do it with color, font-weight, a border-bottom: 1px dashed #eee, or whatever else you want.

It’s flexible—and semantic! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants