Github页面在我的帖子中添加随机标签

时间:2012-03-22 22:25:55

标签: html github markdown jekyll liquid

如果您访问我的网站,您会注意到最新的文章(在主页上)将其标题包含在<pre>标记中并重复。我不知道为什么会这样。

以下是正在显示的帖子:

---
layout: default
---

Stop distributing .doc files
----------------------------
Monday March 19th, 2012

`.doc` started as a file format used by many operating systems and used to store only plain-text. In the 90's, Microsoft decided to use the extension for Word -- their new word processor. Not only did they decide to use the extension, but they also broke the standard by using a proprietary format, instead of the plain-text most people were used to. Despite the `.doc` extension being more than **10 years old** and the fact that most documents formatted this way render horribly in operating systems other than Windows, I still regularly receive documents in this format. Stop it.

However aggravating the above paragraph is, this article isn't solely targeted at the `.doc` extension -- it is a public plea for people to stop distributing application specific documents and to start distrubting all documents in `.pdf`.

Yesterday I received an email from an engineering society I'm a part of. They were notifying all members of the upcoming annual general meeting that is taking place next week. I immediately lost interest in the email when I saw that their meeting schedule and their nomination form were both in `.docx` format. I don't like being forced to download the file, minimize my browser, launch an Office application (in my case, LibreOffice) and then read the content. Had it been distributed in `.pdf`, Chrome would have immediately opened a new tab for me displaying the document and giving me options to save, zoom or print it. I'm sure Firefox, Opera and (maybe) Internet Explorer have similar features.

We are increasingly collaborating on the web, and the need for bulky desktop applications are almost gone with the wind. Had I not had an office application on my computer (which could have been possible seeing as I do most of my documentation and report with LaTeX), I would have had an extra step before viewing the content that was sent to me. It's not like it is difficult either. All major office applications I know of allow easy exporting to `.pdf` file format and LibreOffice also allows you to save a hybrid `.pdf` and `.odt` together in one file. This allows you to distribute the PDF as is and also open it for editing.

There is virtually no need to distribute documents in any format, proprietary or not, other than PDF. Don't make your users work and fiddle with your flatform-specific or application-dependent documents.

这是我的默认布局(相关部分,您可以查看其他任何内容的来源):

<div id="right-side">

            {{ content }}

            <div id="footer">
                <p>
                    &copy; {{ site.author.name }} 2012 with help from
                    <a href="http://jekyllbootstrap.com" target="_blank">Jekyll Bootstrap</a>
                </p>
            </div>
        </div>

如您所见,布局只是将markdown文件的内容转储到right-side div中。如果您访问我网站上的其他页面/帖子,您会看到这些页面有效但不是主页(尽管它们采用相同的降价格式并使用相同的布局)。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

问题是your index page上的循环。缩进是由Liquid保留的(类型):文本替换是字面替换,这意味着第一行将缩进,但后面的行不会。 index.mdfirst.content已经是HTML)的降价处理在Liquid运行后发生,因此缩进被解释为代码块。

处理中的步骤(这不一定是每一步的逐字输出,但它会很接近):

{% for first in site.posts limit:1 %}
    {{ first.title }}
    {{ first.content }}
{% endfor %} 

Liquid已在index.md上运行:

    Stop distributing .doc files
    <h2>[...]</h2>

<p>Monday March 19th, 2012</p>

[...]

现在Markdown运行,缩进意味着前两行是代码块:

<pre><code>Stop Distributing .doc Files
&lt;h2 id='stop_distributing_doc_files'&gt;Stop distributing .doc files&lt;/h2&gt;</code></pre>
<p>Monday March 19th, 2012</p>

这可以通过不对for循环的元素进行如此大的缩进来修复:缩进4个空格或选项卡使代码块。所以

{% for first in site.posts limit:1 %}
  {{ first.title }}
  {{ first.content }}
{% endfor %}