seagle0128 / grip-mode Goto Github PK
View Code? Open in Web Editor NEWInstant Github-flavored Markdown/Org preview using grip
License: GNU General Public License v3.0
Instant Github-flavored Markdown/Org preview using grip
License: GNU General Public License v3.0
I was thinking that it'd be great if grip-mode had autoscroll support, so the browser window scrolls alongside the emacs buffer. The markdown-preview-mode browser already implements it.
Hi, when opening a preview using grip-mode, it always opens on the bottom instead of the right, how would I fix this?
I'm using doom emacs with emacs-plus@28 (with xwidgets), my config is here: https://github.com/shaunsingh/vimrc-dotfiles/blob/main/.doom.d/config.org
It seems that the best version is emacs-mac on macOS, however it seems to not support xwidget so that I cannot use grip mode in emacs buffer.
Any recommendations?
I was under the impression that the default behavior would be to open an external browser, like the first screenshot. Is there a way to make it open an external browser? I tried setting the default browser like the readme instructed, but that didn't fix it
It looks like I have to save the org file each time I want to preview it as you said in your limitations: "Need to save the buffer before rendering and previewing."
So to me it's not an instant preview or am I missing something here. Is it a present time only limitation ?
Many thanks for your feedback.
Hi,
from your README it is not clear for me what ox-gfm is, what for do I need it and how to setup it up and connect it with your package.
Maybe you can improve your README/FAQ with that info.
Kind
Christian
If I have multiple windows open, M-x grip-mode
seems to detect the first one I had open instead of the one currently in focus. Note that I use eyebrowse. Am willing to help debug this if needed.
Also, a weird thing happened. I had my init.el
open in a non-focused window. I called grip-mode
on a Markdown file in the focused window. It tried to render my init.el
, and when I killed the buffer for init.el
, the file was removed from disk as well. I've never something like this happen before so I'm assuming it's due to this package.
Thanks a lot for that package and the great documentation. You also take use-package
into account which is unusual. Thanks for that!
It seams like that my Emacs 27.1 (Debian 11) was not build with --with-xwidgets
. Even when I do (setq grip-preview-use-webkit t)
the preview is opened in my systems default browser.
But I still want to have the preview in a second buffer.
Are you aware of any elpa browser packages that could be used in such a case?
EDIT: I learned about eww-mode
. I am not sure how to connect that with grip. But normal websites and also README.md files from some GitHub pages looking ugly. That is not what I understand about a HTML rendered preview.
I am using centaur and Emacs 26.3. After firing the command grip-mode
on a markdown buffer, the WebKit page shows internal server error
.
But there is no problem with the markdow-preview
command (preview using chrome browser).
Does grip-mode work with files being edited using Tramp mode?
Tramp mode allows emacs user to edit files located on a remote machine "transparently" to user, in the backend using, e.g., ssh
or scp
When I try to preview using grip-mode in Emacs, I see the following in `Messages buffer:
Tramp: Encoding local file ‘/var/folders/vf/ll67jl_j0m996xwvpty_ssdm0000gn/T/tramp.zJeD5Z.tmp’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/ssh:rpit8:/home/pi/projects/raspi-receiver-remote-control/README.md.tmp’ using ‘base64 -d -i >%s’...done
Preview /ssh:rpit8:/home/pi/projects/raspi-receiver-remote-control/README.md on http://localhost:18693
The file in this example is /ssh:rpit8:/home/pi/projects/raspi-receiver-remote-control/README.md
and there's a README.md.tmp
file visible on the remote filesystem next to README.md
But there's no grip server I can find, either remotely or locally, and no browser view. My setup is running Emacs27 on macOS and trying to preview edits for markdown files on a remote Raspberry Pi (Raspian).
Is it possible that this feature might involve optionally having the .tmp file be placed on the "local" machine's operating system temp-dir (where Emacs is running) and sending that locally visible file location to grip?
Emacs configuration: doom-emacs
Lines 129 to 132 in 96742e4
Not sure if this is specific to doom-emacs but setting grip-url-browser
with (setq grip-url-browser "custom_browser")
in config.el
has no effect. This is because browse-url-generic-program
is initially set to grip-url-browser
but set back to nil
all within the same let
block with (ignore browse-url-generic-program)
.
Removing (ignore browse-url-generic-program)
fixes this. Am I missing something?
macOS 11.6.1, with Emacs 27.2.
When using grip-mode with markdown, everything work smooth and fine.
While using org-mode, the browser will start the preview correctly in opening. After that, each time I press C-x C-s to save the change, it will open another web page with a new random port, but the connection is failed.
The saved content could be checked by manually refreshing the page, which is created when the org file open.
I installed grip with option '--user' which caused Emacs could't find grip by itself. So I put this line into my settings following the guideline but it didn't work.
(setq grip-mode-binary-path "/home/stepinslience/.local/bin/grip")
I made a change by replacing grip-mode-binary-path
with grip-binary-path
and it works.
(setq grip-binary-path "/home/stepinslience/.local/bin/grip")
Currently grip-mode
only executes grip
on current file. This creates an issue if the page has local resource, e.g. image. Executing grip
on project root solves this problem. Could this be added togrip-mode
? Maybe the main usage of grip-mode
is to render lightweight readme file, but this could be added as an option.
Hi,
from your README it is not clear for me why your application can use GitHub API. For what? It is a markdown editor. It is totally unclear how GitHub can help here. What is the feature behind it?
Maybe you can improve your README/FAQ with that info.
Kind
Christian
ox-gfm
Hi seagle0218,
I am using centaur emacs now and I want to preview my org file.
But when I use M-x grip-mode
, the web page shows me 500
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
And I saw there was a md file generated.
I already installed python3 and grip in my system (OSX), is there any way to debug it?
And here are outputs in the message buffer
Saving file /Users/zhengshuai.peng/Workspace/notes/ProductResearch/Hologres/hologres_summary.md...
Wrote /Users/zhengshuai.peng/Workspace/notes/ProductResearch/Hologres/hologres_summary.md
Preview ‘/Users/zhengshuai.peng/Workspace/notes/ProductResearch/Hologres/hologres_summary.org’ on http://localhost:61059
mwheel-scroll: Beginning of buffer
Quit
Process ‘grip-61059’ killed
Dear @seagle0128,
thank you for your package, I am trying to use it as a Markdown live preview in the browser.
It seems to work fine, but i'd like to enable maths formulas during the preview, the formulas are not translated at all, they are left between $$...$$
or $...$
in the html.
I don't see any mathjax/katex script in the html source. I guess a first possibility is to add it inside <head>
of the html template, I guess it is in /usr/lib/python3.11/site-packages/grip/templates/
but i am not sure how to do it properly.
Do you have any idea?
Thanks !
Hi, looks like I'm getting an error caused by the latest commit (514c090):
Creating file with prefix: No such file or directory, /var/folders/gw/053czpm957z2rq6k8xqvnxx00000gn/T/QA/README.md
The problem seems to be that QA
does not exist in that directory. It should be created first.
(This could be caused by my uniquify settings, which force the buffer name to always include both the directory and the filename:
;; Use a sensible mechanism for making buffer names unique.
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward
uniquify-min-dir-content 1
uniquify-strip-common-suffix nil
)
so the name of the buffer in question is QA/README.md
. I guess another solution would be to strip the buffer name of slashes.)
I have disabled grip-mode in a org mode file initially, when I try to enable grip-mode in org file by M-x grip-mode
emacs give me a error
Grip mode disabled in current buffer
This happen even after restarting emacs.How do I enable grip-mode after I disabling.
looks like there is also an issue with ox-md
as I am getting when trying enter grip-mode from org file -
Symbol’s function definition is void: org-make-tag-string
Having a custom variable to define a web browser for previewing orgs/markdown would be nice. Back when I was using nvim I used surf for previewing markdown files(the reason why I used surf was because it had only one task that is view markdown files) .
I searched online and found that we could change default browser for emacs globally but I wouldn't like since I also use mu4e and would like to launch urls with firefox.
Now using firefox only for previewing markdown/org file is overkill.
I dont know enough elisp but this is what I have come up with by searching online
(defcustom grip-url-browser nil
"Browser to launch Markdown/Org previews."
:type 'string
:group 'grip)
(defun grip--browser (url)
"Use browser specified by user to load URL.
Use default browser if nil."
(if grip-url-browser
(let ((browse-url-generic-program grip-url-browser))
browse-url-browser-function 'browse-url-generic))
(browse-url url))
;; Then change browse-url to our custom function
(defun grip--browse-url (url)
"Ask the browser to load URL.
Use default browser unless `xwidget' is available."
(if (and grip-preview-use-webkit
(featurep 'xwidget-internal))
(progn
(xwidget-webkit-browse-url url)
(let ((buf (xwidget-buffer (xwidget-webkit-current-session))))
(when (buffer-live-p buf)
(and (eq buf (current-buffer)) (quit-window))
(pop-to-buffer buf))))
(grip--browser url)))
I dont know if this would work cause I dont have enough knowledge about elisp
Today I am use grip-mode
for markdown preview but
it's give me apply: spawing child process : exec format error
after M-x grip-mode
The grip-mode
is run well before Windows system automatically update.
I still don't why was happen.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.