-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add md
as an alias for Markdown
#6338
Conversation
Oh my gosh this is awesome! Great, thanks! :) I was also thinking, after my last comment, alternatively, that there might be a more involved, but perhaps ultimately better solution, also for other coalescing extensions. |
We've got this already... it's the |
I looked at duplicates in that files. To see what else you could use the same “hack” for. Here’s the result. Giant table! Select to expand
Some explanation: To illustrate, let’s look at ` ```.inc `:
```.inc
mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
```
` ```inc `:
```inc
mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
```
For reference, ` ```asm `:
```asm
mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
```
For reference, ` ```php `:
```php
mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
```
mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
For reference, mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php? For reference, mov [con_handle],STD_OUTPUT_HANDLE ; assembly?
class PullRequest { static $_TSPEC; } // php?
Note that probably no one knows that you can use a dot in a info string like this! But it’s interesting to show the difference. It’s also important to understand that when an extension is listed but not classified as a name (so say Now, what you show in this PR, is that you can add an extension name which would otherwise be classified wrongly, without a dot as a name. To illustrate, |
Thanks @wooorm. That's way more than you really needed to do 🙇 Lets keep things simple and start with just this md/markdown case and consider the others as and when they come up. |
md
as an alias for Markdown
Hah, yeah. Also, TIL, you can put filenames and entire paths in there?! I never knew. Input: ```example.js
console.log(1)
```
```folder/to/index.tsx
export function huh() {
return <div />
}
``` Output: console.log(1) export function huh() {
return <div />
} |
@wooorm Wanna know another cool trick? In markup formats other than Markdown (Wikitext, reStructuredText, AsciiDoc, etc), you can achieve highlighted code-blocks using specially prepared HTML. Similar hacks exist for footnotes, diagrams, and equations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a fairly harmless addition to me.
Yeah, weird stuff in the depths of GitHub! I don’t know much about how the other languages work, but I did know you can embed things in markdown! I know of examples of mermaid, geojson, topojson, stl```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
```geojson
{
"type": "Point",
"coordinates": [-122.43, 37.77],
"properties": {"name": "SF", "marker-color": "ff6347"}
}
```
```topojson
{
"type": "Topology",
"objects": {
"example": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [-122.43, 37.77],
"properties": {"name": "SF", "marker-color": "ff6347"}
}
]
}
}
}
```
```stl
solid square
facet normal -1 0 0
outer loop
vertex 0 100 100
vertex 0 100 0
vertex 0 0 100
endloop
endfacet
facet normal -1 0 0
outer loop
vertex 0 0 100
vertex 0 100 0
vertex 0 0 0
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 100 100 100
vertex 0 100 100
vertex 100 0 100
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 100 0 100
vertex 0 100 100
vertex 0 0 100
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 100 100 0
vertex 100 100 100
vertex 100 0 0
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 100 0 0
vertex 100 100 100
vertex 100 0 100
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0 100 0
vertex 100 100 0
vertex 0 0 0
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0 0 0
vertex 100 100 0
vertex 100 0 0
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 100 100 100
vertex 100 100 0
vertex 0 100 100
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 0 100 100
vertex 100 100 0
vertex 0 100 0
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 100 0 0
vertex 100 0 100
vertex 0 0 0
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 0 0 0
vertex 100 0 100
vertex 0 0 100
endloop
endfacet
endsolid
``` |
GitHub includes several languages that have the same extensions. For example, `.cake` is used for CoffeeScript and for C#. But which one is used for ` ```cake `? The answer is complex. But this commit solves it, it removes duplicate extensions from languages that will not get highlighted as such if you use them. Practically, that means `.cake` is no longer present here as an extension for CoffeeScript. Previously, which language was chosen was decided based on in which order languages were loaded: later languages “won”. There are some cases, where the common extensions, such as `.md`, is *not* used to highlight as markdown, which one might expect. It’s instead highlighted as Lisp. That’s unfortunate, but it’s better to match how GitHub works, and these cases can be fixed upstream in `github/linguist`. Finally, an almost never used feature of fenced code blocks on GitHub, is that you can write explicit extensions (` ```.js `). Sometimes, when there is a dot, it maps to different languages. This project now matches GitHub in what values without a dot, and with a dot, map to. More info in: <github-linguist/linguist#6338>.
Those aren't specific to Markdown, GitHub-flavoured or otherwise. Watch:
That HTML output could've been prepared by any number of lightweight markup languages that GitHub supports, as the markup rendering pipeline essentially goes like: flowchart LR
Markup --> html1
html1[Raw HTML] --> html2
html2[Sanitised HTML] --> html3
html3[Code-blocks processed] --> html4
html4[Other stuff addded:<br/>tasklists, emoji, etc]
|
Good to know, just, my focus is markdown, and GH is a big player there :) |
Description
Many people use
```md
for Markdown codeblocks within Markdown files. This is currently only declared as an extension which is shared with "GCC Machine Description". When markup seesmd
it searches for the language name, aliases and then extensions in order, and as "GCC Machine Description" comes first alphabetically, Lisp syntax highlighting is applied and not Markdown.This resolves that by adding
md
as an alias to Markdown.🎩 to @wooorm in #6335 for bringing this to my attention and making me realise this could be resolved from Linguist 🙇
Checklist:
The final checkboxes aren't applicable as this is "fixing" a misclassification in markup, not Linguist.