|
| 1 | +--- |
| 2 | +stackbit_url_path: posts/mdeditor-for-vscode-16nn |
| 3 | +title: mdEditor (for VSCode) |
| 4 | +date: '2021-06-28T16:12:41.414Z' |
| 5 | +excerpt: >- |
| 6 | + Table of Contents Overview Features Prerequisites Installation Usage |
| 7 | + Credits ... |
| 8 | +thumb_img_path: >- |
| 9 | + https://res.cloudinary.com/practicaldev/image/fetch/s--4OnHOVW_--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/guqx0sw882p4q2bxyiq5.png |
| 10 | +comments_count: 0 |
| 11 | +positive_reactions_count: 2 |
| 12 | +tags: |
| 13 | + - markdown |
| 14 | + - news |
| 15 | + - opensource |
| 16 | + - showdev |
| 17 | +canonical_url: 'https://dev.to/killshot13/mdeditor-for-vscode-16nn' |
| 18 | +template: post |
| 19 | +--- |
| 20 | +## Table of Contents |
| 21 | + |
| 22 | +- [Overview](# overview) |
| 23 | +- [Features](# features) |
| 24 | +- [Prerequisites](# prerequisites) |
| 25 | +- [Installation](# installation) |
| 26 | +- [Usage](# usage) |
| 27 | +- [Credits](# references) |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Overview (TL;DR) <a name = "overview"></a> |
| 32 | + |
| 33 | +In a nutshell, mdEditor is a VS Code Workspace that can be installed from GitHub. It creates a sort of self-contained Markdown environment on your local machine. |
| 34 | + |
| 35 | +mdEditor provides the configuration guidelines and creates the structure for an awesome VSCode Markdown editor. By creating a reusable Code-Workspace, the main portion of your IDE environment is protected from rule conflicts. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Features <a name = "features"></a> |
| 40 | + |
| 41 | +1. The Code-Workspace, once opened with VS Code, loads everything you need for importing, exporting, linting, custom rulesets, automatic styling, and file conversion --> PDF, DOCX, and HTML. |
| 42 | + |
| 43 | +2. The syntax rules allow for the enforcement of any markdown flavor with a simple on/off option for each rule. |
| 44 | + |
| 45 | +3. The linter looks for errors/problems and immediately flags them. A detailed explanation and reference link will appear on hover. |
| 46 | + |
| 47 | +4. The auto-fix feature is enabled by default to run each time a file is saved. This formats your Markdown using the enabled rules, which corrects most errors automatically with no manual edits needed. |
| 48 | + |
| 49 | +5. The file conversion tool uses an extension to integrate Pandoc with VS Code. With a simple key-binding ( |
| 50 | +`CTRL + K` |
| 51 | +, |
| 52 | +`P` |
| 53 | +), you can create |
| 54 | +`.pdf` |
| 55 | +, |
| 56 | +`.docx` |
| 57 | +, and |
| 58 | +`.html` |
| 59 | + files from Markdown, after which the new files can be viewed immediately and/or exported elsewhere. |
| 60 | + |
| 61 | +6. The default stylesheet is applied during file conversion, ensuring uniformity and consistency in the output. You can apply custom styles using CSS to achieve the desired appearance of the converted files. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## Prerequisites <a name = "prerequisites"></a> |
| 66 | + |
| 67 | +**[Visual Studio Code](https://code.visualstudio.com/Download)** |
| 68 | +This should be self-explanatory. |
| 69 | + |
| 70 | +**[Pandoc](http://pandoc.org/installing.html)** |
| 71 | +This may require some guidance if you don't currently use Pandoc. I wrote a gist to help first-time users; here is [the link](https://gist.github.com/killshot13/5b379355d275e79a5cb1f03c841c7d53). |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +### Installation <a name = "installation"></a> |
| 76 | + |
| 77 | +mdEditor can be installed using the simple guide you are reading now, which paraphrases the README.md file from the [main repository](https://github.com/killshot13/mdEditor). |
| 78 | + |
| 79 | + |
| 80 | +<iframe class="liquidTag" src="https://dev.to/embed/github?args=killshot13%2FmdEditor%20no-readme" style="border: 0; width: 100%;"></iframe> |
| 81 | + |
| 82 | + |
| 83 | +Decide where the root directory of the editor is going to live on your local drive (reference [Overview](# overview) for details), then clone [mdEditor](https://github.com/killshot13/mdEditor.git) to that location. |
| 84 | + |
| 85 | +Now, open mdEditor at the base directory using VSCode. Your IDE will auto-discover the |
| 86 | +`.code-workspace` |
| 87 | + file and prompt you to reopen the folder as a workspace. |
| 88 | + |
| 89 | +Confirm this choice, unless you want a different configuration. If so, there is a blank |
| 90 | +`settings.json` |
| 91 | + in the |
| 92 | +`.vscode` |
| 93 | + folder for you. Otherwise, just delete that file to avoid confusion. |
| 94 | + |
| 95 | +Once open, you should receive another prompt to install the recommended VS Code extensions. Once again, choose confirm to install, and leave the default settings in place. |
| 96 | + |
| 97 | +The extensions will power the linting rules and Pandoc style guide within the workspace. Here are the links in case you encounter any issues. |
| 98 | + |
| 99 | +--> [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) |
| 100 | +--> [vscode-pandoc](https://marketplace.visualstudio.com/items?itemName=DougFinke.vscode-pandoc) |
| 101 | + |
| 102 | +Now, using this diagram, verify the file structure of your local installation of mdEditor is a rough match. |
| 103 | + |
| 104 | +**Tree View** |
| 105 | +_mdEditor_ |
| 106 | +\+---.vscode |
| 107 | + | |
| 108 | +`settings.json` |
| 109 | + |
| 110 | + | |
| 111 | + +---md |
| 112 | + | |
| 113 | +`project1.md` |
| 114 | + |
| 115 | + | |
| 116 | +`project2.md` |
| 117 | + |
| 118 | + | |
| 119 | + +---styles |
| 120 | + | |
| 121 | +`style.css` |
| 122 | + |
| 123 | + | |
| 124 | +`syntax.md` |
| 125 | + |
| 126 | + | |
| 127 | + | |
| 128 | +`.markdownlint.json` |
| 129 | + |
| 130 | + | |
| 131 | +`mdEditor.code-workspace` |
| 132 | + |
| 133 | + | |
| 134 | +`README.md` |
| 135 | + |
| 136 | + | |
| 137 | +`LICENSE` |
| 138 | + |
| 139 | + \--- |
| 140 | + |
| 141 | +**NOTE: On Linux you must uncomment the |
| 142 | +`pandoc.htmlOptString` |
| 143 | + in the |
| 144 | +`mdEditor.code-workspace` |
| 145 | + file. The current version, which uses Windows OS file separators, must be replaced with the Linux version; otherwise, the css styles will not be applied correctly.** |
| 146 | + |
| 147 | +Installation is complete. |
| 148 | +Nice job! |
| 149 | + |
| 150 | +--- |
| 151 | + |
| 152 | +## Usage <a name = "usage"></a> |
| 153 | + |
| 154 | +To test linting & formatting, click the |
| 155 | +`test.txt` |
| 156 | + file (in the |
| 157 | +`md` |
| 158 | + folder); it should open in the main editor window. |
| 159 | + |
| 160 | +In the sidebar, keeping the |
| 161 | +`test.txt` |
| 162 | + tab in focus, change the filetype from |
| 163 | +`txt` |
| 164 | + to |
| 165 | +`md` |
| 166 | + and save. |
| 167 | + |
| 168 | +Check the output in the PROBLEMS tab of your lower (terminal) panel. Several formatting violations should appear. Now make a tiny edit and save again. Most of the errors should be gone, having been corrected automatically. |
| 169 | + |
| 170 | +To test the filetype output, enter the key combination |
| 171 | +`CTRL + K` |
| 172 | +, then press |
| 173 | +`P` |
| 174 | +. Options to create |
| 175 | +`.pdf` |
| 176 | +, |
| 177 | +`.docx` |
| 178 | +, or |
| 179 | +`.html` |
| 180 | + file should appear in the dropdown. Click each option in turn and confirm the desired result was produced. |
| 181 | + |
| 182 | +Workspace setup is now complete and mdEditor is ready to use. |
| 183 | + |
| 184 | +>NOTE: The |
| 185 | +`syntax.md` |
| 186 | + file in the |
| 187 | +`styles` |
| 188 | + folder contains a detailed description of the linting rules available within the editor workspace. Any rule can be toggled on/off by editing the |
| 189 | +`.markdownlint.json` |
| 190 | + file using this syntax. |
| 191 | +`"ruleID" : bool` |
| 192 | + |
| 193 | + |
| 194 | +Happy markdown'ing! :) |
| 195 | + |
| 196 | +Don't forget to 💖 this article and leave a 💭. If you're feeling extra generous, please click my name below to 🎆subscribe🎇! |
| 197 | + |
| 198 | + -- killshot13 |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | + |
| 203 | +<iframe class="liquidTag" src="https://dev.to/embed/user?args=killshot13" style="border: 0; width: 100%;"></iframe> |
| 204 | + |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## Credits <a name = "references"></a> |
| 209 | + |
| 210 | +_Extensive credit is owed to [Dave](https://twitter.com/thisDaveJ) for indirectly inspiring me to create mdEditor after reading [this guide](https://thisdavej.com/build-an-amazing-markdown-editor-using-visual-studio-code-and-pandoc/) he authored._ |
| 211 | + |
| 212 | +[mdEditor](https://github.com/killshot13/mdEditor) is free software released under the [MIT license](https://github.com/killshot13/mdEditor/blob/main/LICENSE). Copyright 2020-2021 Michael Rehnert |
| 213 | + |
| 214 | +All software programs, extensions, plugins, and digital content referenced and/or used in the documentation and/or installation guide of mdEditor is the respective intellectual property of the creators, developers, and owners thereof and is entitled to the protections granted under U.S. Copyright law. |
| 215 | + |
| 216 | +*[This post is also available on DEV.](https://dev.to/killshot13/mdeditor-for-vscode-16nn)* |
| 217 | + |
| 218 | + |
| 219 | +<script> |
| 220 | +const parent = document.getElementsByTagName('head')[0]; |
| 221 | +const script = document.createElement('script'); |
| 222 | +script.type = 'text/javascript'; |
| 223 | +script.src = 'https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.1.1/iframeResizer.min.js'; |
| 224 | +script.charset = 'utf-8'; |
| 225 | +script.onload = function() { |
| 226 | + window.iFrameResize({}, '.liquidTag'); |
| 227 | +}; |
| 228 | +parent.appendChild(script); |
| 229 | +</script> |
0 commit comments