Jekyll and Markdown Syntax Cheatsheet

Chanming
Jan 1, 2022

Abstract

This is just another abstract. You should be able to write a paragraph or two here. However, semi-columns may not work well here. you may need to wrap it with a pair of grave accent marks, or dollar marks, $:$ like this.

This is just a demo. The excerpt should stop here since here’s a more tag.

Text and Paragraph Formatting

Text and Paragraph Style

This sentence is bold. If you like semantics, you might go with strong or emphasized text. If not, italic is still around. Small text is for fine print. Your copy can also be subscripted and superscripted, inserted, deleted, or highlighted. You would use a hyperlink to go to a new page. Or delegate the link to somewhere else like this link. Keyboard input elements like Cmd + Shift are used to display textual user input.

Math Equations

\[(1+x)^{n}=1+n x+\frac{n(n-1)}{2 !} x^{2}+\frac{n(n-1)(n-2)}{3 !} x^{3}+\frac{n(n-1)(n-2)(n-3)}{4 !} x^{4}+\frac{n(n-1)(n-2)(n-3)(n-4)}{5 !} x^{5}+\ldots\] \[y \gets ax + b \tag{1.1}\]

Blockquotes

Blockquotes can also be nested…

…by using additional greater-than signs right next to each other…

…or with spaces between arrows.

Lists

Unordered

  • Create a list by starting a line with +, -, or *
  • Sub-lists are made by indenting 2 spaces:
    • Marker character change forces new list start:
      • Ac tristique libero volutpat at
      • Facilisis in pretium nisl aliquet
      • Nulla volutpat aliquam velit
  • Very easy!

Ordered

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa

  4. You can use sequential numbers…
  5. …or keep all the numbers as 1.

Start numbering with offset:

  1. foo
  2. bar

Footnotes

Here’s a simple footnote,1 and here’s a longer one.2 And there’s some filling words to make paragraph seem good.

Heading IDs

This is a link to heading. Heading IDs

Definition Lists

Some Markdown processors allow you to create definition lists of terms and their corresponding definitions. To create a definition list, type the term on the first line. On the next line, type a colon followed by a space and the definition.

First Term
This is the definition of the first term.
Second Term
This is one definition of the second term.
This is another definition of the second term.

Task Lists

Task lists (also referred to as checklists and todo lists) allow you to create a list of items with checkboxes. In Markdown applications that support task lists, checkboxes will be displayed next to the content. To create a task list, add dashes (-) and brackets with a space ([ ]) in front of task list items. To select a checkbox, add an x in between the brackets ([x]).

  • Write the press release
  • Update the website
  • Contact the media

Images

This is Google, 2022

Minion Stormtroopocat

Like links, Images also have a footnote style syntax

Alt text

With a reference later in the document defining the URL location:

Abbreviations

This is HTML abbreviation example.

It converts “HTML”, but keep intact partial entries like “xxxHTMLyyy” and so on.

Horizontal Rules




Available Blocks

Algorithms

Skeleton

Control Syntax Meaning
\REQUIRE <text> precondition
\ENSURE <text> postcondition
\INPUT <text> input
\OUTPUT <text> output
\STATE <block> body of the algorithm

Control Flow Syntax

  • A <block> can include zero or more
    • <statement>,
    • <control>,
    • <comment> or
    • <function>.
  • A <statement> can be any of the following:
    • \STATE <text>,
    • \RETURN <text>,
    • \PRINT <text>.
  • A <control> can be:
    • conditional blocks \IF{<condition>}, \ELIF{<condition>}, \ELSE{<condition>}, \ENDIF;
    • or a loop: \WHILE, \FOR, or \FORALL, e.g.
      \WHILE{<condition>} 
        <block> 
      \ENDWHILE
      
    • or a repeat:
      \REPEAT 
        \STATE <block> 
      \UNTIL{<condition>}
      
  • A <function> can be defined by \FUNCTION or PROCEDURE, e.g.
    \FUNCTION{name:<text>}{params:<text>}  
      \STATE <block>
      \STATE <block>
    \ENDFUNCTION
    
  • A <comment> is \COMMENT{<text>}.

Text Content

  • normal characters
  • escaped characers e.g. \\, \{, \$, \&, \#, \%, \_
  • math formula, $i \gets i + 1$
  • function calls: \CALL{func name <text>}{args <text>}
  • keywords: \AND, \OR, \XOR, \NOT, \TO, \DOWNTO, \TRUE, \FALSE
  • Latex sizing keywords: \tiny, \scriptsize, \footnotesize, \small \normalsize, \large, \Large, \LARGE, \huge, \HUGE.
  • Latex font declaration: \rmfamily, \sffamily, \ttfamily, \upshape, \itshape, \slshape, \scshape, \bfseries, \mdseries, \lfseries
  • Latex font style: \textnormal{<text>}, \textrm{<text>}, \textsf{<text>}, \texttt{<text>}, \textup{<text>}, \textit{<text>}, \textsl{<text>}, \textsc{<text>}, \uppercase{<text>}, \lowercase{<text>}, \textbf, \textmd, \textlf

Example

% This quicksort algorithm is extracted from Chapter 7, Introduction to Algorithms (3rd edition)
\begin{algorithm}
\caption{Quicksort}
\begin{algorithmic}
\PROCEDURE{Quicksort}{$A, p, r$}
    \IF{$p \lt r$} 
        \STATE $q = $ \CALL{Partition}{$A, p, r$}
        \STATE \CALL{Quicksort}{$A, p, q - 1$}
        \STATE \CALL{Quicksort}{$A, q + 1, r$}
    \ENDIF
\ENDPROCEDURE
\PROCEDURE{Partition}{$A, p, r$}
    \STATE $x = A[r]$
    \STATE $i = p - 1$
    \FOR{$j = p$ \TO $r - 1$}
        \IF{$A[j] \lt x$}
            \STATE $i = i + 1$
            \STATE exchange
            $A[i]$ with     $A[j]$
        \ENDIF
        \STATE exchange $A[i]$ with $A[r]$
    \ENDFOR
\ENDPROCEDURE
\end{algorithmic}
\end{algorithm}

Proofs and Theorems

Lemma 1. An even number plus an even number results in an even number.

Definition 1. A definition is a a statement of the meaning of a word or word group or a sign or symbol.

Theorem 1. The real nubmers $\mathbb{R}$ are uncountable.

Proof.     If $\mathbb{R}$ is countable, then $[0, 1]$ is countable as well. Hence there exists a map $C$ from $\mathbb{N}$ onto $[0, 1]$ with

\[C(n)=\sum_{i=1}^{\infty} c_{i}(n) 10^{-i}\]

where $c_{i}(n)\in{0,1, \ldots, 9},$ are the digits in decimal expansion. Now consider a real number

\[x=\sum_{i=1}^{\infty} \bar{c}_{i} 10^{-i}\in[0,1]\]

with $\bar{c}_ {i}\ne c_ {i}(i)$. Obviously $C(n) \neq x$ for all $n \in \mathbb{N}$. Hence $C$ is not onto. A contradiction.

Theorem 2. If $S$ is both countable and infinite, then there is a bijection between $S$ and $N$ itself.

Proof.     For any $s\in S$, we let $f(s)$ denote the value of $k$ such that $s$ is the $k$th smallest element of $S$. This map is well defined for any $s$, because there are only finitely many natural numbers between 1 and $s$. It is impossible for two different elements of $S$ to both be the $k$th smallest element of $S$. Hence $f$ is one-to-one. Also, since $S$ is infinite, $f$ is onto.

Sidenotes

Sidenotes can be used as an alternative to footnotes, where the user does not have to jump to the bottom of the page to read it. On mobile, click the superscript to reveal the note Yay, sidenotes!. If you are on mobile, I will appear inline. If you are using a larger screen, the sidenote will appear to the right of the text..

Sidenotes do need a little bit of setup, they are made up of a label, an invisible checkbox on top of the number and a span with the text inside. The superscript is set automatically and incremented using CSS when the checkbox has a class of sidenote-number. This is randomly generated in _plugins/algorithm.rb file. To remove the number, simply remove the class sidenote-number.

Add a class of left to the span with the sidenote class to make the note appear on the left side of the page on instead of right. The symbol you could use to indicate a sidenote is up to you. What about this notebook This is a left sidenote. Aha.
(Anything in this block will not be correctly rendered as markdown text, since <span> tag cannot have <p> child. Use <br/> or other inline tags directly.) $\lambda_f(t)=1.3^t+1.5t+1$
.

Highlight Code

Inline code

Indented code

// Some comments
line 1 of code
line 2 of code
line 3 of code

Block code “fences”

Sample text here...

Syntax highlighting

var foo = function (bar) {
  return bar++;
};

console.log(foo(5));

And

class TokenVerificationImpl(TokenVerifyBase):
    
    def __init__(self, token: str):
        pass
        
    def verify(self, user_input: str) -> bool:
        return False
    

if __name__ == '__main__':
    print('helloWorld!')

Tables

Default left aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Right aligned columns

Option Description
data path to data files to supply the data that will be passed into templates.
engine engine to be used for processing templates. Handlebars is the default.
ext extension to be used for dest files.

Left, center, right aligned columns

Syntax Description Test Text
Header Title Here’s this
Paragraph Text And more

EOF

  1. This is the first footnote. 

  2. Here’s one with multiple paragraphs and code.

    Indent paragraphs to include them in the footnote.

    { my code }

    Add as many paragraphs as you like. 

Update History

  • 2022-01-05, fix several typos.
  • 2022-01-01, first release.