TLDR; No, but you can have workarounds depending on your implementation
The official markdown specification doesn't have anything like that, but you can probably do some workarounds depending on what you use. Basically, you have to set it up:
Setup codebraid
codebraid
is a build tool that lets you run code that is written and inserts the results as if it were templating. Here is a link to their repository: https://github.com/gpoore/codebraid#readme. As shown in this StackOverflow answer: https://stackoverflow.com/a/69659435/13514657, you can run some python code to read from a table and output the value there.
Here is an example for reading formula.md
:
```{.python .cb.run}
with open('formula**strong text**.md') as fp:
print(fp.read())
```
Write a plugin for your transpiler
If you are using something like remark
, markdown-it
, or markedjs
, then they probably have a plugin system in which you can write a custom plugin that will allow you to import markdown files.
MarkedJS
- Insert the imports before passing them to
markedjs
- Create a plugin that provides a tokenizer that marks imports with a special token and a renderer that transpiles the markdown to HTML with the given rendering configuration
- Create a renderer that detects an existing syntax (say links) with a special flag that will interpret it as an import
Web
Write a browser extension or userscript.
Visual Studio Code
You can write a markdown-it
plugin and turn it into a Visual Studio Code extension. Here is an example where someone wrote their own markdown language: https://github.com/mjbvz/vscode-markdown-mermaid/blob/master/src/index.ts.
MDX
If you are using mdx
, then it is as simple as importing the other file and displaying it inside your file.
import Formula from './Formula.mdx';
# My math work
## Formula
If you wanted to see the formula to do the above here it is:
<Formula />
Image
You could probably convert the markdown file into an SVG or take a screenshot of it and reference it, but of course, that means that you have to take a screenshot every single time.