Sometimes I duplicate my content like this:
## Tutorial for bold text in markdown
Code:
```markdown
**Hello, world!**
```
Result:
**Hello, world!**
Note the lack of code fenceblocks at the end, so that the markdown gets actually rendered e.g. as <b>Hello, world!</b>
.
If your snippets are large or you don’t want to have a pair drift, you can use capture to write the content just once and then reuse. Useful for markdown or CSS or even JS as those run in the browser - not so useful for other languages.
{% capture my_code %}
**Hello, world!**
{% endcapture %}
Code:
```markdown
{{ my_code }}
```
Result:
{{ my_code | markdownify }}
Note that the markdownify filter will render markdown as HTML but it will not render Liquid. i.e. Using {{
or {%
will not get evaluated and so will appear as plain text in both the code and the result.