zoni / obsidian-export Goto Github PK
View Code? Open in Web Editor NEWRust library and CLI to export an Obsidian vault to regular Markdown
License: Other
Rust library and CLI to export an Obsidian vault to regular Markdown
License: Other
Create two notes:
1.md:
Some text
Some highlights ^some-block-id
2.md:
![[1.md#^some-block-id]]
Obsidian Export behaves like Obsidian, that is, it exports 2.md with the following content:
Some highlights
Obsidian export transcludes the whole 1.md file:
Some text
Some highlights ^some-block-id
Use headings instead of block ids, which Obsidian Export does export correctly. However hopefully this is easy to fix given that Obsidian Export already supports headings?
It would be useful to support printing the output to stdout instead of providing a filename.
That way you could pipe the output to another program like:
obsidian-export doc.md | pandoc -f markdown -t html
Hello @zoni, thanks for this plugin!. It's amazing.
My report:
When exporting the note:
Transcluding.md, with the contents:
The action of ![[Transcluding]]
I get:
Error: Failed to export '/home/cvasquez/obsidian/public-garden/Transcluding.md'
Caused by:
Recursion limit exceeded
Location:
/home/cvasquez/.cargo/registry/src/github.com-1ecc6299db9ec823/obsidian-export-0.2.0/src/main.rs:45:19
currently, if --start-at is used, if there are other files in other directories, there is no way to export them as well, it would be good to provide that option
When using pandoc, I check if the source markdown is newer than the resulting HTML; if so, I know I need to run pandoc on the markdown but can otherwise skip it. If you preserved the source mtime
, this would be very easy -- otherwise, I'll need to copy mtime
from the source myself.
Hi,
let me start by expressing my gratitude for your efforts into this nice project !
Your project is the only one (in Rust) I know of that parses Obsidian files properly.
It would be great if you made the parser available to other projects (including the one I'm trying to implement as I'm writing) !
Skimming through your code, that would be the whole contents of references.rs
, plus the YAML and Markdown parsing logic embedded within Exporter::run()
from lib.rs
. I might have missed something, but I guess you'll know better ;-)
Cheers
# 0.1.md
[[0.2|Create new site]]
0.1.md and 0.2.md are in the same directory.
# 0.1.md
[Create new site](0.2.md)
This will not render properly as this implies there is a file in path 0.1/0.2
when they are in the same parent directory.
The correct path should render as below:
# 0.1.md
[Create new site](../0.2.md)
Please reply to this or ping me if this will be fixed.
Thanks for your work.
Hi, is there any possibility to export notes with attachments moved to the subfolders? So I could easily export a note to a separate folder outside of my vault and all its attachments are with it.😄
Thank you for this; it's very fast! It'd be great to have an option for the resulting markdown pages to have titles, be it the first H1 #
heading or in a yaml preface.
Just wondering if the binary export for M1 chips could be provided. I don't know the technical constraints of the compilation process; I know I can compile the app via cargo, but I prefer not having to install Rust in my macbook, since I dont know or use the language.
I have embedded notes that link to files with German umlauts. The exporter reports that the file is not to be found. It is shown in Obsidian, and it works after renaming the file (+embedded link name).
Hello,
I think i have a WINDOWS issue.
obsidian-export
is launched, i then have in generated .md in the output markdown paths like :![Pasted image 20210201170521.png](..\..\resources\2021\images\Pasted%20image%2020210201170521.png)
http://localhost:1313/daily/2021/02/....%5Cresources%5C2021%5Cimages%5CPasted%20image%2020210201170513.png
Note :
....
pattern (i don't know why here the "" has disappeared)So, maybe, would it be possible to have "/" for the paths ?
Or any other idea ?
For ex. #something
will it convert this to a specific html element so we can style it accordingly?
Hi Nick;
here's my challenge:
I created a vault with Obsidian v.0.13.17.
The vault contains several folder with *.md notes.
When I use obsidian-export in Linux or Windows 11 everything works fine. I checked the files re to the below mentioned error and I don't see a problem. (line breaks are there)
Now I use this data to create a static HTML site with mkdocs and the material theme. Using this yml file for a local html.site (following the info on the mkdocs website:
site_name: Report site_url: "" theme: 'material' use_directory_urls: false plugins: []
Again all ok, except that all line breaks are removed. (same with different theme)
See Screenshots:
I really have no idea what's going on here, is that something you can fix this with the exporter?
/Jörn
Attached the test vault "ExportTest"
ExportTest.zip
Vault after obsidian-export:
Sitemd_files_after_obs-export.zip
HTML_Site after mkdocs export:
HTML-site.zip
proposed command line usage:
$ obsidian-export --wikilink-prefix="/posts/" /path/to/input/ /path/to/output/
for given input markdown:
[[example]]
generated markdown would be:
[example](/posts/example.md)
this would be another solution to the hugo relative link problem and would generally allow more flexibility for people working with alternative publishing mechanisms.
main code touch points seem to be be https://github.com/zoni/obsidian-export/blob/main/src/lib.rs#L650
I have found that inline footnotes don't export correctly. For example:
This is text. ^[This is an inline footnote.]
which should render as
exports as
This is text. \^[This is an inline footnote.]
I also found that the referenced link style isn't preserved. Is this intended behavior? If so, I can always devise a workaround to manually extract those links but it'd be much cleaner if you could add that functionality.
As a final note, I think a hint in the readme that the user needs to do a chmod +x
would be very useful. I was certainly guilty of not doing so at first.
Using your solution to generate website with Obsidian Zola. Can I somehow override the default URL generation mechanics of obsidian-export (to change spaces to dashes)?
Take a file named 2018-10-10-hello-world.md
. Zola when generating a URL will strip out the date and first -
as stated in https://www.getzola.org/documentation/content/page/
"Another exception to this rule is that a filename starting with a datetime (YYYY-mm-dd or an RFC3339 datetime) followed by an underscore (_
) or a dash (-
) will use that date as the page date, unless already set in the front matter. The page name will be anything after _
/-
, so the file 2018-10-10-hello-world.md
will be available at [base_url]/hello-world
"
This means any pages linked in a Zola generated page are broken, as the link points to the file name with date included, while the page exists at the URL without the date.
Installed typst:
wget https://github.com/typst/typst/releases/download/v0.3.0/typst-x86_64-unknown-linux-musl.tar.xz
sudo tar xf typst-x86_64-unknown-linux-musl.tar.xz -C /usr/local/bin --strip-components=1
$ typst -V
typst 0.3.0 (81bf8313)
$ pandoc --version
pandoc 3.1.2
Features: +server +lua
Scripting engine: Lua 5.4
Try to export my article to pdf and get an error
The similar problem: jgm/pandoc#8754
The reason: typst syntax (with or without compile option).
$ typst --help
typst creates PDF files from .typ files
Usage: typst [OPTIONS] <COMMAND>
Commands:
compile Compiles the input file into a PDF file [aliases: c]
watch Watches the input file and recompiles on changes [aliases: w]
fonts List all discovered fonts in system and custom font paths
help Print this message or the help of the given subcommand(s)
I would like to be able to export only explicitly selected files.
For example, the choice could be made using the export parameter: true
---
alias: test
export: true
---
\# h1
Content
Obsidian aliases allow pages to have more than one title for the purposes of creating cross-references: Add aliases to note - Obsidian Help
A common use-case for this is creating a page with a long title such as "Expanded Acronyms for Everyone (EAfE).md" and then giving it a nice short alias to make it easy to link to from notes:
---
aliases: [EAfE]
---
# What are acronyms?
... content body here ...
You can then link to this page from other pages via [[EAfE]]
, which is a lot less typing.
I currently see a lot of the following errors when exporting my Obsidian vault:
Warning: Unable to find referenced note
Reference: 'DBF'
Source: '/Users/robmee01/Library/Mobile Documents/iCloud~md~obsidian/Documents/Work/Journal/FY22Q2/2022wk16.md'
and
Warning: Unable to find referenced note
Reference: 'BFaaS'
Source: '/Users/robmee01/Library/Mobile Documents/iCloud~md~obsidian/Documents/Work/Journal/FY21Q4/2022wk09.md'
Please can support for aliases be added, such that internal links to the page via its alias resolve to the intended page in the exported markdown?
Right now I can export a canvas in obsidian to an image, would like to be able to do that programmatically
If I link to an image using embedded wiki-links (i.e. ![[Image_link]]) instead of standard Markdown (i.e. ), it results in the image file changing to 0 bytes (and unable to be viewed) albeit with the file name still intact.
I'm experiencing this with .png files - not sure if it happens with other extensions (e.g. jpg)
i have quite a few pages that use the dataview plugin to put summary tables together. it would be great if there was someway to make those pages static so that it is output during the export.
Hi there, this program has been immensely useful for getting my Obsidian docs into LaTeX
, so thank you 🙏.
I've noticed that certain blocks of mathematics (in LaTeX
) are handled incorrectly, breaking the math environments. For example, if you include a left-bracket in a LaTeX
environment (such as $[0, 2\pi)$
), after obsidian-export
is run it will be converted to $\[0, 2\pi)$
(which is invalid).
I assume this is something to do with [[Wikilink]]
parsing, but I don't know enough Rust to investigate 😅 I think a possible solution would be to ignore any parsing or modification inside math blocks and instead treat them verbatim.
First of all thanks for this useful program, it saves me a lot of work, but now I have a problem about the slash in the path.
My original image link is "Wikilink"
![[Pasted image xxx.png]]
and path of the image link exported by this program is backslash, the resulting path is as follows.
![Pasted image xxx.png](_resources\Install-obsidian-export-record\Pasted%20image%20xxx.png)
Then when I upload this md file to my server, the picture will not be displayed due to the wrong slash symbol,
the correct symbol should be written like this
![Pasted image xxx.png](_resources/Install-obsidian-export-record/Pasted%20image%20xxx.png)
I want to know if there is any way to adjust for this problem instead of manually adjusting one by one?
Thank you~
I would like to have this structure :
In my obsidian workspace :
.obsidian
daily/
resources/
hugo/
"daily/" are my .md files
"resources/" are where my images are
"hugo/" is my hugo workspace, with a regular structure
"hugo/content/" : the output of obsidian-export
"hugo/layouts/" : hugo regular layout folder
(and so on, for themes, ...)
With that organization :
However my problem is that right now, one extra layer is missing in the path generated between converted markdown files and resources.
Maybe this is coming by the fact that my target folder (second parameter of obsidian-export
has two levels ? ("hugo/content/") ? Or because i have subfolders in "daily/" and "resources/" ?
"daily/2021/01.md"
"resources/2021/images/Pasted Image.png"
For now, as a result, i have (not takin #7 in account here) :
![Pasted image 20210201170521.png](..\..\resources\2021\images\Pasted%20image%2020210201170521.png)
And images are not generated by hugo.
Whereas with an extra path, images are correctly displayed :
![Pasted image 20210201170521.png](..\..\..\resources\2021\images\Pasted%20image%2020210201170521.png)
Example from: https://github.com/zoni/obsidian-export/actions/runs/3933231631/jobs/6726713876
Run actions-rs/cargo@v1
/home/runner/.cargo/bin/cargo clippy -- -D warnings
Checking obsidian-export v22.11.0 (/home/runner/work/obsidian-export/obsidian-export)
error: the borrowed expression implements the required traits
Error: --> src/lib.rs:384:58
|
384 | let destination = &self.destination.join(&relative_path);
| ^^^^^^^^^^^^^^ help: change this to: `relative_path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `-D clippy::needless-borrow` implied by `-D warnings`
error: the borrowed expression implements the required traits
Error: --> src/lib.rs:[7](https://github.com/zoni/obsidian-export/actions/runs/3933231631/jobs/6726713876#step:8:8)35:50
|
735 | || path_normalized_lowered.ends_with(&filename_normalized.to_lowercase())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `filename_normalized.to_lowercase()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
error: could not compile `obsidian-export` due to 2 previous errors
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code [10](https://github.com/zoni/obsidian-export/actions/runs/3933231631/jobs/6726713876#step:8:11)1
This isn't an Issue, but I'd like to understand how Obsidian.md keeps track of wikilink file paths, and how obsidian-export
deals with that.
obsidian-export
make use of this system information? Or does it traverse all the files in the vault and make a map of the file paths?It's common practice to create empty links in obsidian. IMO this warning should be ignored by default.
Hi there,
Great library! It's exactly what we needed.
I have a source file with:
![[CLI.svg]]
![[CLI.png]]
and the exported file results in:
[CLI.svg](_fragments/_gen_media/CLI.svg)
![CLI.png](_fragments/_gen_media/CLI.png)
The svg is missing the exclamation mark. I'd love to be able to submit a PR however, I've never done any rust coding. Would appreciate a fix or direction on where this fix would need to be.
Thanks!
> obsidian-export --version
obsidian-export 21.9.0
filenames with spaces are converted to links with %20 in them, however kramdown/etc does not seem to properly recognize this and does not convert these links to proper html links, instead it keeps the .md extention, which fails to work (404) on github pages.
EDIT: I tested manually replacing the %20 with an actual space, and github's kramdown now renders it properly. (maybe this could be an option, as %20 "should" work (in my opinion) everywhere, github just has an issue maybe?)
Obsidian's image resize syntax is currently unsupported. This is a tracking issue for support of this functionality.
For reference, the syntax for this in Obsidian is as follows:
![AltText|100x100](https://url/to/image.png)
![[image.png|100x100]]
(See Resize images on https://publish.obsidian.md/help/How+to/Embed+files)
I'm a DND dungeon master and often find myself wanting to hide only some information within a file. Here is an example of how it could look.
# Interesting Title
Here is some information I want to be exported.
%% BEGIN-EXPORT-IGNORE %%
Here is some information I want hidden.
%% END-EXPORT-IGNORE %%
Here is some other public info.
Sorry for the noob question -- but when I try to run the MacOS binary as described in the README, I have issues.
Attempt 1:
❯ ~/Downloads/obsidian-export --version
zsh: no such file or directory: /Users/toby.manders/Downloads/obsidian-export
Attempt 2:
❯ ~/Downloads/obsidian-export_MacOS-x86_64.bin --version
zsh: permission denied: /Users/toby.manders/Downloads/obsidian-export_MacOS-x86_64.bin
Attempt 3:
❯ sudo ~/Downloads/obsidian-export_MacOS-x86_64.bin --version
Password:
sudo: /Users/toby.manders/Downloads/obsidian-export_MacOS-x86_64.bin: command not found
Attempt 4:
❯ ~/Downloads/obsidian-export_MacOS-x86_64 --version
zsh: no such file or directory: /Users/toby.manders/Downloads/obsidian-export_MacOS-x86_64
Is there something I need to do with the binary before calling it from the command line?
I get this error when I use v22.1.0 of the windows binary.
Usage:
C:\Users\pope\Downloads\obsidian-export_Windows-x64_64.exe 'C:\Users\pope\Code\Fighting Games\' C:\Users\pope\Code\out
I can run the program with the help flags and that does work.
PS C:\Users\pope\Downloads\obsidian-export_Windows-x64_64.exe --help
Usage: C:\Users\pope\Downloads\obsidian-export_Windows-x64_64.exe [OPTIONS]
Positional arguments:
source Read notes from this source
destination Write notes to this destination
Optional arguments:
-h, --help Display program help
-v, --version Display version information
--start-at START-AT Only export notes under this sub-path
--frontmatter FRONTMATTER-STRATEGY
Frontmatter strategy (one of: always, never, auto) (default: auto)
--ignore-file IGNORE-FILE Read ignore patterns from files with this name (default: .export-ignore)
--hidden Export hidden files (default: false)
--no-git Disable git integration (default: false)
--no-recursive-embeds Don't process embeds recursively (default: false)
--hard-linebreaks Convert soft line breaks to hard line breaks. This mimics Obsidian's 'Strict line breaks' setting (default: false)
When I export an Obsidian note with a https://github.com/blacksmithgu/obsidian-dataview query snippet, I get an .md file with the dataview query, not the query results because dataview executes queries within the Obsidian apps.
Is there any way to make Obsidian Export talk to the dataview plugin to render query results? I publish my own Obsidian vault to a static site thanks to Obsidian Export, and I would love to use dataview but right now I can't because I know that some of my published notes will be broken. Popular frameworks like LYT Kit v6 are now also using dataview, so I expect that more and more people would benefit from this feature.
Adding @blacksmithgu in case he has any idea about how we could do this.
And more context on this issue:
https://forum.obsidian.md/t/hybrid-of-dataview-and-textexpand/16656
While changing from my old solution for partial shared data, I found that symbolic linked directories are not supported:
1: the source path is neither a regular file nor a symlink to a regular file
The file reference.md
contains ![[redshift]]
. There is a file called redshift.md
in the ztl
folder. When I run obsidian-export
I get this error.
# Run obsidian-export
obsidian-export ztl/reference.md ~/d/exported-ztl/
# Error message
Warning: Unable to find embedded note
Reference: 'redshift'
Source: 'ztl/reference.md'
The export directory has a new reference.md
file. However, the file does not have any of the contents of the embedded reference.
First of all, thanks for such an amazing tool. This has been really helpful for me.
One problem I encountered is that when an embedded reference section has parenthesis in the heading, it is unable to find that.
In this image, we can see that the tool works perfectly fine for the above embed, but the second one results in a full-page embed.
After a lot of debugging (A LOT, especially as I have never coded in Rust) , println!("{} : {}", section.to_lowercase(), cowstr.to_string().to_lowercase());
results in the follwoing output.
We can see that section
ignores the parenthesis, while cowstr
doesn't.
For now, I have resorted to removing the parenthesis from the reference heading. I just wanted to bring this to your attention.
Thanks and regards.
I tried running with both the 0.7.0 binary from GitHub, and then I installed Rust to execute the cargo install
command, and it did, but the same issue appears when trying to export just one note with its referenced notes:
This is the exact command I'm trying to execute:
obsidian-export obsidian/ --start-at obsidian/_Fleeting\ Notes/Support\ Rotation.md exported-notes
obsidian-export
but powershell threw a “suggestion” becauseThe command obsidian-export was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\obsidian-export". See "get-help about_Command_Precedence" for more details.
PS D:\notes> .\obsidian-export my-obsidian-vault /tmp/export
which returned Error: No such file or directory: my-obsidian-vault
.\obsidian-export Gardening /Export
which didn’t work (no such file or directory)..\obsidian-export Gardening Export
worked fine.---
title: "Obsidian"
---
---
## title: "Obsidian"
With --frontmatter=always
:
---
---
---
## title: "Obsidian"
Using macOS v22.1.0 release
Originally posted by mschrader15 January 3, 2022
Hi @zoni ,
I would like to mark my notes for export inside of the YAML frontmatter instead of sticking them in a specific directory. Something like:
---
export: True
---
This would allow me to maintain the structure of my vault while also publishing only specific pages.
I would be happy to create a PR with this feature. Do you have any thoughts?
As a newbie to everything coding related, I don't understand what to do with the precompiled file.
Why the restriction on symlinked folders?
❯ llh
total 100K
...
lrwxr-xr-x 1 reagle staff 29 Jul 6 16:36 aoc -> /Users/reagle/joseph/2023/aoc/
...
❯ /Users/reagle/bin/obsidian-export /Users/reagle/joseph/plan/ob-plan /Users/reagle/joseph/plan/ob-web
Error: Failed to export '/Users/reagle/joseph/plan/ob-plan/Research/aoc'
Caused by:
0: failed to write to '/Users/reagle/joseph/plan/ob-web/Research/aoc'
1: the source path is neither a regular file nor a symlink to a regular file
Location:
/rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/convert/mod.rs:542:9
Obsidian's block reference syntax is currently unsupported. This is a tracking issue for support of this functionality.
I am not able to export images from the obsidian while exporting a single Note(markdown file). I have created a test vault, containing some text and a screenshot, placed by dragging into it.
And while exporting the file, it throws a warning and the exported markdown file is empty in that position.
However exporting the whole vault works fine.
Error log:
Warning: Unable to find embedded note
Reference: 'Screenshot 2021-05-02 at 11.27.07 PM.png'
Source: '/Users/harshitruwali/Desktop/del/del.md'
OS: MacOS 11.3
obsidian-export version: 0.7.0
Obsidian version: 0.11.13
Hi, thanks for such a great tool! I was wondering if it would be possible to make the markdown links angle bracket escaped instead of url-encoding escaped ([some title](<../filepath with spaces/test.md#section>)
vs [some title](<../filepath%20with%20spaces/test.md#section>)
). This is supported by CommonMark/Obsidian and is much more readable on a quick glance IMO.
I saw this piece of the code in lib.rs
Lines 688 to 706 in 8013026
and think it would be two if statements on lines 689 and 698. One to block out the percent encoding and then another to prepend and append the angled brackets. I couldn't figure out how to add it as an option to the tool though so I would really appreciate it if it could be there. Thanks again for making this tool and if you are able to add this feature!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.