I would not recommend investing in the iOS Notes ecosystem. There is no way to export these notes with their metadata and media intact without using iCloud. If you need a note-taking app, go with Joplin instead; it supports Markdown, has both iOS and desktop clients, and supports self-hosted syncing.
You can connect iOS Notes with any IMAP server. This supports a reduced feature set (no embedded images, tables, or audio) but does allow for self-hosting.
Apple Notes is not intended for people who want to own their data and have control over export