Skip to content

Commit d4a3424

Browse files
authored
Updating docs for new renderable in markdown and mermaid file support (#26204)
1 parent ea6ac73 commit d4a3424

File tree

8 files changed

+186
-8
lines changed

8 files changed

+186
-8
lines changed
Loading
Loading
Loading
Loading

content/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ We use [Linguist](https://github.com/github/linguist) to perform language detect
6969
{% if mermaid %}
7070
## Creating diagrams
7171

72-
You can use Mermaid syntax to add diagrams. For more information, see "[Creating diagrams](/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams)."
72+
You can also use code blocks to create diagrams in Markdown. GitHub supports Mermaid, geoJSON, topoJSON, and ASCII STL syntax. For more information, see "[Creating diagrams](/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams)."
7373

7474
{% endif %}
75-
7675
## Further reading
7776

7877
- [{% data variables.product.prodname_dotcom %} Flavored Markdown Spec](https://github.github.com/gfm/)

content/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams.md

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ versions:
66
shortTitle: Create diagrams
77
---
88

9-
You can use Mermaid syntax to create diagrams. Mermaid is a Markdown-inspired tool that renders text into diagrams. For example, Mermaid can render flow charts, sequence diagrams, pie charts and more. For more information, see the [Mermaid documentation](https://mermaid-js.github.io/mermaid/#/).
9+
## About creating diagrams
10+
11+
You can create diagrams in Markdown using three different syntaxes: mermaid, geoJSON and topoJSON, and ASCII STL.
12+
13+
## Creating Mermaid diagrams
14+
15+
Mermaid is a Markdown-inspired tool that renders text into diagrams. For example, Mermaid can render flow charts, sequence diagrams, pie charts and more. For more information, see the [Mermaid documentation](https://mermaid-js.github.io/mermaid/#/).
1016

1117
To create a Mermaid diagram, add Mermaid syntax inside a fenced code block with the `mermaid` language identifier. For more information about creating code blocks, see "[Creating and highlighting code blocks](/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)."
1218

@@ -31,3 +37,122 @@ graph TD;
3137
**Note:** You may observe errors if you run a third-party Mermaid plugin when using Mermaid syntax on {% data variables.product.company_short %}.
3238

3339
{% endnote %}
40+
41+
## Creating geoJSON and topoJSON maps
42+
43+
You can use geo/topoJSON syntax to create interactive maps. To create a map, add geoJSON or topoJSON inside a fenced code block with the `geojson` or `topojson` syntax identifier. For more information, see "[Creating and highlighting code blocks](/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)."
44+
45+
### Using geoJSON
46+
47+
For example, you can create a simple map:
48+
49+
<pre>
50+
```geojson
51+
{
52+
"type": "Polygon",
53+
"coordinates": [
54+
[
55+
[-90,30],
56+
[-90,35],
57+
[-90,35],
58+
[-85,35],
59+
[-85,30]
60+
]
61+
]
62+
}
63+
```
64+
</pre>
65+
66+
![Rendered map](/assets/images/help/writing/fenced-geojson-rendered-map.png)
67+
68+
### Using topoJSON
69+
70+
For example, you can create a simple topoJSON map:
71+
72+
<pre>
73+
```topojson
74+
{
75+
"type": "Topology",
76+
"transform": {
77+
"scale": [0.0005000500050005, 0.00010001000100010001],
78+
"translate": [100, 0]
79+
},
80+
"objects": {
81+
"example": {
82+
"type": "GeometryCollection",
83+
"geometries": [
84+
{
85+
"type": "Point",
86+
"properties": {"prop0": "value0"},
87+
"coordinates": [4000, 5000]
88+
},
89+
{
90+
"type": "LineString",
91+
"properties": {"prop0": "value0", "prop1": 0},
92+
"arcs": [0]
93+
},
94+
{
95+
"type": "Polygon",
96+
"properties": {"prop0": "value0",
97+
"prop1": {"this": "that"}
98+
},
99+
"arcs": [[1]]
100+
}
101+
]
102+
}
103+
},
104+
"arcs": [[[4000, 0], [1999, 9999], [2000, -9999], [2000, 9999]],[[0, 0], [0, 9999], [2000, 0], [0, -9999], [-2000, 0]]]
105+
}
106+
```
107+
</pre>
108+
109+
![Rendered topojson map](/assets/images/help/writing/fenced-topojson-rendered-map.png)
110+
111+
For more information on working with `.geojson` and `.topojson` files, see "[Working with non-code files](/repositories/working-with-files/using-files/working-with-non-code-files#mapping-geojson-files-on-github)."
112+
113+
114+
## Creating STL 3D models
115+
116+
You can use ASCII STL syntax directly in markdown to create interactive 3D models. To display a model, add ASCII STL syntax inside a fenced code block with the `stl` syntax identifier. For more information, see "[Creating and highlighting code blocks](/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)."
117+
118+
For example, you can create a simple 3D model:
119+
120+
<pre>
121+
```stl
122+
solid cube_corner
123+
facet normal 0.0 -1.0 0.0
124+
outer loop
125+
vertex 0.0 0.0 0.0
126+
vertex 1.0 0.0 0.0
127+
vertex 0.0 0.0 1.0
128+
endloop
129+
endfacet
130+
facet normal 0.0 0.0 -1.0
131+
outer loop
132+
vertex 0.0 0.0 0.0
133+
vertex 0.0 1.0 0.0
134+
vertex 1.0 0.0 0.0
135+
endloop
136+
endfacet
137+
facet normal -1.0 0.0 0.0
138+
outer loop
139+
vertex 0.0 0.0 0.0
140+
vertex 0.0 0.0 1.0
141+
vertex 0.0 1.0 0.0
142+
endloop
143+
endfacet
144+
facet normal 0.577 0.577 0.577
145+
outer loop
146+
vertex 1.0 0.0 0.0
147+
vertex 0.0 1.0 0.0
148+
vertex 0.0 0.0 1.0
149+
endloop
150+
endfacet
151+
endsolid
152+
```
153+
</pre>
154+
155+
![Rendered 3D model](/assets/images/help/writing/fenced-stl-rendered-object.png)
156+
157+
For more information on working with `.stl` files, see "[Working with non-code files](/repositories/working-with-files/using-files/working-with-non-code-files#3d-file-viewer)."
158+

content/repositories/working-with-files/using-files/working-with-non-code-files.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ By default, the embedded renderer is 420 pixels wide by 620 pixels high, but you
130130

131131
{% endtip %}
132132

133+
{% if mermaid %}
134+
### Rendering in Markdown
135+
136+
You can embed ASCII STL syntax directly in Markdown. For more information, see "[Creating diagrams](/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-stl-3d-models)."
137+
{% endif %}
138+
133139
## Rendering CSV and TSV data
134140

135141
GitHub supports rendering tabular data in the form of *.csv* (comma-separated) and .*tsv* (tab-separated) files.
@@ -240,7 +246,7 @@ When you click the paper icon on the right, you'll also see the changes made to
240246

241247
![Source Render toggle screenshot](/assets/images/help/repository/source-render-toggle-geojson.png)
242248

243-
### Geometry Types
249+
### Geometry types
244250

245251
Maps on {% data variables.product.product_name %} use [Leaflet.js](http://leafletjs.com) and support all the geometry types outlined in [the geoJSON spec](http://www.geojson.org/geojson-spec.html) (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection). TopoJSON files should be type "Topology" and adhere to the [topoJSON spec](https://github.com/mbostock/topojson/wiki/Specification).
246252

@@ -281,6 +287,12 @@ By default, the embedded map 420px x 620px, but you can customize the output by
281287

282288
{% endtip %}
283289

290+
{% if mermaid %}
291+
### Mapping in Markdown
292+
293+
You can embed geoJSON and topoJSON directly in Markdown. For more information, see "[Creating diagrams](/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-geojson-and-topojson-maps)."
294+
{% endif %}
295+
284296
### Clustering
285297

286298
If your map contains a large number of markers (roughly over 750), GitHub will automatically cluster nearby markers at higher zoom levels. Simply click the cluster or zoom in to see individual markers.
@@ -299,7 +311,7 @@ Additionally, if your `.geojson` file is especially large (over 10 MB), it is no
299311

300312
It may still be possible to render the data by converting the `.geojson` file to [TopoJSON](https://github.com/mbostock/topojson), a compression format that, in some cases, can reduce filesize by up to 80%. Of course, you can always break the file into smaller chunks (such as by state or by year), and store the data as multiple files within the repository.
301313

302-
### Additional Resources
314+
### Further reading
303315

304316
* [Leaflet.js geojson documentation](http://leafletjs.com/examples/geojson.html)
305317
* [MapBox marker-styling documentation](http://www.mapbox.com/developers/simplestyle/)
@@ -327,3 +339,45 @@ $ jupyter nbconvert --to html <em>NOTEBOOK-NAME.ipynb</em>
327339

328340
- [Jupyter Notebook's GitHub repository](https://github.com/jupyter/jupyter_notebook)
329341
- [Gallery of Jupyter Notebooks](https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks)
342+
343+
{% if mermaid %}
344+
## Displaying mermaid files on {% data variables.product.prodname_dotcom %}
345+
346+
{% data variables.product.product_name %} supports rendering Mermaid files within repositories. Commit the file as you would normally using a `.mermaid` or `.mmd` extension. Then, navigate to the path of the Mermaid file on {% data variables.product.prodname_dotcom %}.
347+
348+
For example, if you add a `.mmd` file with the following content to your repository:
349+
350+
```
351+
graph TD
352+
A[Friend's Birthday] -->|Get money| B(Go shopping)
353+
B --> C{Let me think}
354+
C -->|One| D["Cool <br> Laptop"]
355+
C -->|Two| E[iPhone]
356+
C -->|Three| F[fa:fa-car Car]
357+
```
358+
359+
When you view the file in the repository, it is rendered as a flow chart.
360+
![Rendered mermaid file diagram](/assets/images/help/repository/mermaid-file-diagram.png)
361+
362+
### Troubleshooting
363+
364+
If your chart does not render at all, verify that it contains valid Mermaid Markdown syntax by checking your chart with the [Mermaid live editor](https://mermaid.live/edit).
365+
366+
If the chart displays, but does not appear as you'd expect, you can create a new [feedback discussion](https://github.com/github/feedback/discussions/categories/general-feedback), and add the `mermaid` tag.
367+
368+
#### Known issues
369+
370+
* Sequence diagram charts frequently render with additional padding below the chart, with more padding added as the chart size increases. This is a known issue with the mMermaid library.
371+
* Actor nodes with popover menus do not work as expected within sequence diagram charts. This is due to a discrepancy in how JavaScript events are added to a chart when the Mermaid library's API is used to render a chart.
372+
* Not all charts are a11y compliant. This may affect users who rely on a screen reader.
373+
374+
### Mermaid in Markdown
375+
376+
You can embed Mermaid syntax directly in Markdown. For more information, see "[Creating diagrams](/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams)."
377+
378+
### Further reading
379+
380+
* [Mermaid.js documentation](https://mermaid-js.github.io/mermaid/#/)
381+
* [Mermaid.js live editor](https://mermaid.live/edit)
382+
{% endif %}
383+

data/features/mermaid.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Issue 5812 and 6172
2-
# Mermaid syntax support
1+
# Issues 5812 and 6172, also 6411
2+
# Mermaid syntax support, also ASCII STL and geoJSON/topoJSON syntax support
33
versions:
44
fpt: '*'
55
ghec: '*'
6-
ghes: '>=3.5'
6+
ghes: '>=3.6'
77
ghae: 'issue-6172'

0 commit comments

Comments
 (0)