In v3, this repo is maintained as a npm package (What is npm?). It mainly utilizes Node API fs
to read/write files, and easy-to-use template engine Handlebars.js (Enhanced version of Mustache.js).
This document focuses on the build workflow. In addition, you will understand more about the configs available for this package.
-
Make sure Notepad++, Git and Node.js are available in your machine. Open command prompt (
cmd.exe
) on Windows, then run:git --version node -v
If it cannot return version numbers, install the missing package:
- Node.js Windows Installer (.msi). Recommend 64-bit latest LTS version.
- Git for Windows.
- If you want a GUI application for Git, I recommend Fork Git client.
-
Fork this repo:
-
Clone and install markdown-plus-plus:
:: Go to your development directory, example: cd %UserProfile%\dev :: Clone to your local machine :: Replace my username with yours git clone https://github.com/Edditoria/markdown-plus-plus.git :: Install dependencies in your project directory cd markdown-plus-plus npm install
You only need to run the above commands once.
In simple words, the <build\build.js>
does the following things:
- Reads the config files in
<config\>
folder, - use Handlebars.js library to render
<build\template.hbs.xml>
file, then - writes UDL files in
<udl\>
folder.
Importantly, naming conversion follows the below rules:
- Config files are named
<markdown.[theme-name].config.json>
. - UDL (output) files are named
<markdown.[theme-name].udl.xml>
. They are generated automatically. - For theme name, I recommend naming it in lower-case English or number characters, and separating the words by hyphen. Optionally, you also can add more information for your needs, for example,
<markdown.magic-theme_by-your-name_v3.1.config.json>
.
In most situations, you only need to edit the config files in <config\>
. You don't need to dig deep in build scripts, unless you want to change the build process, or fix things.
To change highlighting behaviors, you need to edit the config files.
Open <*.config.json>
file(s) in <config\>
folder using Notepad++. As you see, the context in the file has to be valid json data.
Option | Descriptions |
---|---|
themeName |
The theme name that will be displayed in Notepad++ menu under "Language". |
gfm.table |
HTML table in GitHub Flavored Markdown. This is what you see in this table. |
goodies.highlightHex |
Highlight HEX value. It is not a Markdown syntax but eye candy. |
goodies.extraProtocols |
A string to list extra protocols seperating by comma. |
flags.transparentBg |
By default, each text has background color set in default.bgColor . You can take out the background color by switching this option to true . However, some text or style may not display clearly on your screen. |
flags.asteriskUnorderedList |
By default, you cannot use asterisk-style bullet points (* a \<li\> bullet point ). By switching this option to true , you can write in this markdown style. However, there will be a side effect: *multiple em words* will only parse the first word because it will screw up unordered list in some situations. |
(Others) | All of them are standard markdown syntax suggested by Daring Fireball. |
Run the build script when you want some outputs:
:: Build UDLs in <udl\>
npm run build
Remember to include the word "run"! npm build
is totally different thing in npm.
Now, the UDL files are ready for you to import to Notepad++. Congratulation! 🎉 🎉
:: Copy file(s) to serve Notepad++ (May vary to your system environment)
set npp_udl=%AppData%\Notepad++\userDefineLangs
dir udl /w
copy udl\markdown.zenburn.udl.xml %npp_udl%
:: See the difference of a file, e.g. an output file after build
git diff udl\markdown.zenburn.udl.xml
:: Discard all changes to latest commit
git checkout -- .
:: Make sure you are pushing/pulling the correct remote
git remote -v
Experience and enjoy. Happy coding! 🍕