I made a python-script that lets you specify a single md-file that exists in your vault, and it will copy that file with all of its linked images as well as linked md-files recursively (it goes through these files as well to finds all of its images/links and copies these as well).
You end up with a new folder (vault) that you can easily send to a friend to open in obsidian with just the files needed to show the file you started with and its linked files all the way down to last link.
As a bonus I added an option to create a html-version of the exported vault. If selected, it creates a .html next to each of the md-files. The html-version includes all the images/working links, lists, headings and code-blocks (code-highlighted). It also shows the vault-file/folders in a treeview next to current file with working links).
For easy access it creates an index.html in root of export-vault that takes you to the html-version of the selected file for export.
This feature is super-useful when you wanna share the vault with someone that doesn’t have obsidian.
Only tested in Linux, might need a small tweak to work on windows/mac?
Have fun with the script and please tell me if you think it needs something more (latex support?)
I’m running the script on my linux machine, but I get this error message:
Traceback (most recent call last):
File "exportMdFileToHtml.py", line 249, in <module>
readFilesRecursive(mainFileToExport)
File "exportMdFileToHtml.py", line 218, in readFilesRecursive
line = findMdFile(line, currentFile=path)
File "exportMdFileToHtml.py", line 81, in findMdFile
newFile = copyFileToExport(fileOnly + '.md', currentFile, traverse=True)
File "exportMdFileToHtml.py", line 70, in copyFileToExport
readFilesRecursive(linkedFilePath)
File "exportMdFileToHtml.py", line 218, in readFilesRecursive
line = findMdFile(line, currentFile=path)
File "exportMdFileToHtml.py", line 83, in findMdFile
if(len(newFile)>0):
TypeError: object of type 'NoneType' has no len()
I have no idea what it means.
I placed the *.py outside of my target folder and used this command:
python3 exportMdFileToHtml.py "link to folder/file_name_.md" y
Not sure what I made wrong, can you switch a light on for me?
Put the script at the root (top level) of your vault, and skip the folder/path to your MD file when you run the script (only filename needed) and see if that helps.