diff --git a/package.json b/package.json
index cb1c7f9af772..9c13cb43459f 100644
--- a/package.json
+++ b/package.json
@@ -119,7 +119,6 @@
"redirect-webpack-plugin": "^1.0.0",
"remark": "^13.0.0",
"remark-autolink-headings": "^6.0.1",
- "remark-custom-blockquotes": "1.0.0",
"remark-emoji": "^2.1.0",
"remark-extract-anchors": "1.1.1",
"remark-frontmatter": "^3.0.0",
@@ -137,6 +136,7 @@
"static-site-generator-webpack-plugin": "^3.4.1",
"style-loader": "^2.0.0",
"tap-spot": "^1.1.1",
+ "unist-util-visit": "^2.0.3",
"webpack": "^5.11.1",
"webpack-bundle-analyzer": "^4.3.0",
"webpack-cli": "^4.3.1",
diff --git a/src/components/Markdown/Markdown.scss b/src/components/Markdown/Markdown.scss
index 7d3da27bbc47..2b93c10140f0 100644
--- a/src/components/Markdown/Markdown.scss
+++ b/src/components/Markdown/Markdown.scss
@@ -97,6 +97,7 @@ $topHeightMobileWithBanner: $bannerHeight + $topHeightMobile;
p,
blockquote,
+ aside,
table,
pre {
margin: 1em 0;
@@ -159,24 +160,21 @@ $topHeightMobileWithBanner: $bannerHeight + $topHeightMobile;
}
}
- blockquote {
+ aside {
border-left: 4px solid #dddddd;
padding: 0.75em 1em;
color: getColor(dove-grey);
- font-style: italic;
-
> :first-child {
margin-top: 0;
}
> :last-child {
margin-bottom: 0;
}
-
&.tip,
&.warning,
&.todo {
- border-left: none;
- border-radius: 3px;
+ border-left-width: 3px;
+ border-left-style: solid;
.tip-content {
font-style: italic;
@@ -185,21 +183,33 @@ $topHeightMobileWithBanner: $bannerHeight + $topHeightMobile;
code {
color: inherit;
}
+
+ > .tip__prefix,
+ > .warning__prefix,
+ > .todo__prefix {
+ text-transform: capitalize;
+ font-weight: 700;
+ color: #000;
+ font-size: getFontSize(1);
+ }
}
&.tip {
background-color: #eaf8ff;
color: #4e7182;
+ border-left-color: darken(#eaf8ff, 40%);
}
&.warning {
background-color: #fdf5d8;
color: #716b53;
+ border-left-color: darken(#fdf5d8, 40%);
}
&.todo {
background-color: #fbddcd;
color: #907a6e;
+ border-left-color: darken(#fbddcd, 40%);
.tip-content::before {
content: '[TODO]: ';
@@ -208,6 +218,20 @@ $topHeightMobileWithBanner: $bannerHeight + $topHeightMobile;
}
}
+ blockquote {
+ border-left: 4px solid #dddddd;
+ padding: 0.75em 1em;
+ color: getColor(dove-grey);
+ font-style: italic;
+
+ > :first-child {
+ margin-top: 0;
+ }
+ > :last-child {
+ margin-bottom: 0;
+ }
+ }
+
table {
margin: 1em 0;
diff --git a/src/remark-plugins/remark-custom-asides/__snapshots__/index.test.js.snap b/src/remark-plugins/remark-custom-asides/__snapshots__/index.test.js.snap
new file mode 100644
index 000000000000..edb6f5982712
--- /dev/null
+++ b/src/remark-plugins/remark-custom-asides/__snapshots__/index.test.js.snap
@@ -0,0 +1,6 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`customize blockquote should transform W> into aside of warning 1`] = `
+"
+"
+`;
diff --git a/src/remark-plugins/remark-custom-asides/index.js b/src/remark-plugins/remark-custom-asides/index.js
new file mode 100644
index 000000000000..15a3372f44d1
--- /dev/null
+++ b/src/remark-plugins/remark-custom-asides/index.js
@@ -0,0 +1,70 @@
+/**
+ * based on https://github.com/montogeek/remark-custom-blockquotes
+ */
+
+const visit = require('unist-util-visit');
+module.exports = function customAsides(
+ options = {
+ mapping: {},
+ }
+) {
+ const { mapping } = options;
+ return function transformer(tree) {
+ // looking for `paragraph` node
+ visit(tree, 'paragraph', visitor);
+ function visitor(node) {
+ const { children } = node;
+ const textNode = children[0].value;
+
+ // could be link/etc.
+ if (!textNode) return;
+
+ // looking for mapping in the beginning
+ const className = mapping[textNode.substr(0, 2)];
+ // >This is a joke <- ignore this
+ // >T hi there
+ const hasPostfixWhitespace = textNode.indexOf(' ') === 2;
+ if (className && hasPostfixWhitespace) {
+ // use `aside` element instead of `blockquote`
+ // which I believe is more suitable as per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside
+ node.data = {
+ hName: 'aside',
+ hProperties: {
+ className,
+ },
+ };
+
+ // remove custom characters from paragraph
+ node.children = [
+ {
+ type: 'heading',
+ depth: 6,
+ data: {
+ // see https://github.com/syntax-tree/mdast-util-to-hast#hname
+ // add a className to heading
+ hProperties: {
+ className: `${className}__prefix`,
+ },
+ },
+ children: [
+ {
+ type: 'text',
+ value: `${className}`,
+ },
+ ],
+ },
+ {
+ type: 'paragraph',
+ children: [
+ {
+ ...children[0],
+ value: children[0].value.slice(3),
+ },
+ ...children.slice(1),
+ ],
+ },
+ ];
+ }
+ }
+ };
+};
diff --git a/src/remark-plugins/remark-custom-asides/index.test.js b/src/remark-plugins/remark-custom-asides/index.test.js
new file mode 100644
index 000000000000..4d1c1b9ce8d9
--- /dev/null
+++ b/src/remark-plugins/remark-custom-asides/index.test.js
@@ -0,0 +1,24 @@
+import remark from 'remark';
+describe('customize blockquote', () => {
+ it('should transform W> into aside of warning', () => {
+ remark()
+ .use(require('./index.js'), {
+ mapping: {
+ 'W>': 'warning',
+ },
+ })
+ .use(require('remark-html'))
+ .process(
+ `
+W> hello world
+`,
+ function (err, { contents }) {
+ expect(err).toBeNull();
+ expect(contents).toContain('