rzk-lang / vscode-rzk

Visual Studio Code Extension(s) for Rzk proof assistant.
https://marketplace.visualstudio.com/items?itemName=NikolaiKudasovfizruk.rzk-1-experimental-highlighting
Other
8 stars 1 forks source link

Enable Markdown Preview for .rzk.md files #2

Open fizruk opened 1 year ago

fizruk commented 1 year ago

There is one thing that I don't know yet how to fix: *.md files have Markdown Preview, but *.rzk.md do not anymore. Markdown Preview is useful when I insert SVG diagrams in the markdown files (e.g. see Associativity section for Segal Types). If you have ideas or you would like to submit a PR — it would be most welcome! :)

Originally posted by @fizruk in https://github.com/fizruk/vscode-rzk/issues/1#issuecomment-1565609238

fredrik-bakke commented 1 year ago

Just for input, with Markdown Preview Enhanced this works perfectly fine in my setup. But you said you already tried this without success. Perhaps something can be done with your local setup?

fizruk commented 1 year ago

Perhaps, although I'm not sure what prevents MPE from working on my machine. The only way I can make it do something is by explicitly calling it from the Palette:

Screenshot 2023-06-11 at 18 05 11

However, I do not get any features like scroll sync:

Screenshot 2023-06-11 at 18 05 56

What do you think I should check locally? I am on a macOS 13.4, VS Code 1.79.0.

fredrik-bakke commented 1 year ago

Oh. I've only used it from the command palette so far, and didn't know about the other features. However, luckily, I think I have a solution for you! By adding the following to your keybindings.json file. The shortcuts for Markdown Preview Enhanced will work for all file types with markdown in their name :)

{
    "key": "ctrl+shift+enter",
    "command": "markdown-preview-enhanced.runAllCodeChunks",
    "when": "editorLangId =~ /.*markdown.*/"
  },
  {
    "key": "shift+enter",
    "command": "markdown-preview-enhanced.runCodeChunk",
    "when": "editorLangId =~ /.*markdown.*/"
  },
  {
    "key": "ctrl+shift+s",
    "command": "markdown-preview-enhanced.syncPreview",
    "when": "editorLangId =~ /.*markdown.*/"
  },
  {
    "key": "shift+cmd+v",
    "command": "markdown-preview-enhanced.openPreview",
    "when": "editorLangId =~ /.*markdown.*/"
  },
  {
    "key": "cmd+k v",
    "command": "markdown-preview-enhanced.openPreviewToTheSide",
    "when": "editorLangId =~ /.*markdown.*/"
  },
  {
    "key": "shift+cmd+v",
    "command": "markdown.showPreview",
    "when": "!notebookEditorFocused && editorLangId =~ /.*markdown.*/"
  },
  {
    "key": "cmd+k v",
    "command": "markdown.showPreviewToSide",
    "when": "!notebookEditorFocused && editorLangId =~ /.*markdown.*/"
  }

You could ship similar key bindings with the extension if you want, but then I would advise you to only match literate rzk markdown for obvious reasons 😄

fredrik-bakke commented 1 year ago

I'm not getting sync to work either.

aabounegm commented 1 year ago

Is this resolved by #16 or is there still a missing feature?

fizruk commented 1 year ago

I think it is good enough, although it would be great to somehow have the option to have Markdown Preview Enhanced to work as well. In particular, MPE allows to sync scrolling code with Markdown and seems to work better with images, etc.

bragov4ik commented 1 year ago

I'm not sure what is the current status of this feature, but for me sync scrolling works with default markdown preview. The only small problem I encountered is that the preview can be opened only through a small button on the corner of the editor:

image

I think having a searchable option (command/shortcut) might avoid some confusion with previews. with rzk file:

image

with md file:

image image

PR that should fix it: https://github.com/rzk-lang/vscode-rzk/pull/37

I got error trying to run it locally, so hopefully someone with environment ready can check if it works 🥺

aabounegm commented 1 year ago

For what it's worth, scroll sync is working for me with Markdown Preview Enhanced as well. Sadly, I cannot find any resource for having a language (such as literate rzk markdown) inherit another language (markdown in this case) entirely, including its commands and configuration. Only the syntax highlighting as we currently have.

bragov4ik commented 1 year ago

I'm not sure what is the current status of this feature, but for me sync scrolling works with default markdown preview.

btw sometimes it stops working when file type is literate rzk.... fixable by swtiching it to just markdown file