LoginSignup
0
0

More than 5 years have passed since last update.

Firefox + Markdown Viewer + GolangでMarkdownをプレビューする

Last updated at Posted at 2018-03-18

Chrome + Markdown Viewer + LiveReloadでリアルタイムにMarkdownをプレビューするで使ったMarkdown ViewerですがFirefoxでも試したので、そのメモを残しておきます。

Markdown Viewer

Firefox版のMarkdown Viewerです。

Markdown Viewer

試した時のつまりポイント

  • Firefoxはデフォルトで file:// でアクセスしたファイルをブラウザから開けないようになっている
  • Markdown Viewerでmdファイルを開くにはWebサーバ経由でアクセスする必要がある

解決策

  • ここでは、Goで簡易Webサーバを作ってブラウザからローカルサーバにアクセスしファイルを開くやり方を試して見ました

手順

Firefox Add-onインストール

(1) Markdown Viewerをインストールします。

Webサーバの立ち上げ

(1) 以下の 公開するパス にDocumentRootになるパスを指定します。

main.go
package main

import (
        "net/http"
)

func main() {
        dir_path := "公開するパス"
        http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(dir_path))))
        http.ListenAndServe(":8000", nil)
}

(2) 実行します。

$ go run main.go

Markdown Viewerの設定

(1) 画面右上のMarkdown Viewerアイコンをクリックして ADVANCED OPTIONS をクリックします。

スクリーンショット 2018-03-18 13.01.11.png

(2) HTTP:// に変更して localhost を入力し ADD をクリックします。

スクリーンショット 2018-03-18 13.03.28.png

スクリーンショット 2018-03-18 13.03.36.png

(3) あとはブラウザのURL欄に localhost:8000/mdまでのパス を入れて開けばMarkdownがプレビューできます。

スクリーンショット 2018-03-18 13.05.00.png

スクリーンショット 2018-03-18 13.06.50.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0