Plasticboy Markdown
Researchers have long issued warnings about the consequences of our livestock-dominated food system. After the Sars outbreak in 2003, an essay in the American Journal of Public Health lamented that “changing the way humans treat animals – most basically, ceasing to eat them or, at the very least, radically limiting the quantity of them that are eaten – is largely off the radar as a. If you are using plasticboy/vim-markdown plugin, put in your.vimrc: let g:vimmarkdownconceal = 0 let g:vimmarkdownconcealcodeblocks = 0 Share. Improve this answer. Ben Williams' blog about technology, Linux, digital music, veganism, and a little politics. Markdown Vim Mode; The Guardian The 14 things you. ' Language: Markdown '-au FileType markdown setlocal spell: au FileType markdown set expandtab: au FileType markdown set shiftwidth = 4: au FileType markdown set softtabstop = 4: au FileType markdown set tabstop = 4: au FileType markdown set syntax = markdown '-' Language: Protobuf '.
Markdown: One Format to Rule Them All
Create attractive and structured documents from the comfort of your text editor – and convert them to a huge array of formats.
It should come as no surprise that we Linux Voicers are big fans of open standards. For complicated documents or spreadsheets, Open Document Format (ODF, as used by LibreOffice) is the way to go. But, it's also a rather complicated beast, and for shorter or simpler texts that you may want to process using other tools, it's arguably overkill. So, what other options do you have for text-heavy content?
Well, there's HTML – which is somewhat standardized but gets a bit fiddly to write with all the tags. If you're working on a scientific paper, then LaTeX is a great choice, but it has a pretty steep learning curve. And, of course, there's always plain ASCII text, but that has its limitations as well – namely, there's no way to add formatting.
Wouldn't it be great if you could add some symbols and other bits to plain text, so that it's perfectly readable in an editor like Vim, Emacs, or Nano, but could also be processed to add formatting? Enter Markdown [1]. The name is a play on markup, as in a 'markup language' like HTML, but Markdown is very different. It was originally created in 2004, and today there are various implementations and supersets (with no official standard).
Regardless of the implementation, the core features of Markdown are the same – and it's used in many places, including GitHub (look for files with .md
extensions). With Markdown, you can create structured plain text files in any editor and process them to prettier HTML (or other formats) when necessary. In that sense, it's the perfect middle ground between raw ASCII text and word processor formats. In this article, we'll show how to write, edit, and process Markdown docs, all from the comfort of your favorite text editor. (See the 'Dedicated Markdown Editors' box for more information.)
Although any plain text editor can be used for Markdown, some custom editors are worth checking out as well. Remarkable [2] is a polished editor that lets you edit syntax-highlighted Markdown text in a pane on the left-hand side, while on the right, you can see a constantly updating preview of the HTML equivalent. Then there's Dillinger [3], which you can test immediately in your browser, along with StackEdit [4], which does a similar job.
If you use Vim, you can get some Markdown integration via PlasticBoy's Markdown Vim Mode [5], whereas Emacs fans have their own package thanks to Jason Blevins [6].
Getting Started
The first thing you'll need to do is install Markdown itself, which converts plain text files into prettier HTML. Search for it in your distro's package manager (most distros have it available). If you're on an Ubuntu-based distro, you can install it from the command line like so:
If you can't find it anywhere in your distro, you can get it from the project's website [1]. Extract the .zip file, cd
into the resulting directory, and use ./Markdown.pl
in place of 'markdown' for the rest of the commands in this tutorial.
Now, let's try some Markdown! Using your favorite text editor, create a file called test.md
with the following content:
Just by looking at that, can you guess what the formatting is? The underscores surrounding 'first' suggest underlining, right? The double asterisks around 'Markdown' look like they're trying to make the word stand out, yes? If you follow some plain-text mailing lists, you may have seen people using these pseudo-formatting options before – especially on the Linux kernel mailing list, where Linus Torvalds uses them a lot.
Anyway, let's convert this plain text into HTML. At the command line:
This simply uses the Markdown tool to process the contents of our test.md file and redirect the output to a test.html
file. Now open that HTML file in a web browser, and voilà – you'll see the results, like in Figure 1, which also shows the HTML source that is generated.
Now, you'll notice right away that the HTML formatting is slightly different to what you may have expected from the Markdown version. Specifically, the underscores haven't made the word 'first' underlined, but rather in italics. This is because Markdown converts the underscores to <em>
tags – for emphasis – which the browser then chooses to interpret as italics.
So, you already know how to create italics and bold with plain text. But what about combining them together? Try this:
Run the previous command to generate the HTML, and view it again in your browser – this time 'word' is in both bold and italics. It's possible to use Markdown formatting across multiple words, like so:
When you look at the HTML version of this, you'll notice that both sentences have been combined into the same line. Markdown is very strict about paragraph formatting; to make it clear that you want the lines to be in separate paragraphs, put a blank line between them:
If you look at the HTML version of this, you'll see that each line is surrounded by its own <p>
tags now.
Heads Up
Now that we have some basic formatting sorted out, let's turn to structure. In Markdown, you can create headings of different sizes by prefixing words with hash marks (#
). Try this, for example:
Plasticboy/vim-markdown 设定
Note that you don't strictly need the space between the hash mark and the content, but when you're writing Markdown content, always bear in mind usability. Even if your ultimate goal is to make an HTML version of your document, the whole point of Markdown is that it should still be easy to read in plain text.
For smaller headings, add more hash marks. There are six heading sizes in total.
Plasticboy/vim-markdown 設定
Convert this to HTML, and you'll see the results like in Figure 2. Always keep in mind that the headings aren't just used for presentation purposes; they add structure to a document as well. As I'll show later in the tutorial, you can convert Markdown documents into many other formats, where structure is often especially important.
Creating bulleted lists is easy – just prefix the items with asterisk (*) marks like so:
What about numbered lists? These are simple too:
Note that you can put lists inside other lists; to do this, adjust the indentation by adding an extra space for the sublist. Here's an example:
For yet another level of indentation, use two spaces at the start instead of one. You can, of course, use the other formatting options we've covered beforehand, like bold and italic.
If you're writing a document and want to quote something from another source (or just make a particular paragraph really stand out, you can use block quotes. These are marked by greater-than (>) signs and work like this:
Note how the line beginning with 'This is also' is included in the block quote – because it follows immediately after the line beginning with >. An empty line is required to end the block quote and return to the normal paragraph style.
If you're citing something in a block quote, then you may want to provide a link to the website as well. These look a bit tricky in Markdown, but with a bit of practice you'll soon get used to them. Links are made of two parts, like in a regular HTML document: the text that's displayed for the link and the actual address to which it points.
Say we want to create a link with the text 'Linux Magazine' that points to the website at http://www.linux-magazine.com. We put the text inside square brackets, and the address inside round brackets:
This might look a bit ugly as raw text, but it gets the job done and when you generate an HTML version, you just see the link text (so just Linux Magazine, which will be clickable).
Suppose you're writing a long document that contains multiple links to a specific web page. Later, you need to change all of those links to point to something else. You could do a find-and-replace job in your editor for this purpose, but Markdown offers a more elegant solution in the form of reference links. These let you define a link at the end of the document, with a name, and then you can reference that name throughout the text. Here's an example:
In this document, both 'the LM website' and 'Visit our website' links point to the same place, as defined by the 'our-site' reference at the end. So, if we wanted to change that link to something else, we only have to edit one line and not go through the entire document. Pretty handy, right? Note that the reference link itself doesn't appear in the actual HTML that's generated.
A Picture's Worth a Thousand Words
What about images? Obviously, these are not easy to integrate into plain-text documents (unless you want to do very funky things with ASCII art), so Markdown's solution involves an exclamation point (!), alt text, and the address of the image, like so:
Here, the alt text is provided in square brackets – this is the tooltip text that appears in the HTML version, when you hover over the image. Using alt text on the web is good practice, as it provides extra information for search engines and visually impaired users. It's good to have useful text in Markdown as well, keeping in mind that the plain-text version should be just as useful (or close enough) as the HTML equivalent.
We then have the address of the image in rounded brackets, and the results can be seen in Figure 3.
If you want to include code in your documents and have it rendered in a monospace font in the HTML version, you can surround the code with three back tick (`
) characters like so:
As your documents get longer, it's a good idea to break them up using horizontal lines. To add these in Markdown, and get <hr>
tags in the resulting HTML, use three or more dashes:
Three dashes suffice, but I like to use more so that they're wider in the Markdown text and emphasize that they're splitting up the document.
Finally, in some circumstances, you may want to use Markdown symbols on their own, without Markdown poking its nose in and trying to convert them into something else. To do this, use backslashes before the symbol – for instance, here's how to generate the word awesome, including the asterisks, without Markdown making it bold in the HTML version:
You'll probably never need this feature, but it's worth bearing in mind, especially if you ever end up writing a Markdown document about… writing Markdown documents!
12Next »
Buy Linux Magazine
UK / Australia
Related content
- UberWriter
The UberWriter text editor, which is optimized for Markdown, includes a number of interesting features and does some amazing things. We show you how it works.
- Qute: A Sleek, No-Frills Text Editor
- Workspace: Markdown Tools
From note-taking applications to wikis – there are plenty of handy tools for working with Markdown-formatted content. Here are a few worth adding to your toolbox.
- Dillinger: Markdown Editor Done Right
- Classeur: A Classy Markdown Editor
As a Neovim user who has been using Sublime Text for code editing for sometime, I miss the experience I get when dealing with Markdown files with thehelp plugins such as MarkdownEditing and MarkdownPreview. In thispost, I would like to share my settings for Markdown editing inside Neovim toget similar experience, even better!
When we are editing Markdown files, it is nice to have some code snippets toimprove efficiency. Fortunately,UltiSnips combined with vim-snippets1 provides a lot ofuseful snippets for Markdown files.
The two plugins can be install by vim-plug:
We need to set up UltiSnips to use it. The following is an example setting:
In the above setting, we use Tab to trigger snippet expansion,which means that after entering the snippet keyword for a particular snippet,using <Tab>
will expand the keyword to the full snippet template. If you have used Tab for othermappings, you can set other snippet trigger, e.g., Ctrl + J:
For example, if we type link
and then press <Tab>
, it will be expanded tothe following text:
Your cursor will be placed at Text
, with Text
being in selection mode andwaiting for you to enter the real link text. The settingUltiSnipsJumpForwardTrigger
and UltiSnipsJumpBackTrigger
set up theshortcut key to go to next and previous text area of a snippet, making thesnippet editing more convenient. Take the above inline link snippet for anexample. Suppose we want to add an inline link to Neovim official website (theaddress is https://neovim.io/), we can follow the steps below:
- Enter
link
and press<Tab>
to get the link template. - Start typing
Neovim
andText
will be replaced byNeovim
. - Press
<Ctrl-F>
.www.url.com
will be selected. - Start typing
https://neovim.io/
.
There are many more snippets you can use. Some of the commonly used snippetkeywords are listed below:
- Header:
- Level 1:
sec
- Level 2:
ssec
- Level 3:
sssec
- Level 4:
par
- Level 5:
spar
- Level 1:
- Links:
- Inline link:
link
- Reference link:
refl
- Image link:
img
- Inline link:
- Code:
- Code block:
cbl
- Inline code:
ilc
- Code block:
- Text rendering:
- Italic text:
*
- Bold text:
**
- Italic and bold text:
***
- Italic text:
- General:
- date:
date
- time:
time
- date and exact time:
datetime
- date in ISO format:
diso
- date:
Often times, you will find you want to more snippets to cover your use cases.For example, I have set up a snippet meta
which can generate the Markdownfront matter fore me, see herefor more details.
For how to set up Ultisnips and writing your own snippets, see thispost.
Distraction-free writing
When we are writing Markdown files, we may wish to focus on the task andtemporarily disable the distraction elements in Neovim. The plugingoyo is designed specifically for thispurpose. We can install it via vim-plug:
After installing this plugin, we can use Goyo
command to toggle between thenormal mode and distraction-free mode.
The author also suggests installinglimelight, which will dim alllines except the current line when turned on.
First, install it with vim-plug:
After install, we can use Limelight
to activate it. To deactivate, useLimelight!
.
We can also integrate goyo and limelight together with the following setting:
when you turn on/off goyo, limelight will also be turn on/off.
Code highlighting is also important, which helps us to see the structure of thesource code more clearly. The first plugin we should install isvim-markdown. We can install itvia vim-plug:
Vim-markdown provides a lot of functionalities such as folding,conceal etc. Here,we mainly use its syntax highlighting feature. Below are some settings forvim-markdown:
This plugin also provides a few shortcuts and commands:
- Shortcut:
]]
: go to next header[[
: go to previous header
- Command:
Toc
: create a vertical window of table of contentsTableFormat
: format the table under current cursor
For more settings about these plugins, please consult their documentations.
Another good Markdown syntax plugin I recommend isvim-pandoc-syntax. Itprovides more syntax highlight and better conceal features. First, install itvia vim-plug:
It is designed to work withvim-pandoc. To use it as astandalone plugin, we should add the following settings in our Neovimconfiguration file:
After all this settings, your Markdown file will be like what is shown in thefollowing image:
Plasticboy Markdown
There are several Markdown previewer for Neovim on GitHub. I have triedprevim andmarkdown-preview.nvim, bothof which have cross-platform support for Nvim (Windows, Linux and macOS aresupported). After some trail, I think markdown-preview is superior in terms ofspeed, functionality provided and rendering result. It is easy to install withvim-plug:
Here is my setting for this plugin:
To start previewing a markdown file, use MarkdowPreview
command. Your defaultbrowser will be opened automatically. You can also add a custom key mapping forthis command:
For other custom settings, see itsdocumentation.
In this post, I introduced the plugins and settings I use for Markdown editing,syntax highlighting and previewing. The end result is the smooth writingexperience I get.
Plasticboy/vim-markdown 使い方
UltiSnips is the snippet engine, while vim-snippets provides the actual snippet. ↩︎