Skip to content
Open
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
56 changes: 56 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Change Request

Make sure not to commit this file and don't apply to gitignore. This is a working document that should always be located here but never committed

I've noticed when using the new `--pdf-and-markdown` flag the markdown is not formatted much and also duplicates what I'd need. Let's try and resolve this.

## Template

Here is a markdown block example of the current format. You'll get this if you investigate how the `../supernote-companion` project integrates with the result of this project.

```md
---
name: 2025 - LBC - Galatians Colossians study
supernote_id: sn-4edfd817
source: /Note/2025 - LBC - Galatians Colossians study.note
created: 2025-12-07
modified: 2025-12-07
size: 71.3 MB
pdf_attachment: REFERENCE/SUPERNOTE/PDF's/2025 - LBC - Galatians Colossians study.pdf
tags:
- supernote
updated: 2026-03-01T22:07
---

# 2025 - LBC - Galatians Colossians study

## Note Information

| Property | Value |
|----------|-------|
| **Source** | `/Note/2025 - LBC - Galatians Colossians study.note` |
| **Created** | December 7, 2025 at 08:07 AM |
| **Modified** | December 7, 2025 at 08:07 AM |
| **Size** | 71.3 MB |

## PDF Attachment

![[REFERENCE/SUPERNOTE/PDF's/2025 - LBC - Galatians Colossians study.pdf]]

---

## Notes

*Add your notes and annotations here...*
```

## Solution

I'd like to extend upon this template that the markdown file produced adds the text in a section after the referenced pdf attachment titled `Text`.
Please meet all the meta data provided the numbers in this template were derived from the `.note` file.
This is used within obsidian and I use wikilink style links.
The `updated` and `created` fields are created from another plugin that you don't need to produce, this will be handled by another plugin. You can however have equivalent fields prefixed with `supernote_` that are from the super note .note file metadata
The template above is produced from `2025 - LBC - Galatians Colossians study.note` file.
I've noticed with the files provided using the flag `--pdf-and-markdown` have like 2 sections of text. Text like its written then the same text but a newline for each word. Can I remove the latter section. I'd rather just have the text in paragraph form.

Now make it an option with another flag to remove the new lines altogether and only have spaces between words. Unless there is 2 new line characters detected. Then this would leave the text nicer formatted for editors.
114 changes: 112 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ license = "MIT"
name = "supernote_pdf"
readme = "README.md"
repository = "https://github.com/RohanGautam/supernote_pdf"
version = "0.1.1"
version = "0.1.3-dev.0"

[[bin]]
name = "supernote_pdf"
path = "src/main.rs"

[[bin]]
name = "supernote_sync"
path = "src/main.rs"

[dependencies]
anyhow = "1.0.98"
chrono = { version = "0.4.41", default-features = false, features = ["clock"] }
clap = {version = "4.5.43", features = ["derive"]}
flate2 = "1.1.2"
image = "0.25.6"
Expand Down
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ This tool is designed for one thing: converting Supernote `.note` files to PDF a
- **🚀 Blazing Fast:** Asynchronously decodes pages and processes entire folders in parallel. See [Benchmarks](#-benchmarks) for details.
- **📂 Directory Conversion:** Converts an entire folder of `.note` files, perfectly preserving the original directory structure.
- **💻 Simple & Powerful CLI:** A straightforward command-line interface for single-file or batch conversions.
- **📝 Text Extraction:** Optional OCR-text extraction mode for notes with Supernote recognition data (`RECOGNTEXT`), outputting `.txt`.
- **📄+📝 PDF and Markdown Mode:** Optional mode to generate both `.pdf` and `.md` per note in one run.
- **📝 Markdown-only Mode:** Optional mode to generate `.md` only (no PDF output).
- **🔧 Optimized for Archival:** Creates PDFs with embedded images, keeping file sizes small and conversion times low for densely written notes.
- **✅ Robust:** Includes safety checks to prevent accidental data loss (e.g., won't overwrite an existing output directory).

Expand Down Expand Up @@ -49,13 +52,15 @@ Several key design decisions were made to optimize for the primary goal of fast,

### From Crates.io (Recommended)

Ensure you have the [Rust toolchain installed](https://www.rust-lang.org/tools/install). Then, you can install `supernote_pdf` CLI directly from Crates.io using `cargo`:
Ensure you have the [Rust toolchain installed](https://www.rust-lang.org/tools/install). Then install from Crates.io:

```bash
cargo install supernote_pdf
```

and `supernote_pdf` will be available as a tool in your shell.
This now installs **two compatible binary names**:
- `supernote_sync` (new preferred name)
- `supernote_pdf` (legacy name, still supported)

### From Source

Expand All @@ -77,6 +82,18 @@ The CLI is simple, requiring an input path and an output path.
supernote_pdf -i <input-path> -o <output-path>
```

To extract recognized text instead of generating a PDF, add `--extract-text` and use a `.txt` output.

To generate both a PDF and a Markdown file per note, add `--pdf-and-markdown`. This mode writes PDFs as normal and writes Obsidian-friendly Markdown with Supernote metadata, PDF wikilink attachment, and recognized text (`RECOGNTEXT`) in a `## Text` section.

To generate Markdown only (no PDF), add `--markdown-only` and set the output extension to `.md` (or an output directory for batch mode).

For **smart default sync behavior**, use `--auto-output`: it always writes PDF, and writes Markdown only when recognized text exists in the `.note` content.

If you want cleaner paragraph text in markdown, add `--normalize-text-whitespace` (requires `--pdf-and-markdown`, `--markdown-only`, or `--auto-output`). This converts single newlines to spaces while preserving paragraph breaks (double newlines).

Smart markdown breaks are now enabled by default in markdown modes (`--pdf-and-markdown` and `--markdown-only`) for better readability in Obsidian. The `--smart-markdown-breaks` flag is kept for compatibility.

### Example 1: Convert a Single File

To convert a single `.note` file to a `.pdf` file:
Expand All @@ -97,6 +114,50 @@ The tool will scan for all `.note` files in the input directory, recreate the fo

**Note:** For safety, the output directory must not already exist. This prevents you from accidentally overwriting previous backups.

### Example 3: Extract Text from a Single File

```bash
supernote_pdf -i "My Notes/Meeting Agenda.note" -o "Archive/Meeting Agenda.txt" --extract-text
```

### Example 4: Extract Text from an Entire Directory

```bash
supernote_pdf -i path/to/your/Note_folder -o path/to/your/Note_Text --extract-text
```

This mirrors the source directory structure and writes one `.txt` file per `.note` file.

### Example 5: Generate PDF + Markdown from a Single File

```bash
supernote_pdf -i "My Notes/Meeting Agenda.note" -o "Archive/Meeting Agenda.pdf" --pdf-and-markdown
```

This writes:
- `Archive/Meeting Agenda.pdf`
- `Archive/Meeting Agenda.md`

### Example 6: Generate PDF + Markdown from an Entire Directory

```bash
supernote_pdf -i path/to/your/Note_folder -o path/to/your/Note_PDFs --pdf-and-markdown
```

This mirrors the source directory structure and writes `.pdf` and `.md` sibling files for each `.note`.

### Example 7: Generate PDF + Markdown with paragraph-normalized text

```bash
supernote_pdf -i "My Notes/Meeting Agenda.note" -o "Archive/Meeting Agenda.pdf" --pdf-and-markdown --normalize-text-whitespace
```

### Example 8: Generate Markdown only (no PDF)

```bash
supernote_pdf -i "My Notes/Meeting Agenda.note" -o "Archive/Meeting Agenda.md" --markdown-only
```

## 📊 Benchmarks

`supernote_pdf` is significantly faster than available tools, making it ideal for large and frequent backups.
Expand Down
12 changes: 12 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]

# Build release binary locally
build:
cargo build --release

# Install supernote_pdf globally from this local checkout
# Equivalent to: cargo install --path . --force
# (force is used so local changes are reinstalled)
deploy_local: build
cargo install --path . --force
echo "Installed supernote_pdf globally from $(pwd)"
Loading