Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added pics/2.6.2/callouts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/2.6.2/start-in-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 20 additions & 26 deletions samples/test-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ Jumps to location in document

---

# Callouts

> [!note] Custom titled callout
> This is a note callout

> [!tip] You can combine ==highlights== with **bold** for emphasis.

> [!IMPORTANT] Nested callouts work too
> > [!note] Nested callout
> > This is a nested callout
> > > [!info] Nested callout
> > > This is a nested callout

---

# Highlights

You can ==highlight text== inline just like in Obsidian.
You can ==highlight text== inline.

Multiple ==highlights== can appear ==in the same== paragraph.

Expand Down Expand Up @@ -50,7 +65,7 @@ Long note name with alias — this demonstrates that the block ID is separate fr

A third paragraph with its own anchor you can reference from the TOC. ^third-anchor

Obsidian-style internal links: [[#important]] jumps to the first paragraph above.
Internal links: [[#important]] jumps to the first paragraph above.

---

Expand Down Expand Up @@ -103,25 +118,6 @@ And level 5.

---

## GFM Alerts

> [!NOTE]
> This is a note alert — check if the icon and color are correct.

> [!TIP]
> Tip: combine ==highlights== with**bold** for emphasis.

> [!IMPORTANT]
> Block IDs ^block-in-quote are supported inside blockquotes too.

> [!WARNING]
> Task toggles auto-save to disk — make sure you have write access.

> [!CAUTION]
> Unchecking a task rewrites the raw markdown file immediately.

---

## Code Blocks

Inline code: `let x = 42;` — `==no highlight here==`
Expand Down Expand Up @@ -160,7 +156,7 @@ fn process_highlights(content: &str) -> String {
| Standard footnotes | `[^ref]` | ✅ |
| Block IDs | `^id` | ✅ |
| Task toggle | `- [ ]` click | ✅ |
| Obsidian links | `[[#heading]]` | ✅ |
| Wikilinks | `[[#heading]]` | ✅ |

---

Expand All @@ -176,7 +172,8 @@ Superscript: x^2 (not supported inline) vs actual footnote^[this is a footnote].

A regular link: [GitHub](https://github.com)

An image: ![Test](https://via.placeholder.com/400x200?text=Test+Image)
An image:
![Test](https://picsum.photos/400/200)

---

Expand Down Expand Up @@ -227,6 +224,3 @@ graph TD
B -->|No| D[Debug it]
D --> B
```

---

23 changes: 17 additions & 6 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ async fn show_window(window: tauri::Window) {
window.show().unwrap();
}

fn process_obsidian_embeds(content: &str) -> Cow<'_, str> {
// Match code blocks, inline code, or obsidian embeds
fn process_internal_embeds(content: &str) -> Cow<'_, str> {
let re = Regex::new(r"(?s)```.*?```|`.*?`|!\[\[(.*?)\]\]").unwrap();

re.replace_all(content, |caps: &Captures| {
Expand Down Expand Up @@ -56,7 +55,7 @@ fn process_obsidian_embeds(content: &str) -> Cow<'_, str> {
})
}

fn process_obsidian_links<'a>(content: &'a str) -> Cow<'a, str> {
fn process_wikilinks<'a>(content: &'a str) -> Cow<'a, str> {
let mut processed = Cow::Borrowed(content);

// 1. Process [[#target]] or [[#target|alias]]
Expand Down Expand Up @@ -135,8 +134,8 @@ fn process_obsidian_links<'a>(content: &'a str) -> Cow<'a, str> {

#[tauri::command]
fn convert_markdown(content: &str) -> String {
let processed_embeds = process_obsidian_embeds(content);
let processed_links = process_obsidian_links(&processed_embeds);
let processed_embeds = process_internal_embeds(content);
let processed_links = process_wikilinks(&processed_embeds);

let mut options = ComrakOptions {
extension: ComrakExtensionOptions {
Expand Down Expand Up @@ -180,6 +179,11 @@ fn save_file_content(path: String, content: String) -> Result<(), String> {
fs::write(path, content).map_err(|e| e.to_string())
}

#[tauri::command]
fn save_file_binary(path: String, data: Vec<u8>) -> Result<(), String> {
fs::write(path, data).map_err(|e| e.to_string())
}

#[tauri::command]
fn open_file_folder(path: String) -> Result<(), String> {
opener::reveal(path).map_err(|e| e.to_string())
Expand Down Expand Up @@ -577,6 +581,11 @@ fn delete_file(path: String) -> Result<(), String> {
Ok(())
}

#[tauri::command]
fn copy_file(src: String, dest: String) -> Result<(), String> {
fs::copy(src, dest).map(|_| ()).map_err(|e| e.to_string())
}

#[tauri::command]
fn cleanup_empty_img_dir(parent_dir: String) -> Result<(), String> {
let img_dir = Path::new(&parent_dir).join("img");
Expand Down Expand Up @@ -764,7 +773,7 @@ pub fn run() {
if is_installer_mode {
let _ = window.set_size(tauri::Size::Logical(tauri::LogicalSize {
width: 450.0,
height: 550.0,
height: 650.0,
}));
let _ = window.center();
}
Expand All @@ -780,6 +789,7 @@ pub fn run() {
send_markdown_path,
read_file_content,
save_file_content,
save_file_binary,
get_app_mode,
setup::install_app,
setup::uninstall_app,
Expand All @@ -800,6 +810,7 @@ pub fn run() {
save_image,
copy_file_to_img,
delete_file,
copy_file,
cleanup_empty_img_dir,
list_directory_contents
])
Expand Down
Loading
Loading