Replies: 26 comments 3 replies
-
An in-terminal preview using the builtin markdown view would be a nice option, too. |
Beta Was this translation helpful? Give feedback.
-
I don't think so. I've used similar with neovim and it's terrible. It has all wrong colors and no way to view images. But I wouldn't say no to both types of previews. |
Beta Was this translation helpful? Give feedback.
-
Subjectively, this sounds more like a plugin than a core feature. |
Beta Was this translation helpful? Give feedback.
-
@felix-u Ya, a plugin would suit better. |
Beta Was this translation helpful? Give feedback.
-
This should be a plugin |
Beta Was this translation helpful? Give feedback.
-
I found this: https://pypi.org/project/markdown-server/ might be helpful |
Beta Was this translation helpful? Give feedback.
-
Markdown preview could actually (efficiently) be handled by a language server. There is already https://github.com/euclio/mdpls which does exactly that. |
Beta Was this translation helpful? Give feedback.
-
Actually installing that and adding [[language]]
name = "markdown"
language-server = { command = "/path/to/mdpls" }
config = { markdown.preview.auto = true, markdown.preview.browser = "firefox" } to your |
Beta Was this translation helpful? Give feedback.
-
@MDeiml I tried that but it looks like it does not support the |
Beta Was this translation helpful? Give feedback.
-
Not sure if latex is supported for that repo, seems like it uses https://github.com/euclio/aurelius under the hood which might support latex? I'm not sure. You could open an issue in that repo and ask the author. |
Beta Was this translation helpful? Give feedback.
-
Yep I looked into that and it should support latex. I checked and it supports all other symbols like |
Beta Was this translation helpful? Give feedback.
-
how do I open the preview? |
Beta Was this translation helpful? Give feedback.
-
@0xlilith |
Beta Was this translation helpful? Give feedback.
-
The preview should also open automatically if you open a markdown file. It works for me at least. |
Beta Was this translation helpful? Give feedback.
-
Hopefully, helix will have better markdown preview or highlight support in the future. So far, I am using vscode for markdown editing. |
Beta Was this translation helpful? Give feedback.
-
Is there a way to control the presentation theme in the Firefox preview? e.g. not white text on black background. Don't think I want to manage the css directly in the markdown files as that would impact it's presentation everywhere |
Beta Was this translation helpful? Give feedback.
-
Doesn't seem like it, but it doesn't seem to hard to implement yourself. Maybe create an issue or pull request in https://github.com/euclio/mdpls? Or you could just fork that repo and edit the template to your liking. |
Beta Was this translation helpful? Give feedback.
-
I am using |
Beta Was this translation helpful? Give feedback.
-
This is awesome, thank you very much. This, however, disables [[language]]
name = "markdown"
language-servers = ["marksman", "mdpls"]
[language-server.mdpls]
command = "/home/arcstur/.cargo/bin/mdpls"
config = { markdown.preview.auto = true } Open Preview doesn't appear in the workspace commands, but it always open a new preview when opening a markdown file. I don't know how to merge both workspace commands of the two LSPs. |
Beta Was this translation helpful? Give feedback.
-
modern browser is so weight for preview task. vimb, midori works. |
Beta Was this translation helpful? Give feedback.
-
I think that choosing a good theme makes a lot of difference. I saw that only a few themes have different colors for heading levels. Kanagawa, sonokai and papercolor have, for example. Only a few themes use colors for italic and bold, monokai being one of them. I think that using that, markdown already looks a lot better. The only theme I found that had different colors both for h1/h2 and for bold/italic is onelight. I wonder if we can modify other themes to also differentiate colors on bold/italic/h1/h2. Doing that I think will make the markdown experience much better. Markdown is made such that seeing it as code already makes it good, so I don't think we need different sizes for headings for example. The only thing I would miss is having image previews. If someone that understands the codebase could guide me into where to start developing this, I would like it very much. I know it would be a plugin and we still need a plugin system haha. |
Beta Was this translation helpful? Give feedback.
-
Looking at the code in /runtime/themes/ we can see that some themes define what I mentioned. Kanagawa using colors for heading levels: "markup.heading.marker" = "springViolet2"
"markup.heading.1" = { fg = "surimiOrange", modifiers = ["bold"] }
"markup.heading.2" = { fg = "carpYellow", modifiers = ["bold"] }
"markup.heading.3" = { fg = "waveAqua2", modifiers = ["bold"] }
"markup.heading.4" = { fg = "lightBlue", modifiers = ["bold"] }
"markup.heading.5" = { fg = "oniViolet", modifiers = ["bold"] }
"markup.heading.6" = { fg = "springViolet1", modifiers = ["bold"] } Monokai using colors for bold and italic "markup.bold" = { fg = "yellow", modifiers = ["bold"] }
"markup.italic" = { fg = "magenta", modifiers = ["italic"] } In my personal opinion, having colors for both heading levels and bold + italic make reading markdown much easier. I wonder if we also can do that for other themes, or that is defined by the theme authors and we would violate their intetions. What are the maintainer thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
I wrote a bash script that previews anything pandoc can render in the terminal itself, and detects modifications to the file to reload. My helix-config-foo isn't great so I'm not sure if this can be integrated well; I'm currently using it in a separate terminal tab/window. #!/usr/bin/env bash
set -eo pipefail
FILE="$(realpath "$1")"
TMPDIR="$(mktemp -d)"
PDF="$TMPDIR/rendered.pdf"
trap "pkill -P $$ && rm -rf \"$TMPDIR\"" exit
regen() {
inotifywait -q -e modify "$FILE" "$TMPDIR/closing.signal" > "$TMPDIR/inotify.log"
grep -q "$TMPDIR/closing.signal" "$TMPDIR/inotify.log" || {
pandoc "$FILE" -o "$PDF"
pkill -P "$$" # Kills children of these script, which can only be termpdf.py at this point
}
}
pushd "$TMPDIR" >/dev/null # termpdf.py's log file will go here and will be deleted on exit
pandoc "$FILE" -o "$PDF"
touch closing.signal
while :
do
regen &
termpdf.py "$PDF" && popd>/dev/null && echo 1 >"$TMPDIR/closing.signal" && exit 0 # If the user quits the viewer, we can exit nicely
done |
Beta Was this translation helpful? Give feedback.
-
I'm not sure how to do it, but this seems like a fairly simple solution if it could be built into Helix, may also be able to simply use it as a language server in languages.toml: https://github.com/jannis-baum/vivify
|
Beta Was this translation helpful? Give feedback.
-
... if your "favorite editor" is written in javascript. This is something that can be covered by an LSP but it does not fit into core. |
Beta Was this translation helpful? Give feedback.
-
For anyone still looking for a good solution to this, I've found that Glow works pretty well, if you don't mind a non rust program. Now I just want to figure out how to add a custom command into helix so I can launch it within the editor. Edit: Discovered Inlyne after typing this: made with rust, actively maintained, does HTML viewing, and updates live. Has less features than Glow but I think this will be my solution for now. |
Beta Was this translation helpful? Give feedback.
-
Markdown preview similar to this plugin:
https://github.com/davidgranstrom/nvim-markdown-preview
Beta Was this translation helpful? Give feedback.
All reactions