GithubHelp home page GithubHelp logo

zoni / obsidian-export Goto Github PK

View Code? Open in Web Editor NEW
1.0K 10.0 84.0 390 KB

Rust library and CLI to export an Obsidian vault to regular Markdown

License: Other

Rust 97.96% Just 2.04%
obsidian obsidian-md export exporter obsidian-vault

obsidian-export's Introduction

Obsidian Export

Obsidian Export is a CLI program and a Rust library to export an Obsidian vault to regular Markdown.

  • Recursively export Obsidian Markdown files to CommonMark.
  • Supports [[note]]-style references as well as ![[note]] file includes.
  • Support for gitignore-style exclude patterns (default: .export-ignore).
  • Automatically excludes files that are ignored by Git when the vault is located in a Git repository.
  • Runs on all major platforms: Windows, Mac, Linux, BSDs.

Please note obsidian-export is not officially endorsed by the Obsidian team. It supports most but not all of Obsidian's Markdown flavor.

Installation

Pre-built binaries

Pre-compiled binaries for all major platforms are available at https://github.com/zoni/obsidian-export/releases

In addition to the installation scripts provided, these releases are also suitable for installation with cargo-binstall.

Building from source

When binary releases are unavailable for your platform, or you do not trust the pre-built binaries, then obsidian-export can be compiled from source with relatively little effort. This is done through Cargo, the official package manager for Rust, with the following steps:

  1. Install the Rust toolchain from https://www.rust-lang.org/tools/install
  2. Run: cargo install obsidian-export

It is expected that you successfully configured the PATH variable correctly while installing the Rust toolchain, as described under "Configuring the PATH environment variable" on https://www.rust-lang.org/tools/install.

Upgrading from earlier versions

If you downloaded a pre-built binary, upgrade by downloading the latest version to replace the old one.

If you built from source, upgrade by running cargo install obsidian-export again.

Basic usage

The main interface of obsidian-export is the obsidian-export CLI command. As a text interface, this must be run from a terminal or Windows PowerShell.

It is assumed that you have basic familiarity with command-line interfaces and that you set up your PATH correctly if you installed with cargo. Running obsidian-export --version should print a version number rather than giving some kind of error.

If you downloaded a pre-built binary and didn't put it a location referenced by PATH (for example, you put it in Downloads), you will need to provide the full path to the binary instead.

For example ~/Downloads/obsidian-export --version on Mac/Linux or ~\Downloads\obsidian-export --version on Windows (PowerShell).

Exporting notes

In it's most basic form, obsidian-export takes just two mandatory arguments, a source and a destination:

obsidian-export /path/to/my-obsidian-vault /path/to/exported-notes/

This will export all of the files from my-obsidian-vault to exported-notes, except for those listed in .export-ignore or .gitignore.

Note that the destination directory must exist, so you may need to create a new, empty directory first.

If you give it an existing directory, files under that directory may get overwritten.

It is also possible to export individual files:

# Export as some-note.md to /tmp/export/
obsidian-export my-obsidian-vault/some-note.md /tmp/export/
# Export as exported-note.md in /tmp/
obsidian-export my-obsidian-vault/some-note.md /tmp/exported-note.md

Note that in this mode, obsidian-export sees some-note.md as being the only file that exists in your vault so references to other notes won't be resolved. This is by design.

If you'd like to export a single note while resolving links or embeds to other areas in your vault then you should instead specify the root of your vault as the source, passing the file you'd like to export with --start-at, as described in the next section.

Exporting a partial vault

Using the --start-at argument, you can export just a subset of your vault. Given the following vault structure:

my-obsidian-vault
├── Notes/
├── Books/
└── People/

This will export only the notes in the Books directory to exported-notes:

obsidian-export my-obsidian-vault --start-at my-obsidian-vault/Books exported-notes

In this mode, all notes under the source (the first argument) are considered part of the vault so any references to these files will remain intact, even if they're not part of the exported notes.

Character encodings

At present, UTF-8 character encoding is assumed for all note text as well as filenames. All text and file handling performs lossy conversion to Unicode strings.

Use of non-UTF8 encodings may lead to issues like incorrect text replacement and failure to find linked notes. While this may change in the future, there are no plans to change this behavior in the short term.

Advanced usage

Frontmatter

By default, frontmatter is copied over "as-is".

Some static site generators are picky about frontmatter and require it to be present. Some get tripped up when Markdown files don't have frontmatter but start with a list item or horizontal rule. In these cases, --frontmatter=always can be used to insert an empty frontmatter entry.

To completely remove any frontmatter from exported notes, use --frontmatter=never.

Ignoring files

The following files are not exported by default:

  • hidden files (can be adjusted with --hidden)
  • files matching a pattern listed in .export-ignore (can be adjusted with --ignore-file)
  • any files that are ignored by git (can be adjusted with --no-git)
  • using --skip-tags foo --skip-tags bar will skip any files that have the tags foo or bar in their frontmatter
  • using --only-tags foo --only-tags bar will skip any files that don't have the tags foo or bar in their frontmatter

