diff --git a/README.md b/README.md index abc057bb0..b93538ea1 100644 --- a/README.md +++ b/README.md @@ -192,9 +192,9 @@ You can also use a custom text, e.g.: `` [custom text](`MyModule.function/1`) `` Link to extra pages like this: `` [Up and running](Up and running.md) `` (skipping the directory the page is in), the final link will be automatically converted to `up-and-running.html`. -## Rendering Math +## Extensions -If you write TeX-style math in your Markdown (like `$\sum_{i}^{N} x_i$`), they end up as raw text on the generated pages. To render them we recommend using [KaTeX](https://katex.org/), a JavaScript library that turns those expressions into actual graphics. To load and trigger KaTeX on every documentation page, you can configure ExDoc to insert relevant scripts into the HTML: +ExDoc renders Markdown content for you, but you can extend it to render complex objects on the page using JavaScript. To inject custom JavaScript into every page, add this to your configuration: ```elixir docs: [ @@ -206,18 +206,54 @@ docs: [ defp before_closing_body_tag(:html) do """ - - - + """ end defp before_closing_body_tag(_), do: "" ``` +### Rendering Math + +If you write TeX-style math in your Markdown (like `$\sum_{i}^{N} x_i$`), they end up as raw text on the generated pages. To render them we recommend using [KaTeX](https://katex.org/), a JavaScript library that turns those expressions into actual graphics. To load and trigger KaTeX on every documentation page we can insert the following HTML: + +```html + + + +``` + For more details and configuration options see the [KaTeX Auto-render Extension](https://katex.org/docs/autorender.html). +### Rendering Vega-Lite plots + +Other objects you may want to render in a special manner are code snippets. For example, assuming your Markdown includes Vega-Lite specification in `vega-lite` code snippets, you can do: + +```html + + + + +``` + +For more details and configuration options see the [vega/vega-embed](https://github.com/vega/vega-embed). + ## Contributing The easiest way to test changes to ExDoc is to locally rebuild the app and its own documentation: