diff --git a/docs/api-site-config.md b/docs/api-site-config.md index 5eaf86b72d..a51ddb2c08 100644 --- a/docs/api-site-config.md +++ b/docs/api-site-config.md @@ -149,6 +149,8 @@ h1 { `manifest` - Path to your web app manifest (e.g., `/manifest.json`). This will add a `` tag to `` with `rel` as `"manifest"` and `content` as the provided path. +`markdownOptions` - Override default [Remarkable options](https://github.com/jonschlinkert/remarkable#options) that will be used to render markdown. + `markdownPlugins` - An array of plugins to be loaded by Remarkable, the markdown parser and renderer used by Docusaurus. The plugin will receive a reference to the Remarkable instance, allowing custom parsing and rendering rules to be defined. `ogImage` - Local path to an Open Graph image (e.g., `img/myImage.png`). This image will show up when your site is shared on Facebook and other websites/apps where the Open Graph protocol is supported. diff --git a/v1/lib/core/renderMarkdown.js b/v1/lib/core/renderMarkdown.js index f7b071b874..27adace730 100644 --- a/v1/lib/core/renderMarkdown.js +++ b/v1/lib/core/renderMarkdown.js @@ -8,6 +8,7 @@ const hljs = require('highlight.js'); const Markdown = require('remarkable'); const prismjs = require('prismjs'); +const deepmerge = require('deepmerge'); const anchors = require('./anchors.js'); @@ -21,7 +22,7 @@ class MarkdownRenderer { constructor() { const siteConfig = require(`${CWD}/siteConfig.js`); - const md = new Markdown({ + let markdownOptions = { // Highlight.js expects hljs css classes on the code element. // This results in

       langPrefix: 'hljs css language-',
@@ -67,7 +68,18 @@ class MarkdownRenderer {
       },
       html: true,
       linkify: true,
-    });
+    };
+
+    // Allow overriding default options
+    if (siteConfig.markdownOptions) {
+      markdownOptions = deepmerge(
+        {},
+        markdownOptions,
+        siteConfig.markdownOptions,
+      );
+    }
+
+    const md = new Markdown(markdownOptions);
 
     // Register anchors plugin
     md.use(anchors);
diff --git a/v1/package.json b/v1/package.json
index 23ad698e58..84ef592615 100644
--- a/v1/package.json
+++ b/v1/package.json
@@ -3,7 +3,12 @@
   "description": "Easy to Maintain Open Source Documentation Websites",
   "version": "1.4.0",
   "license": "MIT",
-  "keywords": ["documentation", "websites", "open source", "docusaurus"],
+  "keywords": [
+    "documentation",
+    "websites",
+    "open source",
+    "docusaurus"
+  ],
   "repository": {
     "type": "git",
     "url": "https://github.com/facebook/Docusaurus.git"
@@ -14,7 +19,11 @@
     "start": "cd website && yarn start"
   },
   "jest": {
-    "testPathIgnorePatterns": ["/node_modules/", "__fixtures__", "v2"],
+    "testPathIgnorePatterns": [
+      "/node_modules/",
+      "__fixtures__",
+      "v2"
+    ],
     "testURL": "http://localhost/"
   },
   "bin": {