Coder Social home page Coder Social logo

markdown-preview-mode's Introduction

Markdown preview mode

MELPA Stable MELPA

Markdown preview in emacs features:

  • on save/idle preview update
  • scroll sync
  • custom/extra css and javascript
  • remote preview
  • multiple simultaneous previews

Install

  • package-install markdown-preview-mode
  • el-get-install markdown-preview-mode

Markdown processor

markdown-preview-mode depends on markdown-mode for markdown processor, defined by markdown-command and it is markdown by default. Please, make sure it is in your $PATH.

Run

  • markdown-preview-mode - start mode and open preview window.
  • markdown-preview-open-browser - open preview window for current buffer.
  • markdown-preview-cleanup - cleanup running processes (close websocket and http servers).

Customize

  • customize-option markdown-command - change markdown processor; take a look at multimarkdown
  • customize-option browse-url-browser-function - change the browser.
  • customize-option markdown-preview-host - change http/websocket server address.
  • customize-option markdown-preview-ws-port - change websocket server port.
  • customize-option markdown-preview-http-port - change http server port.
  • customize-option markdown-preview-auto-open - change the way preview window is open.

Remote access

  • Customize markdown-preview-host to 0.0.0.0.
  • Customize markdown-preview-http-host to 0.0.0.0.
  • Set markdown-preview-auto-open to nil to disable window opening at remote emacs server.
  • Start markdown-preview-mode. Http link for preview will be printed to *Messages* buffer. If not - run markdown-preview-open-browser to get the link printed.
  • Setup 2 tunnels for 0.0.0.0:7379 and 0.0.0.0:9000 and then open preview link in local browser. Adjust tunnels according to your custom ws-port and http-port settings.

Extra css

Add extra css to default solarized dark theme

(add-to-list 'markdown-preview-stylesheets "https://raw.githubusercontent.com/richleland/pygments-css/master/emacs.css")

Override theme completely

(setq markdown-preview-stylesheets (list "http://thomasf.github.io/solarized-css/solarized-light.min.css"))

Extra javascript

Add MathJax

(add-to-list 'markdown-preview-javascript "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML")

async

(add-to-list 'markdown-preview-javascript '("http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML" . async))

Dependencies

markdown-preview-mode's People

Contributors

adelatorrefoss avatar adrieankhisbe avatar ancane avatar chwarr avatar jcs090218 avatar jj1uzh avatar juergenhoetzel avatar leungbk avatar makiuchi-d avatar makotoshimazu avatar masutaka avatar syohex avatar uqix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markdown-preview-mode's Issues

Hardcoded Stylesheet in .markdown-preview.html

Altough I change the style sheet by customizing markdown-preview-style, I still am not able to get the right stylesheet connected in the preview. I check this out and in the .html file the link to the standard thomasf.github stylesheet is present. Can you help me out? Thanks a lot.

"make server process failed" when enabling markdown-preview-mode

Hi,

I'm seeing this when I try to enable markdown-preview-mode

apply: make server process failed: Success, :name, ws-server, :service, 9000, :filter, ws-filter, :server, t, :nowait, t, :family, ipv4, :coding, no-conversion, :plist, (:server #s(#s(eieio--class ws-server nil nil [#s(cl-slot-descriptor handlers nil t nil) #s(cl-slot-descriptor process nil t nil) #s(cl-slot-descriptor port nil t nil) #s(cl-slot-descriptor requests nil t nil)] #s(hash-table size 65 test eq rehash-size 1.5 rehash-threshold 0.8125 data (handlers 0 process 1 port 2 requests 3 ...)) nil ((:handlers . handlers) (:process . process) (:port . port) (:requests . requests)) [] [] ...) (lambda (&rest --cl-rest--) (apply (function #[(G62 request) ��	""AO�
�J"�
6\0	"
r	"!��"q��)""f\0
J\0	"
��""f\0!`\0!`\0	""f\0	"!+ [request object path G62 filename markdown-preview-file-name assoc :GET slot-value headers ...] 9]) (quote --docroot--) --cl-rest--)) nil 9000 nil)), :log, nil, :host, localhost

The browser window opens but no process is listening on port 9000.

I have the markdown command in the path, and the markdown-preview command opens the preview in the browser correctly. I tried changing the http and ws ports but that didn't help.

I'm running GNU Emacs 26.0.91, and markdown-preview-mode v. 20171121.2323.

Cheers
Diego

Cannot open localhost:9000

Hi, I am using ArchLinux(4.17.11-arch1) and emacs 26.1.
When I open markdown-preview-mode, it automatically opens browser but it just says "This site cannot be reached".

Am I missing something to configure?
I confirmed 9000 port is not opened with lsof command.

Listen on localhost by default

In commit ahyatt/emacs-websocket@19f9b3b, support was added to the websocket package to specify the host to listen on.

I think it would be good to build atop this functionality and have markdown-preview-mode listen only on localhost by default (with customization to support alternatives).

Is this a feature that would make sense? (I have it coded up and tested against websocket HEAD, but wanted to start with an issue instead of a PR.)

And, anyway, we'd need to wait for a new version of websocket to be published to consume this in stable.

Problems with utf8 charset

I've got problems with utf8 characters, (e.g.: "é" is shown as "é").

By the way, it's a pretty cool mode !

wrong-type-argument websocket nil

I am trying to configure markdown-preview-mode for remote access rather than launching a browser. I'm trying to follow the directions in the README. I have created the following:

(use-package markdown-preview-mode
  :ensure t
  :if (boundp 'mdcommand)
  :init
  (setq markdown-preview-auto-open nil)
  :custom
  (markdown-preview-host "0.0.0.0")
  (markdown-preview-http-host "0.0.0.0"))

When markdown-preview-mode is enabled, it continuously prints the following error in the mini buffer:
====> Error: (wrong-type-argument websocket nil)

What am I doing wrong?

Update on idle stops working after a couple of minutes

I'm really enjoying using markdown-preview-mode and it does its job very well. Thanks for this excellent project.

Unfortunately, update on idle (which I find really useful), seems to stop working after a couple of minutes. Any ideas what might be causing this issue?

Setting `markdown-preview-style` doesn't work

The Solarized Dark theme is still being used, despite chaing the setting in customize:

(custom-set-variables
 '(markdown-preview-style
   "https://raw.githubusercontent.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css")
)

error in process filter: Not enough arguments for format string

Hi, I tried to use markdown-preview-mode but failed.
I have installed markdown command with $apt install markdown.
So my installation may be correct.

Following is from *Messages* buffer

Markdown-Preview mode enabled in current buffer
Websocket opened
You can run the command ‘markdown-preview-mode’ with M-x ma-p-m RET
Websocket opened
error in process filter: Not enough arguments for format string [2 times]

Thanks.

Can't install. Package 'uuidgen-0.3' is unavailable.

Hi, I am relatively new to Emacs.
When I tried execute package-install RET markdown-preview-mode, it gave me that error.
I followed the link you provided in README to uuidgen, but I didn't understand anything at all.
What exactly I need to do?

just reports "JavaScript alerts." "Errors: undefined" and "Connection terminated"

websockets -- 1.4 straight from git , loaded directly via load-library. The same way loaded markdown-preview-mode. Base system -- Debian jessie, emacs
24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)

Results in a window simply with "Markdown preview" text in it

and

WebSocket connection to 'ws://localhost:7379/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Code: 1006 reason: 

sorry if it is just a user issue ;)
in console

Allow to disable auto-scroll

Using happily this mode. However, often, auto-scroll is frustrating (because going against my will to scroll where I want).

IMHO one of those might be implemented:

  • a control on the HTML document to toggle auto-scroll on/off
  • a customizable variable to entirely disable auto-scroll

The better I can think about would be :

  • if you manually scroll the document, disable auto-scroll and show a control to re-enable auto-scrolling.

Just thinking about it, though I could share it :-)

Mathjax

Thanks for this mode -- it's just what I needed! Two notes about getting it to work with Mathjax:

The cdn.mathjax.org URL in the Readme is obsolete.

With a modern (version 3) Mathjax, I had to set this:

(setq markdown-preview-script-onupdate "MathJax.typeset()")

Without that, Mathjax will render with the preview first loads, but will revert to unrendered after the first update.

Doesn't open browser

When starting markdown-preview-mode I don't get a preview in my browser. Not even when manually running markdown-preview-open-browser.

I checked that browse-url-at-point works (which uses browse-url-browser-function) and it does.

I use pandoc to generate markdown and this is the value of markdown-command:

pandoc -s -f markdown_github -c file:///home/mattiasb/.emacs.d/github-pandoc.css

might this be the cause?

Question? Is remote live preview possible?

It's nice that this package uses websockets to send the changes to the browser, most other packages only support reloading a file on disk.

I strictly use emacs over ssh, but still I'd like to preview the markdown in my local browser (the machine I'm typing on, not the remote machine running the emacs process). I can easily proxy the web socket ports to my local box using.

ssh -NL 0.0.0.0:7379:0.0.0.0:7379 my-box-with-emacs

That's awesome, but the sticking point right now is the initial html payload that loads the JS is using browse-url which doesn't work, it open the browser on the remote machine running emacs.

Would it be possible to also server that "preview" file over http:// vs file://? If that was supported I'd be able to forward that second http port (say 8080) and open the preview on my local machine.

ssh -NL 0.0.0.0:8080:0.0.0.0:8080 my-box-with-emacs

`github` stylesheet

Hi,
I like markdown-preivew-mode very much. Is there a stylesheet for github? Since it's popular, and I'd like preview before pushing online.

I changed according to #2, but it seems doesn't work now.

lexical-let needs cl

markdown-preview-mode results in error: "helm-M-x: Invalid function: (docroot default-directory)", which is caused by (lexical-let ((docroot default-directory)) I think.

Error displayed in web browser when "markdown-preview-mode" is run

I have not been able to get this working correctly. I've customized my markdown-command, and when I run markdown-preview I get a markdown displayed in my browser.

But, when I run markdown-preview-mode, the following is displayed in my browser:

Caught Error: (wrong-type-argument stringp nil)

The URL is set to: http://localhost:9000/?uuid=ef199220-c8b3-42f8-8d82-5eeb4ad96966
(or similar)

I'm using the following for my markdown-command (and its in the path): python -m markdown

Emoji supports?

I recently hack through this package and have the emoji support for this package!

Image 1

Mainly, how I did this is using showdown and advising many of the code from this package. See jcs-emacs/jcs-emacs@1ca1dad.

Is there a default way to do this? If not, would you consider this feature? Thanks!

Error: (wrong-type-argument arrayp nil) on Windows

Hi,

  • My system is Windows 10 64bit
  • Emacs is GNU Emacs 25.3.1 (x86_64-w64-mingw32)

I installed markdown-preview-mode through the built-in package installer.

After I execute markdown-preview-mode, a webpage is opened with only one line, saying Markdown preview. On the Emacs *Message* buffer I got ====> Error: (wrong-type-argument arrayp nil).

One odd observation, after I started the preview mode, I cannot access most of the website. Chrome shows ERR_TUNNEL_CONNECTION_FAILED error. But after I exit Emacs, which automatically killed the WS process, I can browse as normal.

Can I add extra css files?

Current preview can only add one css file. If I want to add multiple files to it. How should I change the code?
Thanks!

Byte-compiler warning that the function 'my-filter' is unknown

Byte compilation of the latest version of the file gives a warning about the function my-filter not defined, as used in the advice-remove form in the last line of markdown-preview--start-http-server.

Here's the byte compiler log:

Compiling file /Users/roup/.emacs.d/elpa/markdown-preview-mode-20210207.2114/markdown-preview-mode.el at Sat May 15 12:25:59 2021

In end of data:
markdown-preview-mode.el:419:1:Warning: the function ‘my-filter’ is not known
    to be defined.

When `markdown-preview-cleanup` but it doesn't really cleans up?

This might be a question that I have been trying to use the command markdown-preview-cleanup after markdown-preview-mode is enabled and disabled. But I try to close it; it tells me that there are processes that haven't been shutdown. Should the command markdown-preview-cleanup already does this such a task for me? 😕

Relative path for links

I'm trying to embed an SVG into my markdown. I have it set as a relative path
![Some image](../some_image.svg)
But, since the server is watching a temporary file in a different directory it loads a broken link.

How can I get the markdown-preview-mode to embed images with relative paths?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.