Try   HackMD

在 Obsidian 設定免費的拼字檢查:使用開源軟體 LanguageTool 並部屬至 Railway.app

TL;DR

  1. fork 我修改的 LanguageTool Docker
  2. 去 Railway 部屬這個 Repo
  3. 更新 Obsidian LanguageTool 的伺服器設定

最近想試著調高點發文頻率,原因還是堆積的草稿太多了。以前不能接受未完成的東西出品,但想想,程式碼都可以 Release early, release often 了,同樣對待寫作也未嘗不可,這裡也只是我個人的部落格罷了,也沒走什麼 Launch 流程,比如發送電子報、到臉書社團發文貼連結等。

在 Obsidian 使用免費的 LanguageTool 來做拼字檢查

回歸標題,身為一個專業免費仔,該如何在 Obsidian 裡使用拼字檢查呢?平常有在用 Grammarly 做簡單文法檢查的我,馬上搜尋到這篇官方論壇的討論:Any way to integrate Grammarly as plugin? ,裡面這張 LanguageTool 的截圖馬上引起我的注意:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

搜尋了一下 LanguageTool,卻發現有以下限制

  • 20 requests per IP per minute (this is supposed to be a peak value - don’t constantly send this many requests or we would have to block you)
  • 75KB text per IP per minute
  • 20KB text per request
  • Only up to 30 misspelled words will have suggestions.

雖然限制挺寬鬆的,簡單寫些文件應該不容易超過限制,但身為一個專業免費仔,當然要解除限制,並且還不能花到任何一毛錢,這才是所謂的專業

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

部屬 LanguageTool 到 Railway.app

前陣子 Heroku 大逃難時,敝司也參了一腳,當時研究了幾個 Heroku 的替代品,除了很多人推的 Render,另一個呼聲也很高的服務就是 Railway (同樣以 R 為開頭,所以現在是要抱團跟 Raycast 組一個 R-League ㄇ)。

LanguageTool 已經有貢獻者打包了自己的 Dockerfile,不過像 Railway 這種 PaaS 平臺,服務跑起來的 Port 都是執行時才會指定,一般也會用 $PORT 這個環境變數來指定(12 factor 留下來的優秀傳統),所以這裡就要來修改一下 Dockerfile 啦。

詳細請看 fork repo 的 commit fb9b812,就是把 Port 拆出來而已,也有參考 Railway 的文件,裡面提到 Railway 會把環境變數用 ARG 傳入。

修改完之後接續異常順暢的 Railway 部屬流程,設定好 Repository 到我 fork 的 LanguageTool Docker Repository(需要的人請自己 fork 一份),跑起來服務,並在 Obsidian LanguageTool Integration Plugin 裡設定好新的伺服器位址,就可以免費用自架的 LanguageTool 啦!

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

備註

  1. Railway Starter Plan 其實有 500hr 的限制,如果一直開機換算時數只有 20 天而已
  2. 不知為何 LanguageTool Service 常常會自己 Crash,可以把 Auto-Restart 開啟。不過就要注意前面一點時數的問題
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →