aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/public/post/2017/02/14/a-plain-markdown-post/index.html
blob: 192e26976978a46cfd21c9c4613e45311e574134 (plain) (blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>A Plain Markdown Post | Hugo XMag</title>
    <link rel="stylesheet" href="/css/style.css" />
    <link rel="stylesheet" href="/css/fonts.css" />
    <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">

  </head>

  <body class="page">
    <nav class="header">
      <div class="banner">
<a href="/" class="text">
&Hfr;&Ufr;&Gfr;&Ofr; &Xfr;&Mfr;&Afr;&Gfr;
</a>
</div>

      <div class="head-meta">
      
        <span><a href="/">&larr; Back to Home</a></span>
        <span class="date">2017-02-14</span>
        
        
        
          
        
        
        
        <span><a href="https://github.com/yihui/hugo-xmag/edit/master/exampleSite/content/post/2017-02-14-hello-markdown.md">Edit this page &rarr;</a></span>
        
        
      
      </div>
    </nav>

<div class="container">
<article>
<div class="article-meta">

  <div class="categories">
  
    <a href="/categories/example">Example</a>
  
     &hercon; <a href="/categories/hugo">Hugo</a>
  
  </div>

  <h1><span class="title">A Plain Markdown Post</span></h1>

  
  <h3 class="author">Yihui Xie, Frida Gomam
</h3>
  

  
  <p>Tags: <a href="/tags/blogdown">blogdown</a>; <a href="/tags/markdown">Markdown</a>; <a href="/tags/mathjax">MathJax</a>; <a href="/tags/pandoc">Pandoc</a>; <a href="/tags/rstudio">RStudio</a>
  </p>
  
  

</div>


<nav id="TableOfContents">
  <ul>
    <li><a href="#second-level-header">Second-level header</a>
      <ul>
        <li><a href="#third-level-header">Third-level header</a></li>
      </ul>
    </li>
  </ul>
</nav>


<main>
<p>This sample post is mainly for <a href="https://github.com/rstudio/blogdown"><strong>blogdown</strong></a> users. If you do not use <strong>blogdown</strong>, you can skip the first section. To know more about the Hugo XMag theme, please read the <a href="/about/">About</a> page.</p>
<h1 id="1-markdown-or-r-markdown">1. Markdown or R Markdown</h1>
<p>This is a post written in plain Markdown (<code>*.md</code>) instead of R Markdown (<code>*.Rmd</code>). The major differences are:</p>
<ol>
<li>You cannot run any R code in a plain Markdown document, whereas in an R Markdown document, you can embed R code chunks (<code>```{r}</code>);</li>
<li>A plain Markdown post is rendered through <a href="https://gohugo.io/overview/configuration/">Blackfriday</a>, and an R Markdown document is compiled by <a href="http://rmarkdown.rstudio.com"><strong>rmarkdown</strong></a> and <a href="http://pandoc.org">Pandoc</a>.</li>
</ol>
<p>There are many differences in syntax between Blackfriday&rsquo;s Markdown and Pandoc&rsquo;s Markdown. For example, you can write a task list with Blackfriday but not with Pandoc:</p>
<ul>
<li><input checked="" disabled="" type="checkbox"> Write an R package.</li>
<li><input disabled="" type="checkbox"> Write a book.</li>
<li><input disabled="" type="checkbox"> &hellip;</li>
<li><input disabled="" type="checkbox"> Profit!</li>
</ul>
<p>Similarly, Blackfriday does not support LaTeX math and Pandoc does. I have added the MathJax support to this theme (<a href="https://github.com/yihui/hugo-xmag">hugo-xmin</a>) but there is a caveat for plain Markdown posts: you have to include math expressions in a pair of backticks (inline: <code>`$ $`</code>; display style: <code>`$$ $$`</code>), e.g., <code>$S_n = \sum_{i=1}^n X_i$</code>.^[This is because we have to protect the math expressions from being interpreted as Markdown. You may not need the backticks if your math expression does not contain any special Markdown syntax such as underscores or asterisks, but it is always a safer choice to use backticks. When you happen to have a pair of literal dollar signs inside the same element, you can escape one dollar sign, e.g., <code>\$50 and $100</code> renders &ldquo;$50 and $100&rdquo;.] For R Markdown posts, you do not need the backticks, because Pandoc can identify and process math expressions.</p>
<p>When creating a new post, I recommend you to use the RStudio addin &ldquo;New Post&rdquo;:</p>
<p><img src="https://bookdown.org/yihui/blogdown/images/new-post.png" alt="RStudio addin New Post"></p>
<h1 id="2-sample-text">2. Sample Text</h1>
<h2 id="second-level-header">Second-level header</h2>
<h3 id="third-level-header">Third-level header</h3>
<h4 id="fourth-level-header">Fourth-level header</h4>
<p>A paragraph (with a footnote):</p>
<p><strong>Lorem ipsum</strong> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore <em>magna aliqua</em>. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.^[I&rsquo;m sure you are bored by the text here.]</p>
<p>A blockquote (a gray bar at the left and lightgray background):</p>
<blockquote>
<p>Quisque mattis volutpat lorem vitae feugiat. Praesent porta est quis porta imperdiet. Aenean porta, mi non cursus volutpat, mi est mollis libero, id suscipit orci urna a augue. In fringilla euismod lacus, vitae tristique massa ultricies vitae. Mauris accumsan ligula tristique, viverra nulla sed, porta sapien. Vestibulum facilisis nec nisl blandit convallis. Maecenas venenatis porta malesuada. Ut ac erat tortor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla sodales quam sit amet tincidunt egestas. In et turpis at orci vestibulum ullamcorper. Aliquam sed ante libero. Sed hendrerit arcu lacus.</p>
</blockquote>
<p>Some code (with a drop-shadow effect):</p>
<pre><code class="language-js">(function() {
  var quotes = document.getElementsByTagName('blockquote'), i, quote;
  for (i = 0; i &lt; quotes.length; i++) {
    quote = quotes[i];
    var n = quote.children.length;
    if (n === 0) continue;
    var el = quote.children[n - 1];
    if (!el || el.nodeName !== 'P') continue;
    // right-align a quote footer if it starts with ---
    if (/^—/.test(el.textContent)) el.style.textAlign = 'right';
  }
})();
</code></pre>
<p>A table (centered by default):</p>
<table>
<thead>
<tr>
<th style="text-align:right">Sepal.Length</th>
<th style="text-align:right">Sepal.Width</th>
<th style="text-align:right">Petal.Length</th>
<th style="text-align:right">Petal.Width</th>
<th style="text-align:left">Species</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">5.1</td>
<td style="text-align:right">3.5</td>
<td style="text-align:right">1.4</td>
<td style="text-align:right">0.2</td>
<td style="text-align:left">setosa</td>
</tr>
<tr>
<td style="text-align:right">4.9</td>
<td style="text-align:right">3.0</td>
<td style="text-align:right">1.4</td>
<td style="text-align:right">0.2</td>
<td style="text-align:left">setosa</td>
</tr>
<tr>
<td style="text-align:right">4.7</td>
<td style="text-align:right">3.2</td>
<td style="text-align:right">1.3</td>
<td style="text-align:right">0.2</td>
<td style="text-align:left">setosa</td>
</tr>
<tr>
<td style="text-align:right">4.6</td>
<td style="text-align:right">3.1</td>
<td style="text-align:right">1.5</td>
<td style="text-align:right">0.2</td>
<td style="text-align:left">setosa</td>
</tr>
<tr>
<td style="text-align:right">5.0</td>
<td style="text-align:right">3.6</td>
<td style="text-align:right">1.4</td>
<td style="text-align:right">0.2</td>
<td style="text-align:left">setosa</td>
</tr>
<tr>
<td style="text-align:right">5.4</td>
<td style="text-align:right">3.9</td>
<td style="text-align:right">1.7</td>
<td style="text-align:right">0.4</td>
<td style="text-align:left">setosa</td>
</tr>
</tbody>
</table>
<p>An image (automatically centered when it is appropriate):</p>
<p><img src="https://slides.yihui.org/gif/happy-elmo.gif" alt="Happy Elmo"></p>
<p>Looks good?</p>

</main>



















<section class="article-meta article-footer">
  <h3>About the Author</h3>
  
    <p>Yihui Xie is currently a softwaren engineer at <a href="https://www.rstudio.com">RStudio</a>. You can find more information about him at <a href="https://yihui.org">https://yihui.org</a>.</p>
  
    <p>Frida Gomam is a joke.</p>
  
</section>






<nav class="post-nav">
  <span class="nav-prev"></span>
  <span class="nav-next"><a href="/post/2015/07/28/jeff-leek-can-do-zero-fold-cross-validation/">Jeff Leek can do zero-fold cross-validation &rarr;</a></span>
</nav>



</article>
</div>

<script async src="//yihui.org/js/center-img.js"></script>

<footer>

<div class="footer">
  <ul class="menu">
    
    <li><a href="/"><span data-hover="Home">Home</span></a></li>
    
    <li><a href="/about/"><span data-hover="About">About</span></a></li>
    
    <li><a href="/categories/"><span data-hover="Categories">Categories</span></a></li>
    
    <li><a href="/tags/"><span data-hover="Tags">Tags</span></a></li>
    
    <li><a href="/index.xml"><span data-hover="Subscribe">Subscribe</span></a></li>
    
  </ul>
  
  <div class="copyright">© <a href="https://yihui.org">Yihui Xie</a> 2017 - 2023 | <a href="https://github.com/yihui">Github</a> | <a href="https://twitter.com/xieyihui">Twitter</a></div>
  
</div>
</footer>


<script src="//yihui.org/js/math-code.js"></script>
<script async src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>



<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/r.min.js"></script>
<script>
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
</script>




</body>
</html>