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
1 change: 1 addition & 0 deletions Marksman/Compl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions Marksman/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -115,6 +117,7 @@ module ComplWikiStyle =
let ofString (input: string) : Result<ComplWikiStyle, string> =
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}"
Expand Down
1 change: 1 addition & 0 deletions Marksman/Refs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions Tests/ConfigTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ let testDefault () =
let parsed = Config.tryParse content
Assert.Equal(Some Config.Default, parsed)

[<Fact>]
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)

[<Fact>]
let testDefault_titleVsCompletionStyle () =
let content =
Expand Down
3 changes: 2 additions & 1 deletion Tests/default.marksman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 12 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions docs/rfc-wiki-title-style.md
Original file line number Diff line number Diff line change
@@ -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 `[[<Doc title as written>]]`.

## Compatibility

- Existing style values remain unchanged.
- Link resolution behavior is preserved; this RFC only adds a new output style option.