Code Include Demo.
This post demonstrates how to include code files directly from the page bundle using the include-code shortcode.
Usage
To include a file from the post’s directory (page bundle), use the following syntax:
| |
file: The name of the file relative to the post.language(optional): The language for syntax highlighting. If omitted, it defaults to the file extension.
Python Example
Here is a Python script included from hello.py:
| |
Rust Example
Here is a Rust program included from main.rs:
| |
JavaScript Example
Here is a JavaScript snippet included from script.js:
| |
Go Example
Here is a Go program included from main.go:
| |
Java Example
Here is a Java class included from Main.java:
| |
Markdown Example
Here is a Markdown file included from example.md:
| |
HTML Example
Here is an HTML file included from example.html:
| |
Rendered Markdown Include
The following section is essentially “transcluded” from another file (included-section.md) using the include-md shortcode. Unlike the previous examples, this is rendered as actual content, not code.
This is an Included Markdown Section
This content is coming from a separate file named included-section.md.
- It is rendered as Markdown.
- Not displayed as a code block.
It effectively allows you to compose a single post from multiple source files.
Nested Code Example
Here’s a Python example included via include-code within this included Markdown section:
| |