(See --help for more information).

Notes linking to ignored notes will be unlinked (they'll only include the link text). Embeds of ignored notes will be skipped entirely.

Ignorefile syntax

The syntax for .export-ignore files is identical to that of gitignore files. Here's an example:

# Ignore the directory private that is located at the top of the export tree
/private
# Ignore any file or directory called `test`
test
# Ignore any PDF file
*.pdf
# ..but include special.pdf
!special.pdf

For more comprehensive documentation and examples, see the gitignore manpage.

Recursive embeds

It's possible to end up with "recursive embeds" when two notes embed each other. This happens for example when a Note A.md contains ![[Note B]] but Note B.md also contains ![[Note A]].

By default, this will trigger an error and display the chain of notes which caused the recursion.

This behavior may be changed by specifying --no-recursive-embeds. Using this mode, if a note is encountered for a second time while processing the original note, instead of embedding it again a link to the note is inserted instead to break the cycle.

Relative links with Hugo

The Hugo static site generator does not support relative links to files. Instead, it expects you to link to other pages using the ref and relref shortcodes.

As a result of this, notes that have been exported from Obsidian using obsidian-export do not work out of the box because Hugo doesn't resolve these links correctly.

Markdown Render Hooks (only supported using the default goldmark renderer) allow you to work around this issue however, making exported notes work with Hugo after a bit of one-time setup work.

Create the file layouts/_default/_markup/render-link.html with the following contents:

{{- $url := urls.Parse .Destination -}}
{{- $scheme := $url.Scheme -}}

<a href="
  {{- if eq $scheme "" -}}
    {{- if strings.HasSuffix $url.Path ".md" -}}
      {{- relref .Page .Destination | safeURL -}}
    {{- else -}}
      {{- .Destination | safeURL -}}
    {{- end -}}
  {{- else -}}
    {{- .Destination | safeURL -}}
  {{- end -}}"
  {{- with .Title }} title="{{ . | safeHTML }}"{{- end -}}>
  {{- .Text | safeHTML -}}
</a>

{{- /* whitespace stripped here to avoid trailing newline in rendered result caused by file EOL */ -}}

And layouts/_default/_markup/render-image.html for images:

{{- $url := urls.Parse .Destination -}}
{{- $scheme := $url.Scheme -}}

<img src="
  {{- if eq $scheme "" -}}
    {{- if strings.HasSuffix $url.Path ".md" -}}
      {{- relref .Page .Destination | safeURL -}}
    {{- else -}}
      {{- printf "/%s%s" .Page.File.Dir .Destination | safeURL -}}
    {{- end -}}
  {{- else -}}
    {{- .Destination | safeURL -}}
  {{- end -}}"
  {{- with .Title }} title="{{ . | safeHTML }}"{{- end -}}
  {{- with .Text }} alt="{{ . | safeHTML }}"
  {{- end -}}
/>

{{- /* whitespace stripped here to avoid trailing newline in rendered result caused by file EOL */ -}}

With these hooks in place, links to both notes as well as file attachments should now work correctly.

Note: If you're using a theme which comes with it's own render hooks, you might need to do a little extra work, or customize the snippets above, to avoid conflicts with the hooks from your theme.

Library usage

All of the functionality exposed by the obsidian-export CLI command is also accessible as a Rust library, exposed through the obsidian_export crate.

To get started, visit the library documentation on obsidian_export and obsidian_export::Exporter.

Contributing

I will happily accept bug fixes as well as enhancements, as long as they align with the overall scope and vision of the project. Please see CONTRIBUTING for more information.

License

Obsidian-export is open-source software released under the BSD-2-Clause Plus Patent License. This license is designed to provide: a) a simple permissive license; b) that is compatible with the GNU General Public License (GPL), version 2; and c) which also has an express patent grant included.

Please review the LICENSE file for the full text of the license.

Changelog

For a list of releases and the changes with each version, please refer to the CHANGELOG.

obsidian-export's People

Contributors

dependabot[bot] avatar epsilonhalbe avatar joshuacoles avatar nsainaney avatar programmerino avatar renovate[bot] avatar rsesek avatar summon528 avatar zoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-export's Issues

[Feature Request] Create tag to partially ignore content within a file.

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.

Inline footnotes not exported correctly

I have found that inline footnotes don't export correctly. For example:

This is text. ^[This is an inline footnote.]

which should render as

image

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.

Embedded reference doesn't work when the section has parenthesis

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.
image
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.
image
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.

