Skip to content

MarkdownAura v1.5.0

Choose a tag to compare

@westsource westsource released this 13 Oct 03:35
· 22 commits to main since this release

MarkdownAura 1.5.0

A link in a document now goes somewhere. Until now every link in the preview was a dead click: the
webview tried to navigate to it and CSP refused, which from the reader's side is the same as nothing
happening. Each destination is classified and routed (SPEC §13):

  • a URL — http, https, mailto — opens in the system browser, through the same
    tauri-plugin-opener the About sheet's GitHub line already used;
  • another Markdown file becomes a tab of this window, pinned rather than a preview tab;
  • any other local file opens the file manager on its folder with the file selected;
  • #id scrolls the document already open — the footnote references and their ↩ back-references
    are ids the renderer itself writes, so those work.

The details that decide whether this feels right:

  • A relative destination resolves against the folder of the document that carries it, never
    against the app. Absolute paths work as written, including the percent-encoded form markdown
    produces for backslashes (E:%5Cdocs%5Ca.md), and file:///C:/docs/a.md is read as the path it
    names — the form a copied browser address bar has. Protocol-relative (//host/a.md) is still a URL.
  • A destination that is not on disk says so — nothing at C:\… — instead of opening a tab that
    fails or a file manager on an empty folder. [x]() does nothing at all: a link with nowhere to go.
  • A click never navigates the webview. Every a[href] click is intercepted before it is
    classified: an <a href> left to itself navigates the app away from the document, and CSP turns
    that into precisely the dead click this release removes.
  • Whether a path is Markdown is decided in one place. The classification stops at "a path on this
    machine" and the click asks isMarkdownPath — the extension list still lives in one file, with no
    second copy in Rust.

The capability widened from one URL to three schemes. It used to allow exactly the About sheet's
GitHub URL; it now allows https://*, http://* and mailto:*. Anything else — a vscode: link, a
data: URI — is still refused by the capability layer rather than by app code, and the reader is shown
the URL so they can act on it themselves.

Nothing else about reading changed: no new setting, no storage change, no renderer change.


文档里的链接现在真的会去该去的地方。 在此之前,预览里的每个链接都是死链:webview 试图导航到它,而
CSP 拒绝,从读者角度看就是"点了没反应"。现在每个指向都会被分类并送到该去的地方(SPEC §13):

  • URL(http / https / mailto)交给系统浏览器,走的是"关于"面板里 GitHub 那行早就用的同一个
    tauri-plugin-opener;
  • 另一个 Markdown 文件开成本窗口的标签页,是固定标签而不是预览标签;
  • 其它本地文件在资源管理器中打开所在目录并选中该文件;
  • #id 在已打开的文档内滚动——脚注引用与它们的 ↩ 回跳是渲染器自己写下的 id,所以可用。

几个决定"用起来对不对"的细节:

  • 相对路径以承载它的文档所在目录为基准,而不是以应用为基准。绝对路径按原样解析,包括 markdown 为反斜杠
    生成的百分号编码形式(E:%5Cdocs%5Ca.md);file:///C:/docs/a.md 按它命名的路径读取——这正是从浏览器
    地址栏复制出来的形式。协议相对地址(//host/a.md)仍然算 URL。
  • 盘上不存在的目标会直说——… 处没有文件——而不是打开一个失败的标签页、或在空目录上打开资源管理器。
    [x]() 什么也不做:那是一个无处可去的链接。
  • 点击永远不会让 webview 导航。 每个 a[href] 的点击都在被分类之前就拦截:放任的 <a href> 会把应用
    从当前文档上导航走,而 CSP 会把它变成死链——正是本次要消除的东西。
  • "路径是不是 Markdown"只由一处决定。 分类止步于"这是本机的一个路径",随后由点击去问
    isMarkdownPath——扩展名表仍然只存一份,Rust 侧没有副本。

capability 从"一个 URL"放宽到"三种 scheme"。 它原本只允许"关于"面板里那条 GitHub 地址;现在允许
https://*、http://* 与 mailto:*。其它一律仍被权限层拒绝,而不是被应用代码拒绝——读者会看到那条 URL
本身,可以自行处理。

其余阅读行为没有变化:没有新设置项、没有存储格式改动、没有渲染器改动。