All Projects → xyc → Vscode Mdx Preview

xyc / Vscode Mdx Preview

Licence: gpl-3.0
MDX Preview for Visual Studio Code

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vscode Mdx Preview

Marp Vscode
Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
Stars: ✭ 442 (+329.13%)
Mutual labels:  markdown, vscode, vscode-extension
Flutter preview
Flutter | Because a widget-driven development requires a widget-driven preview.
Stars: ✭ 197 (+91.26%)
Mutual labels:  vscode, vscode-extension, preview
Vscode Markdown Pdf
Markdown converter for Visual Studio Code
Stars: ✭ 571 (+454.37%)
Mutual labels:  markdown, vscode, vscode-extension
Vscode Stylelint
A Visual Studio Code extension to lint CSS/SCSS/Less with stylelint
Stars: ✭ 260 (+152.43%)
Mutual labels:  markdown, vscode, vscode-extension
Vscode Mdx
MDX for Visual Studio Code
Stars: ✭ 91 (-11.65%)
Mutual labels:  mdx, vscode, vscode-extension
Gistpad
VS Code extension for managing and sharing code snippets, notes and interactive samples using GitHub Gists
Stars: ✭ 443 (+330.1%)
Mutual labels:  markdown, vscode, vscode-extension
Vscode Yuml
yUML extension for Visual Studio Code
Stars: ✭ 102 (-0.97%)
Mutual labels:  markdown, vscode, vscode-extension
Vscode Cssrem
Converts between `px` and `rem` units in VSCode
Stars: ✭ 81 (-21.36%)
Mutual labels:  vscode, vscode-extension
Vim
⭐ Vim for Visual Studio Code
Stars: ✭ 9,782 (+9397.09%)
Mutual labels:  vscode, vscode-extension
Foam
A personal knowledge management and sharing system for VSCode
Stars: ✭ 10,993 (+10572.82%)
Mutual labels:  markdown, vscode
Syntax Highlighter
Syntax Highlighter extension for Visual Studio Code (VSCode). Based on Tree-sitter.
Stars: ✭ 88 (-14.56%)
Mutual labels:  vscode, vscode-extension
Laravel Blade Snippets Vscode
Laravel blade snippets and syntax highlight support for Visual Studio Code
Stars: ✭ 80 (-22.33%)
Mutual labels:  vscode, vscode-extension
Vscode Standard
VS Code extension for JavaScript Standard Style (`standard`) with automatic fixing
Stars: ✭ 78 (-24.27%)
Mutual labels:  vscode, vscode-extension
Php Namespace Resolver
PHP Namespace Resolver - VSCode Extension
Stars: ✭ 83 (-19.42%)
Mutual labels:  vscode, vscode-extension
Glassit Vsc
VS Code Extension to set window to transparent on Windows platform.
Stars: ✭ 77 (-25.24%)
Mutual labels:  vscode, vscode-extension
Nextra
The Next.js Static Site Generator
Stars: ✭ 1,271 (+1133.98%)
Mutual labels:  markdown, mdx
Vscode Glean
The extension provides refactoring tools for your React codebase
Stars: ✭ 1,194 (+1059.22%)
Mutual labels:  vscode, vscode-extension
Css Flexbox Cheatsheet
VS Code extension that lets you open a CSS Flexbox cheatsheet directly in the editor.
Stars: ✭ 87 (-15.53%)
Mutual labels:  vscode, vscode-extension
Vscode Rss
An RSS reader embedded in Visual Studio Code
Stars: ✭ 102 (-0.97%)
Mutual labels:  vscode, vscode-extension
Vscode Code Runner
Code Runner for Visual Studio Code
Stars: ✭ 1,332 (+1193.2%)
Mutual labels:  vscode, vscode-extension

MDX Preview for Visual Studio Code

New in v0.2: Type Script Preview and Hot Update https://vimeo.com/334605913

MDX Preview lets you preview MDX seamlessly. Write markdown / JSX, see it live refresh and get instant visual feedback.

Features

Instant preview as you type without starting a dev server or building

To get started:

  1. Run yarn install or npm install if necessary so that you have the npm dependencies in your workspace, and navigate to your md or mdx file; or just create an untitled file, change language mode (from command palette) to mdx and type some mdx code.
  2. Open command palette, and type "MDX: Open Preview"; or click the magnifying glass.

Preview will automatically update when you change the file you are previewing or the files that currently previewed file depends on.

MDX Extension is recommended for syntax highlighting of MDX files.

Custom Layout

You can apply custom layout to the MDX file by

  1. Exporting a default layout value using export default
import Layout from '../components/Layout';

export default Layout

## Hello
  1. Specifying a path to a custom layout config file in mdx-preview.preview.mdx.customLayoutFilePath extension setting. For example, the absolute path to the ../components/Layout file above.

  2. When nothing is specified, by default it will apply VS Code Markdown styles. You can turn that off by mdx-preview.preview.useVscodeMarkdownStyles extension settings or "MDX: Toggle VSCode Markdown Styles" command.

MDX transclusion

You can import other files with .md or .mdx extension.

import AnotherMDX from './AnotherMDX.mdx'

<AnotherMDX></AnotherMDX>

JavaScript/TypeScript Preview

If you have a JavaScript or TypeScript file that renders to the #root element, you can also preview that using MDX Preview. For example, you can preview the index.js file from your react app:

// index.js
import ReactDOM from 'react';
import App from './App';
ReactDOM.render(
  <App />,
  document.getElementById('root')
);

Note that VS Code webview has some limitations:

  • Service worker / Local storage are not available.
  • Use MemoryRouter if you are using React Router.

Security

Code will only be evaluated inside VS Code extension webview's isolated iframe. The MDX files can only require dependencies within your active workspace folders. By default, only HTTPS content is allowed within the webview. Of course, you still need to make sure you trust the MDX file you preview, AND trust the files inside your workspace. Note that with the default Content Security Policy, you would not be able to preview a LiveEditor. You can change your security settings through mdx-preview.preview.security extension setting or "MDX: Change Security Settings" command.

Extension Settings

This extension contributes the following settings:

  • mdx-preview.preview.previewOnChange: If set to true, previews on file change; If set to false, previews on file save
  • mdx-preview.preview.security: Security policy settings
  • mdx-preview.preview.useVscodeMarkdownStyles: Use VS Code Markdown Styles for layout.
  • mdx-preview.preview.useWhiteBackground: Use white background regardless of current theme settings.
  • mdx-preview.preview.mdx.customLayoutFilePath: Path of custom layout file to use
  • mdx-preview.build.useSucraseTranspiler: Use sucrase as transpiler (A faster alternative to babel) instead of Babel/TypeScript transpiler

FAQ

How it works

MDX Preview transpiles your .mdx file using @mdx-js/mdx, sends the initial file to the webview, and recursively fetches local dependencies (from your workspace) and npm dependencies (from node_modules directory) from your workspace using polestar, a commonjs-ish module loader for browsers. MDX Preview has provided built-in dependencies for MDX rendering like react, react-dom and @mdx-js/tag.

Some components doesn't work?

In most cases runtime errors will surface in react-error-overlay. If it doesn't, you can open "Developer: Open Webview Developer Tools" (from command palette) to inspect the error. Note that VS Code webview has some inherent limitations that might cause errors. For example, components that use local storage but without a try/catch block.

Build issues? Try checking mdx-preview.build.useSucraseTranspiler extension setting. It might solve it.

Road map

  • [x] TypeScript support
  • [ ] Scroll Sync
  • [ ] remark/rehype plugins
  • [ ] Integrations with gatsby / x0 /...

Acknowledgements

This extension is not possible without the help from James and the open source polestar library.

Saying thanks to these awesome open source projects as well:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].