Support image resize

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:

  • Markdown images: ![AltText|100x100](https://url/to/image.png)
  • Embeds: ![[image.png|100x100]]

(See Resize images on https://publish.obsidian.md/help/How+to/Embed+files)

Recursion limit exceeded

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

Include titles

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.

unrecognized option `--start-at `

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

Image files in embedded links being destroyed

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)

Transcluding block ids transcludes whole note instead

How to reproduce

Create two notes:

1.md:

Some text

Some highlights ^some-block-id

2.md:

![[1.md#^some-block-id]]

Expected result

Obsidian Export behaves like Obsidian, that is, it exports 2.md with the following content:

Some highlights

Actual result

Obsidian export transcludes the whole 1.md file:

Some text

Some highlights ^some-block-id

Workaround

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?

Add dataview support

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

Add canvas export support

Right now I can export a canvas in obsidian to an image, would like to be able to do that programmatically

Single file export does not resolve embedded notes

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.

Windows Documentation

  1. I downloaded the windows release from github. I put the file into a the folder I created with MKDocs, which I copied part of my obsidian vault into (a folder called “Gardening”). I then made a folder called “Export” in the same directory.
  2. Tried to run obsidian-export. Got an error about it not being recognized.
  3. Opened the file in notepad++ and saw it was appended as “mz” so I changed to a .exe file
  4. Tried to run it again using obsidian-export but powershell threw a “suggestion” because

The 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.

  1. so I tried: PS D:\notes> .\obsidian-export my-obsidian-vault /tmp/export which returned Error: No such file or directory: my-obsidian-vault
  2. so I tried: .\obsidian-export Gardening /Export which didn’t work (no such file or directory).
  3. However, .\obsidian-export Gardening Export worked fine.

Export only labeled files

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

Allow us to strip date from link generated

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.

Question: how does Obsidian know the file path of a wikilink?

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.

  1. Wikilink file paths aren't included in the MD files themselves. So does Obsidian store wikilink file paths in its system files?
  2. Does 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?

feature request: add a flag to specify path prefix for wikilinks

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

Line breaks from md files are removed

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)

See screenshot:
obs-export_2

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:
obsidian-export

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

Cant Export Image while Exporting a Single Notes

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'

Screenshot 2021-05-02 at 11 34 48 PM

OS: MacOS 11.3
obsidian-export version: 0.7.0
Obsidian version: 0.11.13

links not converted correctly (macOS)

Obsidian flavor markdown

# 0.1.md
[[0.2|Create new site]]

0.1.md and 0.2.md are in the same directory.

Converted markdown

# 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.

Builds fail due to linting error

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

Soft links are not followed

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

Adding option for angle bracket escaping over url-encoding

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

obsidian-export/src/lib.rs

Lines 688 to 706 in 8013026

let rel_link = rel_link.to_string_lossy();
let mut link = utf8_percent_encode(&rel_link, PERCENTENCODE_CHARS).to_string();
if let Some(section) = reference.section {
link.push('#');
link.push_str(&slugify(section));
}
let link_tag = pulldown_cmark::Tag::Link(
pulldown_cmark::LinkType::Inline,
CowStr::from(link),
CowStr::from(""),
);
vec![
Event::Start(link_tag.clone()),
Event::Text(CowStr::from(reference.display())),
Event::End(link_tag.clone()),
]

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!

Trouble using the pre-built MacOS binary

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?

Support page inclusion using YAML frontmatter

Discussed in #65

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?

Can't export to pdf with typst, unrecongnized subcommand

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
typst

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)

Support printing to stdout

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

preserve mtime of source file

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.

Provide a binary for M1 Mac architecture in the Pre-Built Binaries

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.

Allow different project organization

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 :

  • my hugo workspace is clearly separated from my obsidian workspace (in a sub-folder)
  • yet this hugo workspace is very standard (nothing to toy around)

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)

Broken frontmatter, when note body empty

Source

---
title: "Obsidian"
---

Broken Export

---

## title: "Obsidian"

With --frontmatter=always:

---
---

---

## title: "Obsidian"

Using macOS v22.1.0 release

Broken escaping of square brackets in math

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.

image

Inconsistent behavior when exporting ![[image.svg]] vs ![[image.png]]

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

obsidian-export_Windows-x64_64.exe: missing required free argument

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)

Extract parser and publish it as a separate crate

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

Why the restriction on symlinked folders?

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

Generated paths are not working out of the box under windows with HUGO

Hello,

I think i have a WINDOWS issue.

  1. In OBSIDIAN, i have links like ![[Pasted Image.png]]
  2. When 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)
  3. When i launch HUGO on these markdown file, i then have target URL like :
    http://localhost:1313/daily/2021/02/....%5Cresources%5C2021%5Cimages%5CPasted%20image%2020210201170513.png

Note :

  • the .... pattern (i don't know why here the "" has disappeared)
  • the fact that "" are replaced by "5C"

So, maybe, would it be possible to have "/" for the paths ?
Or any other idea ?

Does it support tags?

For ex. #something will it convert this to a specific html element so we can style it accordingly?

Filenames with spaces don't render correctly on GitHub pages

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?)

Support Obsidian aliases in frontmatter

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?

The problem with the "slash" symbol in the image path

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~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.