Removal of redundant Markdown language headers #426
Replies: 8 comments 12 replies
-
I'm working on this at the moment. Honestly I wouldn't bring this up if it wasn't a real concern. There are a few principles I'd like to suggest:
Another option is:
OR have a convention that prose only refers downwards:
I think one problem with implicit things like this is that they're much less obvious for authors and reviewers. For that I suppose, although the HTML comments are horrible to write, they are at least very explicit. |
Beta Was this translation helpful? Give feedback.
-
It's also possibly worth distinguishing live samples in the reference documentation (i.e. anything with a page-type not equal to Live samples in the reference docs should follow a much more consistent structure than others, and extractability is much more of an issue for them. So we might want to do this only for reference documentation, and leave guide pages alone. |
Beta Was this translation helpful? Give feedback.
-
FYI I created a duplicate of this here: https://github.com/orgs/mdn/discussions/439 . I'm in favour. |
Beta Was this translation helpful? Give feedback.
-
If you want to test what it would look like without the headers, add the following to the css /* all H4 elements with an id of HTML */
h4[id="HTML"],
/* any h3-h6 heading where the id contains html or css, case insensitive, if that heading has a code-example as the next sibling *?
:is(h3, h4, h5, h6):where([id*="html" i],[id*="css" i]):has( + .code-example) {
/* don't display the heading */
display: none;
} |
Beta Was this translation helpful? Give feedback.
-
Following two options were prominent in the Editorial meeting yesterday. In order to make the decision we decided to have a poll. Choose one of the two options in the reply to this message. Any suggestions are welcomed too. Option AMove the code block caption to right so it won't be seen as repeated due to the headers: Option BRemove the language headers and restrict prose location either only at the top of all the code blocks or before each code block. No decision was made regarding this option. So if we choose this option we'll still have to decide how to arrange prose among code blocks. |
Beta Was this translation helpful? Give feedback.
-
I like "Option C" - remove the headers. Where's the evidence that extracting all or part of the example is actually useful? If it is useful where is the evidence that if MDN modifies an example it won't break those users? Unless we can actually show more than theoretical value a discussion of how we can go about keeping them seems a bit silly. |
Beta Was this translation helpful? Give feedback.
-
A tangential question: Could the headers of live examples show the full name of the code's language? E.g. "JavaScript" instead of "JS", "Markdown" instead of "MD". Update: Filed mdn/yari#9628. |
Beta Was this translation helpful? Give feedback.
-
My vote is for:
## Examples
### <example-specific section title, preferably worded as an action, such as "Creating...", "Demonstrating...">
"This example demonstrates..."
(Prose here should state the key objective of the example and possibly describe the situational set up.
Optional but recommended)
"In the code below, ..."
(any notable mentions about the HTML code, optional)
```
html live-sample___example_one
<p>Here's a paragraph</p>
```
"In the code below, ..."
(any notable mentions about the CSS code, optional)
```css live-sample___example_one
p {
background-color: pink;
}
```
{{EmbedLiveSample("example_one")}}
"You'll notice that...", "The span here is green because..."
(Statements to explain the resultant frame.
This is an upward explainer. Optional but recommended)
This can be applied to both ends of the code block to allow for prose placement before or after code. Too much text in the magic comments at the moment, which can be worked out further, but this is the general idea: <!-- example_one_prose -->
The example intro
<!-- example_one_html start -->
HTML code explainer
```html live-sample___example_one
```
If required, further explanation or highlights about the code
<!-- example_one_html end -->
<!-- example_one_css start -->
Notable points about the code
```css live-sample___example_one
```
<!-- example_one_css end -->
<!-- example_one_result start -->
{{EmbedLiveSample("example_one")}}
Further explanation or highlights about the code
<!-- example_one_result end --> |
Beta Was this translation helpful? Give feedback.
-
Introduction
The code sections on the MDN website are now showing the language in their captions. This has made the existing language headers written in markdown content redundant:
It is apparent that the repeated language mention is unnecessary. And many of us want to get rid of this boilerplate stuff in the Markdown content.
This discussion is about whether to keep the markdown headers(
### HTML
). And if we remove them then how it should be done.History
This header structure was adopted to collect the code from example sections to display embedded live sample outputs. For more information refer the original discussion on this implementation: #3548 [Markdown] Decide how to represent live samples.
In short two, out of three, options were prominent, and option 3 was selected.
Option 3: use headings implicitly
Heading levels (not heading IDs) were considered to group the HTML,CSS, and JS code blocks. This is what we have in use today.
This option was chosen because we wanted to have prose considered as part of the live samples as well and not just the code.
Option 2: use a class identifier on the code blocks
Mentioning this because now this has been implemented and it is ready to be used.
Concerns
Prose are part of the live sample and there won't be a way to distinguish them. If we remove these headers then there won't be a way to associate prose with corresponding code blocks.
I think this is a noble thought. But we have never capitalized on this grouping. Current macros extract only the code. These headers are not being used in the extraction, only the closest parent of the macro call is sought.
Let me know if there is any tool or third party extracting these prose using this association. Do we really have plans to extract entire live sample along with prose? A possibility was mentioned of including prose in the playground. Are we really going to do that?
Also, not all live samples are atomic. Some of them build on top of previous samples on the page, and some live samples mention previous samples. So such extraction of entire live samples would require rewording in a lot of them.
If we really don't have any plans for prose then we shouldn't keep this concern holding other stuff happening, e.g.
Option 2
mentioned above.Loss of coherence in some cases
If we simply remove the headers haphazardly then, in some cases it will be hard to tell if a discussion is referring to code block above or below it.
Should
### Result
header be removed too?If we add a customizable caption, with "Result" as default, to the output box then the
### Result
header would also become redundant.Please add to the list if you have any...
Stats
Note, only live samples with
#+ HTML
,#+ CSS
, and#+ JavaScript
headers are considered, because we are replacing that only.Live sample with only the headers and without prose - 1221 (989 files)
API - 389 files
CSS - 528 files
HTML - 43 files
Learn - 7 files
JS - 3 files
SVG - 11 files
Others - 8
Live samples with prose - 110 (95 files)
API - 43 files
CSS - 38 files
HTML - 9 files
Others - 5
Solutions
These solutions are not exclusive; we can combine them. Also, it should be ok if we keep some exceptional live samples as it is, because we are not changing the macro implementation so they will still keep working.
a. Replace the headers with magic comments to mark the prose boundaries
To keep the code-prose association intact we could simply replace the headers with HTML magic comments like this:
This way the headers won't be rendered and we'll have a way to separate sections.
b. Make code section language captions less prominent and don't remove any content headers.
This way the repetition won't be noticeable.
c. Simply remove headers where there are no prose. Sections that match following template.
I see no harm in doing this first if we decide to remove the headers.
d. Update headers with prose manually
Where it is not obvious, update prose mentioning which section they are referring:
We can do this after solution
c.
has been applied.e. do not touch meaningful headers
Let's not modify such cases. These will keep working as it is as we are not updating the macro behavior.
f. for result section add customizable title to the output box and remove those
### Result
headers as wellThe macro call may look like this
{{EmbedLiveSample("Example_one", 100%, 600px, "My Result")}}
:g. Do absolutely nothing keep the structure and code section captions as it is.
This is the easiest solution.
Plan
To be decided when we pick some of the solutions mentioned above. It'll be like raising an issue to track implementation of solutions c&f then d&f for each content areas.
Beta Was this translation helpful? Give feedback.
All reactions