diff --git a/Marksman/Compl.fs b/Marksman/Compl.fs index 56e8123..5b3c9ab 100644 --- a/Marksman/Compl.fs +++ b/Marksman/Compl.fs @@ -339,6 +339,7 @@ module CompletionHelpers = match config.ComplWikiStyle() with | TitleSlug -> Slug.str (Doc.name doc) |> WTitle + | Title -> Doc.name doc |> WTitle | FileStem -> let name = docPath |> RelPath.filenameStem WPath(Approx(RelPath name)) diff --git a/Marksman/Config.fs b/Marksman/Config.fs index a609f34..8cf5a77 100644 --- a/Marksman/Config.fs +++ b/Marksman/Config.fs @@ -106,6 +106,8 @@ let private nonNegativeIntArrayFromTableOpt type ComplWikiStyle = /// Document title's slug, e.g. "A B C" -> "a-b-c" | TitleSlug + /// Document title as-is, e.g. "A B C" -> "A B C" (Obsidian-compatible) + | Title /// File name without an extension, e.g. "path/to/doc.md" -> "doc" | FileStem /// File path without an extension, e.g. "path/to/doc.md" -> "path/to/doc" @@ -115,6 +117,7 @@ module ComplWikiStyle = let ofString (input: string) : Result = match input.ToLower() with | "title-slug" -> Ok TitleSlug + | "title" -> Ok Title | "file-stem" -> Ok FileStem | "file-path-stem" -> Ok FilePathStem | other -> Error $"Unknown ComplWikiStyle: {other}" diff --git a/Marksman/Refs.fs b/Marksman/Refs.fs index 5f6e953..d22cef1 100644 --- a/Marksman/Refs.fs +++ b/Marksman/Refs.fs @@ -58,6 +58,7 @@ module FileLinkKind = fun destDoc -> match complStyle, Doc.slug destDoc = nameSlug, linkKindAsPath destDoc with | TitleSlug, true, _ + | ComplWikiStyle.Title, true, _ | _, true, None -> FileLinkKind.Title | _, _, Some fileKind -> fileKind | _, _, None -> FileLinkKind.FileName diff --git a/Tests/ConfigTests.fs b/Tests/ConfigTests.fs index 8c2cd9a..7fc3fb0 100644 --- a/Tests/ConfigTests.fs +++ b/Tests/ConfigTests.fs @@ -241,6 +241,20 @@ let testDefault () = let parsed = Config.tryParse content Assert.Equal(Some Config.Default, parsed) +[] +let testParse_wikiStyle_title () = + let content = + """ +[completion] +wiki.style = "title" +""" + + let actual = Config.tryParse content + + let expected = { Config.Empty with complWikiStyle = Some ComplWikiStyle.Title } + + Assert.Equal(Some expected, actual) + [] let testDefault_titleVsCompletionStyle () = let content = diff --git a/Tests/default.marksman.toml b/Tests/default.marksman.toml index 37b4022..bd834f7 100644 --- a/Tests/default.marksman.toml +++ b/Tests/default.marksman.toml @@ -48,7 +48,8 @@ create_missing_file.enable = true # The maximum number of candidates returned for a completion candidates = 50 # The style of wiki links completion. -# Other values include: +# Other values include: +# * "title" to complete using raw title text (Obsidian-compatible, e.g. "My Note"), # * "file-stem" to complete using file name without an extension, # * "file-path-stem" same as above but using file path. wiki.style = "title-slug" diff --git a/docs/features.md b/docs/features.md index a8e1ec6..05c1060 100644 --- a/docs/features.md +++ b/docs/features.md @@ -57,6 +57,18 @@ See [this config file](../Tests/default.marksman.toml) for more details. Wiki links can use both a title and a filename to reference a document. The preferred style of completion is configured via `completion.wiki.style` configuration setting. +Available styles: + +| Style | Example | Notes | +|-------|---------|-------| +| `title-slug` (default) | `[[my-note-title]]` | Slugified title (lowercase, spaces → hyphens) | +| `title` | `[[My Note Title]]` | Raw title text as-is — Obsidian-compatible | +| `file-stem` | `[[my-note]]` | Filename without extension | +| `file-path-stem` | `[[subdir/my-note]]` | Relative file path without extension | + +The `title` style is recommended for users who want full Obsidian compatibility: both tools +will generate `[[Raw Title Text]]` links that each resolves correctly. + See [the example config file](../Tests/default.marksman.toml) for more details. ### Completion style and refactorings diff --git a/docs/rfc-wiki-title-style.md b/docs/rfc-wiki-title-style.md new file mode 100644 index 0000000..81af4df --- /dev/null +++ b/docs/rfc-wiki-title-style.md @@ -0,0 +1,34 @@ +# RFC: Wiki Completion `title` Style + +## Problem + +Some Markdown editors (notably Obsidian) prefer wiki links that preserve the document title text, +for example `[[My Note Title]]`, instead of slugified output like `[[my-note-title]]`. + +## Goal + +Add a new completion style `completion.wiki.style = "title"` so generated wiki links can +use the raw title text and remain Obsidian-compatible. + +## Configuration + +```toml +[completion] +wiki.style = "title" +``` + +## Behavior + +Available styles: + +- `title-slug` (default): slugified title +- `title`: raw title text +- `file-stem`: filename without extension +- `file-path-stem`: relative path without extension + +When `title` is selected, completion emits `[[]]`. + +## Compatibility + +- Existing style values remain unchanged. +- Link resolution behavior is preserved; this RFC only adds a new output style option.