-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enable new markdown options - Add new mdex options - Bump min mdex version - Add guide to customize such options
- Loading branch information
Showing
5 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Customize Markdown Rendering | ||
|
||
Markdown pages are rendered using the [Beacon.Template.Markdown](https://hexdocs.pm/beacon/0.1.0-rc.2/Beacon.Template.Markdown.html) module with a set of default options that works for most cases, | ||
but you might want to change how some features work or enable more features. For example, let's suppose you want to generate an ID for every header of the page with the suffix `"topic-"`. | ||
|
||
You can do that by changing the `:load_template` lifecycle of `:markdown` in your [site configuration](https://hexdocs.pm/beacon/0.1.0-rc.2/Beacon.html#start_link/1) as the example below: | ||
|
||
```elixir | ||
[ | ||
site: :my_site, | ||
lifecycle: [ | ||
load_template: [ | ||
{:markdown, | ||
[ | ||
markdown_with_header_ids: &markdown_with_header_ids/2 | ||
] | ||
} | ||
] | ||
] | ||
# rest ommited for brevity... | ||
] | ||
|
||
def markdown_with_header_ids(template, _metadata) do | ||
template = MDEx.to_html!(markdown, extension: [header_ids: "topic-"]) | ||
{:cont, template} | ||
end | ||
``` | ||
|
||
But keep in mind this operation will replace the default markdown rendering with the one you provided, | ||
so the only features enabled will be the one you set and the others will take the default value. | ||
|
||
For example with this configuration the `:header_ids` extension is enabled but others like tables and autolinks would be turned off. | ||
|
||
You can inspect the actual configuration in the [Beacon.Template.Markdown](https://hexdocs.pm/beacon/0.1.0-rc.2/Beacon.Template.Markdown.html) module and also check the [MDEx docs](https://hexdocs.pm/mdex/MDEx.html#to_html/2) for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters