Blog 1

Random Talk on Random Thoughts

A Quick Markdown Syntax Error Detection for Writing MathJax Equations in Octopress Posts (5)

| Comments |

Background

In the previous post in this series, I included three Vim editor commands.

Problem

As I’ve already typed hundreds of lines of source code, I feel tired and I often make mistakes while typing those commands despite these two command mode mappings in my ~/.vimrc.

More efficient recall from Vim command historyGist
1
2
3
" Practical Vim Tip 34: Avoid cursors when rcl'g cmd from hist
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>

Solution

Convert these three commands into a shell script. Since I’m using FuzzyFinder, I assume that the current working directory (as shown by :pwd) is the root of the local repository for the [Octopress] blog.

Script for Octopress editing within Vim (quik-prv.sh) download
1
2
3
#!/bin/sh
sed '1,8d' $1 | kramdown > temp.html~
cat {temp,script}.html~ > tempmj.html~
  1. The YAML header is chopped off since I just want to verify the [kramdown] syntax.
  2. I appended ~ after the file extension names .html since I had added *~ in my .gitignore and I didn’t want these files (including this shell script) to be tracked by Git.
  3. I created a symbolic link on Windows 10 with mklink in cmd. (ran as admin) Other options are more complicated: - Graphical programs: more disk space is consumed for programs rarely used which have command line alternatives. - Windows Power Shell: this method won’t work for Home edition. (That’s my case.) I’m quite satisfied by the current edition and I don’t see any reason to spend a thousand dollar and a whole day to have it changed to Pro version for functionalities that are too advanced for me.

Lessons learnt

While I was writing this post, I used

grep -e "\[kramdown\]" %:h/*.markdown

in the current buffer in order to quickly retrieve the links to websites to which I had previously referred. To escape the square brackets and the search pattern, the flag -e is added in between the utility name and the pattern string. I tried using marks, but I had forgotten the difference between a mark named with a small letter and a capital letter.

Mark Range
small local
capital global

Comments