I’m recently enhancing the $\rm \LaTeX$ code for inline limits. For the reason of doing so, you may refer to the external link of my recent linklog Inline Limit Rendering.
In the previous post in this series written over one year ago, I have included a code block which enables deferred MathJax loading. However, I manually added this chuck of code in the HTML file generated by kramdown, which created the problem described in the next subsection A problem with Vim’s folding arised.
Firstly, save the code for loading MathJax in the previous
post in this series in a separate file ~/script.html
. Then
use the following commands within Vim in order to avoid leaving the
current buffer and to improve efficiency.
9,$w! ~/temp.mkd
!kramdown ~/temp.mkd > ~/temp.html
!cat ~/{temp,script}.html > ~/test.html
The digit 9
in the first command isn’t exact. Change it to any
line number that separates the yaml front matter from the
post content.
Same as the one in my previous post.
I usually write hyperlinks for software names using only one pair of
square brackets, like [Vim]
instead of [Vim][Vim]
. Even though
this isn’t standard, this is more convenient.
I want to start the second item of the following ordered list with a hyperlink to textobj-lastpat written in a short but non-standard way.
1
2
3
4
5
6
7
8
9
10
11
12
Lessons learnt
---
Moreover, I revised the usage of these two [Vim] plugins.
1. [Visual Star Search][visual-star-search]: Select text in visual
mode and search it with an asterisk `*`.
2. [textobj-lastpat]: Add the last search pattern as a text object.
[Vim]: http://www.vim.org
[visual-star-search]: https://github.com/bronson/vim-visual-star-search
[textobj-lastpat]: https://github.com/kana/vim-textobj-lastpat
Unluckily, as I typed this Vim Ex command to see whether my Markdown syntax was correct, I quickly received an error from kramdown.
:!kramdown % > %<.html
You may click “donwload” at the top right hand corner of the codeblock below to see the effect of the result generated by ihe Markdown parser.
1
2
3
4
5
6
7
8
9
<h2 id="lessons-learnt">Lessons learnt</h2>
<p>Moreover, I revised the usage of these two <a href="http://www.vim.org">Vim</a> plugins.</p>
<ol>
<li><a href="https://github.com/bronson/vim-visual-star-search">Visual Star Search</a>: Select text in visual
mode and search it with an asterisk <code>*</code>.</li>
<li></li>
</ol>
Warning: Duplicate link ID 'textobj-lastpat' on line 13 - overwriting
Press ENTER or type command to continue
This time, I won’t find out what’s wrong from the error message because writing that hyperlink in the standard way is the quickest solution that I know.
]]>I’ve written and commited the post My Git Command List (3),
but after a while, I changed that post. In order not to complexify
my Git commit history, I used git commit --amend -a
. That’s quite
simple and convenient. I observed that the displayed time in the
amended commit was the same as the original one, whereas the SHA-1
hash was changed so that Git knows that they’re different.
However, from
Git Object ID Generation (1): Blobs and Commits, I’ve learnt
that the ID of Git commit objects is totally determined by
In this case, no difference of the above factors between the original
commit and the amended commit can be observed with git show
.
In what way do the original commit and the amended commit differ?
To solve this problem, I scrolled up the screen and captured the SHA-1 hashes fo the two commits.
9de8974b93a2e4032b608c0de17ea5ed0c55524b
5b7b566b8a07d4813ba9f08a326e169cf38ca20f
Note: I just make up the email address demo@example.com
to replace
my real email address to avoid email spams. Therefore,
the above commit hashes don’t correspond to the content displayed
below. In fact, they correspond to the commits in the Git
repository for this blog.
$ git cat-file -p 9de8974b93a2e4032b608c0de17ea5ed0c55524b
tree b9f4fb708327e25c8b1b822711ec7dda9c5b2198
parent afcb4d97cb447112bd2e930159966d92b8e4754a
author Vincent Tam <demo@example.com> 1438859683 +0800
committer Vincent Tam <demo@example.com> 1438859683 +0800
A new post on some Git low level commands
I *don't* go over the details of the book *Pro Git*, which is available
online. I just select some important ones for quick reference.
$ git cat-file -p 5b7b566b8a07d4813ba9f08a326e169cf38ca20f
tree 2d864bcb7e4944e9d98b663649c79084692873c1
parent afcb4d97cb447112bd2e930159966d92b8e4754a
author Vincent Tam <demo@example.com> 1438859683 +0800
committer Vincent Tam <demo@example.com> 1438864942 +0800
A new post on some Git low level commands
I *don't* go over the details of the book *Pro Git*, which is available
online. I just select some important ones for quick reference.
Hence, the difference of the timestamp of the committer
causes the
difference in the hashes, whereas the timestamp of the author
is
converted to a human readable date for display.
A Unix timestamp is the number of seconds elasped since the start of the year 1970 in GMT.
According to kramdown’s syntax guide, the EOB marker won’t be found in most Markdown documents. In order to include a list followed by a code block that isn’t contained inside the list, the boundary of the list has to be specified by a line consisting of a leading ‘^’ character.
]]>I often write math in this blog. After typing lots of characters,
syntax errors are inevitable, but no one wants them to be published.
Unluckily, the rake generate
command takes too long to run. In
order to find them out more quickly, I quickly went over the
Gemfile
of the repository for this blog, and saw that the Markdown
engine of Octopress is kramdown. Therefore, I used the command line
version of this Markdown parser to convert my Markdown source file to
an HTML document by a Vim Ex command.
:!kramdown % > %<.html
For this, I’ve written two posts describing the workflow of producing HTML web pages consisting of math expressions from Markdown source files using kramdown and MathJax.
In the first post in this series, I’ve made a list of steps
in Vim. However, jumping to other files is laborious. More
importantly, those steps involve browsing and copying of lines of
HTML code of the <head>
, which loads MathJax, in other HTML files.
This can seriously slow down the editing process. Unhappily, this
problem isn’t solved in the second post in this series.
There might be some option for the kramdown command line utility to use accept an HTML template files during the code conversion. However, I’m too lazy to search for them as I need to work on math.1
Remembering that I defered the loading of JavaScripts in order to boost the PageSpeed score of this site, I adpated the script to load MathJax instead of fancyBox in my draft markdown file.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<script type="text/javascript">
(function() {
function getScript(url,success){
var script=document.createElement('script');
script.src=url;
var head=document.getElementsByTagName('head')[0],
done=false;
script.onload=script.onreadystatechange = function(){
if ( !done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') ) {
done=true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
}</script></p>
<p>getScript(“https://cdn.mathjax.org/mathjax/latest/MathJax.js?” +
“config=TeX-AMS-MML_HTMLorMML” +
“,https://vincenttam.github.io/javascripts/MathJaxLocal.js”,
function(){});</p>
<p>})();
</script>
(Added on DEC 12TH, 2016)
This subsection can be omitted since appending the above code can be
done with cat
. Please see the next post in this series for
the detailed description.
By default, with the plugin vim-markdown
installed, the sections are
folded. Before I can continue editing at the end of the file, I
have to open the last fold, which contained more than 25 lines due to
the script enabling MathJax at the bottom. As a result, I have to
move back to the middle of the last fold by pressing k
for a while.
That annoys me. If the script is contained in a separate fold, it’s
better. Therefore, adding a blank line and then a line consisting of
three hyphens will fix this problem.
(Added on SEP 3RD, 2015)
Now I realised that kramdown will leave the trailing two backslashes
at each line inside <div>
tags in Markdown source files untouched.
In the second post in this series, we know that <div>
tag
prevents kramdown from converting the code inside the tag to HTML,
while in another old post about kramdown’s Markdown attributes,
one can revert the above behaviour by simply adding an attribute
markdown="1"
to the <div>
tag. These can be reflected in the
above test.
Usually, in math environments inside a $\rm \LaTeX$ document, double
backslashes \\
start a new line, and it’s the same in MathJax.
Typing two backslashes in the Markdown source down will suffice.
Unluckily, in the real Markdown source for Octopress posts, four
\
are needed.
For example, I have to think about multi-variable real-valued functions. ↩
Refer to my old post Octopress, PageSpeed, jQuery and fancyBox in Blog 1 for details. ↩
Advantages | Disadvantages | |
---|---|---|
fbi | support SVG files | doesn’t support tmux doesn’t have full control over the zooming size |
fim | support tmux support custom zooming1 |
doesn’t support SVG files |
To view SVG images in tmux buffers, one can use ImageMagick’s
convert
command.2
While writing the above table, I ran into the problem of a Markdown
table with more than one line. Luckily, searching “kramdown table
lines” on Google, I quickly found a Stack Overflow question which
solved my problem.3 Note that <br>
is not the best
way: add a slash /
to suppress the following messages.
Warning: The HTML tag 'br' on line 15 cannot have any content -
auto-closing it
Warning: The HTML tag 'br' on line 17 cannot have any content -
auto-closing it
Warning: The HTML tag 'br' on line 1 cannot have any content -
auto-closing it
Warning: The HTML tag 'br' on line 1 cannot have any content -
auto-closing it
By :nn%
↩
By convert in.svg out.jpg
↩
Newline in markdown table? on Stack Overflow. ↩