mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 10:52:35 +02:00
[markdown] Switch to Remarkable (#153)
* Switch to Remarkable * Clean up references to custom code blocks * Remove valdiateDOMNesting warning * Add syntax highlighting * Add Reason support * Breaking change: prismColor to codeColor, remove CompLibrary.Prism, expose hljs * Completely remove Prism and associated CSS rules * Support loading plugins and scripts * Remove CSS rules, allowing Highlight.js theme to be used entirely * Remove unnecessary webplayer script
This commit is contained in:
parent
58613545b6
commit
b832176dc6
18 changed files with 231 additions and 2744 deletions
|
@ -17,7 +17,7 @@ Documents use the following markdown header fields that are enclosed by a line `
|
|||
|
||||
For example:
|
||||
|
||||
```markup
|
||||
```
|
||||
---
|
||||
id: doc1
|
||||
title: My Document
|
||||
|
@ -29,7 +29,7 @@ Versioned documents have their ids altered to include the version number when th
|
|||
|
||||
For example:
|
||||
|
||||
```markup
|
||||
```
|
||||
---
|
||||
id: version-1.0.0-doc1
|
||||
title: My Document
|
||||
|
@ -52,7 +52,7 @@ Blog Posts use the following markdown header fields that are enclosed by a line
|
|||
|
||||
For example:
|
||||
|
||||
```markup
|
||||
```
|
||||
---
|
||||
title: My First Blog Post
|
||||
author: Frank Li
|
||||
|
@ -91,9 +91,10 @@ Example:
|
|||
|
||||
You can make an autogenerated list of links, which can be useful as a table of contents for API docs.
|
||||
|
||||
In your markdown file, insert a line with the text <`AUTOGENERATED_TABLE_OF_CONTENTS>`. Write your documentation using `h3` headers for each function inside a code block. These will be found by Docusaurus and a list of links to these sections will inserted at the text <`AUTOGENERATED_TABLE_OF_CONTENTS>`.
|
||||
In your markdown file, insert a line with the text <`AUTOGENERATED_TABLE_OF_CONTENTS`>. Write your documentation using `h3` headers for each function inside a code block. These will be found by Docusaurus and a list of links to these sections will inserted at the text <`AUTOGENERATED_TABLE_OF_CONTENTS`>.
|
||||
|
||||
Example:
|
||||
|
||||
```markdown
|
||||
### `docusaurus.function(a, b)`
|
||||
|
||||
|
@ -111,4 +112,50 @@ will lead to a table of contents of the functions:
|
|||
- `docusaurus.function(a, b)`
|
||||
- `docdoc(file)`
|
||||
```
|
||||
|
||||
and each function will link to their corresponding sections in the page.
|
||||
|
||||
## Syntax Highlighting
|
||||
|
||||
Syntax highlighting is enabled by default on fenced code blocks. The language should be detected automatically, but you can sometimes get better results by specifying the language. You can do so using an [info string](https://github.github.com/gfm/#example-111), following the three opening backticks. The following JavaScript example...
|
||||
|
||||
```javascript
|
||||
ReactDOM.render(
|
||||
<h1>Hello, world!</h1>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
```
|
||||
|
||||
...would be rendered with syntax highlighting like so:
|
||||
|
||||
```javascript
|
||||
ReactDOM.render(
|
||||
<h1>Hello, world!</h1>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
```
|
||||
|
||||
Highlighting is provided by [Highlight.js](https://highlightjs.org) using the theme specified in your `siteConfig.js` file as part of the `highlight` key:
|
||||
|
||||
```
|
||||
highlight: {
|
||||
theme: 'default'
|
||||
}
|
||||
```
|
||||
|
||||
You can find the full list of supported themes in the Highlight.js [`styles`](https://github.com/isagalaev/highlight.js/tree/master/src/styles) directory.
|
||||
|
||||
### Registering additional languages
|
||||
|
||||
While Highlight.js provides support for [many popular languages out of the box](https://highlightjs.org/static/demo/), you may find the need to register additional language support. For these cases, we provide an escape valve by exposing the `hljs` constant as part of the `highlight` config key. This in turn allows you to call [`registerLanguage`](http://highlightjs.readthedocs.io/en/latest/api.html#registerlanguage-name-language):
|
||||
|
||||
```
|
||||
highlight: {
|
||||
theme: 'default',
|
||||
hljs: function(hljs) {
|
||||
hljs.registerLanguage('galacticbasic', function(hljs) {
|
||||
// ...
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue