“0..*” Animal
Dog : +fetch()
Cat : +purr()
Bird : +sing() ``` ````
It will be presented as:
classDiagram
direction LR
class Animal {
+String species
+int age
+makeSound()
}
class Dog {
+String breed
+bark()
}
class Cat {
+String color
+meow()
}
class Bird {
+String wingSpan
+fly()
}
class Owner {
+String name
+int age
+adoptAnimal(Animal animal)
}
Animal <|-- Dog
Animal <|-- Cat
Animal <|-- Bird
Owner "1" --> "0..*" Animal
Dog : +fetch()
Cat : +purr()
Bird : +sing()
With Mermaid, you can easily add clear and dynamic diagrams to enhance your blog content.
This theme also supports integrating Diff2Html, a tool that beautifully renders code differences (diffs) directly in markdown. Diff2Html is ideal for showcasing code changes, allowing you to clearly present additions, deletions, and modifications. It’s perfect for code reviews, documentation, and tutorials where step-by-step code changes need to be highlighted—you can even introduce changes across multiple files at once.
```diff2html
diff --git a/utils/mathUtils.js b/utils/mathUtils.js
index 3b5f3d1..c7f9b2e 100644
--- a/utils/mathUtils.js
+++ b/utils/mathUtils.js
@@ -1,8 +1,12 @@
-// Basic math utilities
+// Extended math utilities with additional functions
-export function calculateArea(radius) {
- const PI = 3.14159;
+export function calculateCircleMetrics(radius) {
+ const PI = Math.PI;
const area = PI * radius ** 2;
+ const circumference = 2 * PI * radius;
+
+ if (!isValidRadius(radius)) throw new Error("Invalid radius");
+
return { area, circumference };
}
-export function validateRadius(radius) {
+export function isValidRadius(radius) {
return typeof radius === 'number' && radius > 0;
}
diff --git a/main.js b/main.js
index 5f6a9c3..b7d4e8f 100644
--- a/main.js
+++ b/main.js
@@ -2,9 +2,12 @@
import { calculateCircleMetrics } from './utils/mathUtils';
-function displayCircleMetrics(radius) {
- const { area } = calculateCircleMetrics(radius);
+function displayCircleMetrics(radius) {
+ const { area, circumference } = calculateCircleMetrics(radius);
console.log(`Area: ${area}`);
+ console.log(`Circumference: ${circumference}`);
}
-displayCircleMetrics(5);
+try {
+ displayCircleMetrics(5);
+} catch (error) {
+ console.error("Error:", error.message);
+}
```
Here’s how it will look when rendered with Diff2Html:
diff --git a/utils/mathUtils.js b/utils/mathUtils.js
index 3b5f3d1..c7f9b2e 100644
--- a/utils/mathUtils.js
+++ b/utils/mathUtils.js
@@ -1,8 +1,12 @@
-// Basic math utilities
+// Extended math utilities with additional functions
-export function calculateArea(radius) {
- const PI = 3.14159;
+export function calculateCircleMetrics(radius) {
+ const PI = Math.PI;
const area = PI * radius ** 2;
+ const circumference = 2 * PI * radius;
+
+ if (!isValidRadius(radius)) throw new Error("Invalid radius");
+
return { area, circumference };
}
-export function validateRadius(radius) {
+export function isValidRadius(radius) {
return typeof radius === 'number' && radius > 0;
}
diff --git a/main.js b/main.js
index 5f6a9c3..b7d4e8f 100644
--- a/main.js
+++ b/main.js
@@ -2,9 +2,12 @@
import { calculateCircleMetrics } from './utils/mathUtils';
-function displayCircleMetrics(radius) {
- const { area } = calculateCircleMetrics(radius);
+function displayCircleMetrics(radius) {
+ const { area, circumference } = calculateCircleMetrics(radius);
console.log(`Area: ${area}`);
+ console.log(`Circumference: ${circumference}`);
}
-displayCircleMetrics(5);
+try {
+ displayCircleMetrics(5);
+} catch (error) {
+ console.error("Error:", error.message);
+}
Leaflet is created by Ukrainian software engineer Volodymyr Agafonkin, allowing interactive maps to be embedded in webpages. With support for GeoJSON data, Leaflet allows you to highlight specific regions, making it easy to visualize geographical information in detail.
You can use the following code to load map information on OpenStreetMap:
```geojson
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Crimea",
"popupContent": "Occupied Crimea"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
33.9,
45.3
],
[
36.5,
45.3
],
[
36.5,
44.4
],
[
33.9,
44.4
],
[
33.9,
45.3
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Donetsk",
"popupContent": "Occupied Donetsk"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
37.5,
48.5
],
[
39.5,
48.5
],
[
39.5,
47.5
],
[
37.5,
47.5
],
[
37.5,
48.5
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Luhansk",
"popupContent": "Occupied Luhansk"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
38.5,
49.5
],
[
40.5,
49.5
],
[
40.5,
48.5
],
[
38.5,
48.5
],
[
38.5,
49.5
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Kherson",
"popupContent": "Occupied Kherson"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
32.3,
47.3
],
[
34.3,
47.3
],
[
34.3,
46.3
],
[
32.3,
46.3
],
[
32.3,
47.3
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Zaporizhzhia",
"popupContent": "Occupied Zaporizhzhia"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
34.3,
48
],
[
36.3,
48
],
[
36.3,
47
],
[
34.3,
47
],
[
34.3,
48
]
]
]
}
}
]
}
```
The rendered map below highlights the regions of Ukraine that have been illegally occupied by Russia over the years, including Crimea and the four eastern regions:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Crimea",
"popupContent": "Occupied Crimea"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
33.9,
45.3
],
[
36.5,
45.3
],
[
36.5,
44.4
],
[
33.9,
44.4
],
[
33.9,
45.3
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Donetsk",
"popupContent": "Occupied Donetsk"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
37.5,
48.5
],
[
39.5,
48.5
],
[
39.5,
47.5
],
[
37.5,
47.5
],
[
37.5,
48.5
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Luhansk",
"popupContent": "Occupied Luhansk"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
38.5,
49.5
],
[
40.5,
49.5
],
[
40.5,
48.5
],
[
38.5,
48.5
],
[
38.5,
49.5
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Kherson",
"popupContent": "Occupied Kherson"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
32.3,
47.3
],
[
34.3,
47.3
],
[
34.3,
46.3
],
[
32.3,
46.3
],
[
32.3,
47.3
]
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Zaporizhzhia",
"popupContent": "Occupied Zaporizhzhia"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
34.3,
48
],
[
36.3,
48
],
[
36.3,
47
],
[
34.3,
47
],
[
34.3,
48
]
]
]
}
}
]
}
Chart.js is a versatile JavaScript library for creating responsive and interactive charts. Supporting multiple chart types like bar, line, pie, and radar, it’s an ideal tool for visualizing data directly in webpages.
Here’s an example of a JSON-style configuration that creates a bar chart in Chart.js:
```chartjs
{
"type": "bar",
"data": {
"labels": ["2017", "2018", "2019", "2020", "2021"],
"datasets": [
{
"label": "Population (millions)",
"data": [12, 15, 13, 14, 16],
"backgroundColor": "rgba(54, 162, 235, 0.6)",
"borderColor": "rgba(54, 162, 235, 1)",
"borderWidth": 1
}
]
},
"options": {
"scales": {
"y": {
"beginAtZero": true
}
}
}
}
```
The rendered bar chart illustrates population data from 2017 to 2021:
{
"type": "bar",
"data": {
"labels": ["2017", "2018", "2019", "2020", "2021"],
"datasets": [
{
"label": "Population (millions)",
"data": [12, 15, 13, 14, 16],
"backgroundColor": "rgba(54, 162, 235, 0.6)",
"borderColor": "rgba(54, 162, 235, 1)",
"borderWidth": 1
}
]
},
"options": {
"scales": {
"y": {
"beginAtZero": true
}
}
}
}
ECharts is a powerful visualization library from Apache that supports a wide range of interactive charts, including more advanced types such as scatter plots, heatmaps, and geographic maps.
The following JSON configuration creates a visually enhanced line chart that displays monthly sales data for two products.
```echarts
{
"title": {
"text": "Monthly Sales Comparison",
"left": "center"
},
"tooltip": {
"trigger": "axis",
"backgroundColor": "rgba(50, 50, 50, 0.7)",
"borderColor": "#777",
"borderWidth": 1,
"textStyle": {
"color": "#fff"
}
},
"legend": {
"data": ["Product A", "Product B"],
"top": "10%"
},
"xAxis": {
"type": "category",
"data": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"axisLine": {
"lineStyle": {
"color": "#888"
}
}
},
"yAxis": {
"type": "value",
"axisLine": {
"lineStyle": {
"color": "#888"
}
},
"splitLine": {
"lineStyle": {
"type": "dashed"
}
}
},
"series": [
{
"name": "Product A",
"type": "line",
"smooth": true,
"data": [820, 932, 901, 934, 1290, 1330, 1320, 1400, 1450, 1500, 1600, 1650],
"itemStyle": {
"color": "#5470C6"
},
"lineStyle": {
"width": 3
},
"areaStyle": {
"color": {
"type": "linear",
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"colorStops": [
{ "offset": 0, "color": "rgba(84, 112, 198, 0.5)" },
{ "offset": 1, "color": "rgba(84, 112, 198, 0)" }
]
}
},
"emphasis": {
"focus": "series"
}
},
{
"name": "Product B",
"type": "line",
"smooth": true,
"data": [620, 732, 701, 734, 1090, 1130, 1120, 1200, 1250, 1300, 1400, 1450],
"itemStyle": {
"color": "#91CC75"
},
"lineStyle": {
"width": 3
},
"areaStyle": {
"color": {
"type": "linear",
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"colorStops": [
{ "offset": 0, "color": "rgba(145, 204, 117, 0.5)" },
{ "offset": 1, "color": "rgba(145, 204, 117, 0)" }
]
}
},
"emphasis": {
"focus": "series"
}
}
]
}
```
The rendered output is shown below, and you can also interact with it using your mouse:
{
"title": {
"text": "Monthly Sales Comparison",
"left": "center"
},
"tooltip": {
"trigger": "axis",
"backgroundColor": "rgba(50, 50, 50, 0.7)",
"borderColor": "#777",
"borderWidth": 1,
"textStyle": {
"color": "#fff"
}
},
"legend": {
"data": ["Product A", "Product B"],
"top": "10%"
},
"xAxis": {
"type": "category",
"data": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"axisLine": {
"lineStyle": {
"color": "#888"
}
}
},
"yAxis": {
"type": "value",
"axisLine": {
"lineStyle": {
"color": "#888"
}
},
"splitLine": {
"lineStyle": {
"type": "dashed"
}
}
},
"series": [
{
"name": "Product A",
"type": "line",
"smooth": true,
"data": [820, 932, 901, 934, 1290, 1330, 1320, 1400, 1450, 1500, 1600, 1650],
"itemStyle": {
"color": "#5470C6"
},
"lineStyle": {
"width": 3
},
"areaStyle": {
"color": {
"type": "linear",
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"colorStops": [
{ "offset": 0, "color": "rgba(84, 112, 198, 0.5)" },
{ "offset": 1, "color": "rgba(84, 112, 198, 0)" }
]
}
},
"emphasis": {
"focus": "series"
}
},
{
"name": "Product B",
"type": "line",
"smooth": true,
"data": [620, 732, 701, 734, 1090, 1130, 1120, 1200, 1250, 1300, 1400, 1450],
"itemStyle": {
"color": "#91CC75"
},
"lineStyle": {
"width": 3
},
"areaStyle": {
"color": {
"type": "linear",
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"colorStops": [
{ "offset": 0, "color": "rgba(145, 204, 117, 0.5)" },
{ "offset": 1, "color": "rgba(145, 204, 117, 0)" }
]
}
},
"emphasis": {
"focus": "series"
}
}
]
}
Vega-Lite is a declarative visualization grammar that allows users to create, share, and customize a wide range of interactive data visualizations. The following JSON configuration generates a straightforward bar chart:
```vega_lite
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55},
{"category": "C", "value": 43},
{"category": "D", "value": 91},
{"category": "E", "value": 81},
{"category": "F", "value": 53},
{"category": "G", "value": 19},
{"category": "H", "value": 87}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.1
},
{
"name": "yscale",
"type": "linear",
"domain": {"data": "table", "field": "value"},
"nice": true,
"range": "height"
}
],
"axes": [
{"orient": "bottom", "scale": "xscale"},
{"orient": "left", "scale": "yscale"}
],
"marks": [
{
"type": "rect",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "category"},
"width": {"scale": "xscale", "band": 0.8},
"y": {"scale": "yscale", "field": "value"},
"y2": {"scale": "yscale", "value": 0},
"fill": {"value": "steelblue"}
},
"update": {
"fillOpacity": {"value": 1}
},
"hover": {
"fill": {"value": "orange"}
}
}
}
]
}
```
The rendered output shows a clean and simple bar chart with a hover effect:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55},
{"category": "C", "value": 43},
{"category": "D", "value": 91},
{"category": "E", "value": 81},
{"category": "F", "value": 53},
{"category": "G", "value": 19},
{"category": "H", "value": 87}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.1
},
{
"name": "yscale",
"type": "linear",
"domain": {"data": "table", "field": "value"},
"nice": true,
"range": "height"
}
],
"axes": [
{"orient": "bottom", "scale": "xscale"},
{"orient": "left", "scale": "yscale"}
],
"marks": [
{
"type": "rect",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "category"},
"width": {"scale": "xscale", "band": 0.8},
"y": {"scale": "yscale", "field": "value"},
"y2": {"scale": "yscale", "value": 0},
"fill": {"value": "steelblue"}
},
"update": {
"fillOpacity": {"value": 1}
},
"hover": {
"fill": {"value": "orange"}
}
}
}
]
}
TikZ is a powerful LaTeX-based drawing tool powered by TikZJax. You can easily port TikZ drawings from papers, posters, and notes. For example, we can use the following code to illustrate Euler’s formula $ e^{i \theta} = \cos \theta + i \sin \theta $:
<script type="text/tikz">
\begin{tikzpicture}
\filldraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);
\draw[->, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
\draw[->, thick] (0,-2.5) -- (0,2.5) node[above] {Im};
\draw[->, thick, color=purple] (0,0) -- (1.5,1.5);
\node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};
\draw[thick] (0.7,0) arc (0:45:0.7);
\node at (0.9, 0.3) {$\theta$};
\draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
\draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
\node at (2.2, 0) [below] {1};
\node at (0, 2.2) [left] {$i$};
\node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
\end{tikzpicture}
</script>
The rendered output is shown below, displayed as a vector graphic:
Typograms are a way of combining text and graphics to convey information in a clear and visually engaging manner. Typograms are particularly effective for illustrating simple diagrams, charts, and concept visuals where text and graphics are closely integrated. The following example demonstrates a simple Typogram:
```typograms
___________________
/ /|
/__________________/ |
| | |
| Distill | |
| | |
| | /
|__________________|/
```
The rendered output is shown below:
___________________
/ /|
/__________________/ |
| | |
| Distill | |
| | |
| | /
|__________________|/
The main text column is referred to as the body. It is the assumed layout of any direct descendants of the d-article
element.
.l-body
For images you want to display a little larger, try .l-page
:
.l-page
All of these have an outset variant if you want to poke out from the body text a little bit. For instance:
.l-body-outset
.l-page-outset
Occasionally you’ll want to use the full browser width. For this, use .l-screen
. You can also inset the element a little from the edge of the browser by using the inset variant.
.l-screen
.l-screen-inset
The final layout is for marginalia, asides, and footnotes. It does not interrupt the normal flow of .l-body
sized text except on mobile screen sizes.
.l-gutter
Emphasis, aka italics, with asterisks (*asterisks*
) or underscores (_underscores_
).
Strong emphasis, aka bold, with asterisks or underscores.
Combined emphasis with asterisks and underscores.
Strikethrough uses two tildes. Scratch this.
⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we’ll use three here to also align the raw Markdown).
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
Unordered list can use asterisks
Or minuses
Or pluses
I’m an inline-style link with title
You can use numbers for reference-style link definitions
Or leave it empty and use the link text itself.
URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or http://www.example.com and sometimes example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
Here’s our logo (hover to see the title text):
Inline-style:
Reference-style:
Inline code
has back-ticks around
it.
var s = "JavaScript syntax highlighting";
alert(s);
s = "Python syntax highlighting"
print s
No language indicated, so no syntax highlighting.
But let's throw in a <b>tag</b>.
Colons can be used to align columns.
Tables | Are | Cool |
---|---|---|
col 3 is | right-aligned | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don’t need to make the raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty |
---|---|---|
Still | renders | nicely |
1 | 2 | 3 |
Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.
Quote break.
This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can put Markdown into a blockquote.
Here’s a line for us to start with.
This line is separated from the one above by two newlines, so it will be a separate paragraph.
This line is also a separate paragraph, but… This line is only separated by a single newline, so it’s a separate line in the same paragraph. –>