我怎样才能省略Octopress/Jekyll';什么是摘录?
我使用Octopress 2.0写博客,它使用Jekyll静态站点生成器 要在头版标记博客文章的摘录,您可以在文章中插入我怎样才能省略Octopress/Jekyll';什么是摘录?,jekyll,liquid,octopress,Jekyll,Liquid,Octopress,我使用Octopress 2.0写博客,它使用Jekyll静态站点生成器 要在头版标记博客文章的摘录,您可以在文章中插入,此时的内容将用作摘录 对于一些帖子,即使我想要一个摘录,我也希望从中排除某些内容(可能是一个只在帖子上有意义的目录,或者一些对摘录没有用处的额外注释) 在Octopress/Jekyll/Liquid中是否有一种方法可以使用方法生成摘录,但也可以标记一些少量的内容以将其忽略 下面是一个简单的例子。担任这一职务: --- layout: post title: "Exampl
,此时的内容将用作摘录
对于一些帖子,即使我想要一个摘录,我也希望从中排除某些内容(可能是一个只在帖子上有意义的目录,或者一些对摘录没有用处的额外注释)
在Octopress/Jekyll/Liquid中是否有一种方法可以使用
方法生成摘录,但也可以标记一些少量的内容以将其忽略
下面是一个简单的例子。担任这一职务:
---
layout: post
title: "Example Post"
---
This is the first paragraph. It will be included in the excerpt.
[Jump to third paragraph](#para3). This paragraph should **not** be in the excerpt.
This is the second paragraph. It will be included in the excerpt.
<!--more-->
<a name="para3"></a>This is the third paragraph. It won't be in the excerpt.
编辑:我现在明白你想做什么了 我假设您使用的是默认的octopressmarkdown:rdisont 让我们来看看过滤方式: 在Gemfile中添加
gem'nokogiri'
在您的帖子中,我们的想法是在有时需要剥离的零件上添加一个span.secondary。内容
...
remove_secondary_content_from_excerpt : true
---
This is the first paragraph. It will be included in the excerpt.
[[Jump to third paragraph](#para3). This paragraph should **not**
be in the excerpt.](class:secondary)
This is the second paragraph. It will be included in the excerpt.
<!--more-->
### This is the TEXT title
This is **the text**
。。。
从摘录中删除次要内容:true
---
这是第一段。这将包括在摘录中。
[[跳到第三段](#para3)。该段不应**
在摘录中。](班级:中学)
这是第二段。这将包括在摘录中。
###这是文本标题
这是课文**
在_includes/article.html中
...
</header>
{% endunless %}
{% if index %}
<div class="entry-content">
{% if post.remove_secondary_content_from_excerpt == true %}
{% capture secondary_content %}{{ post.excerpt | excerpt_get_secondary_content }}{% endcapture %}
{{ post.excerpt | remove: secondary_content }}
{% else %}
{{ post.excerpt }}
{% endif %}
</div>
{% capture excerpted %}{{ content | has_excerpt }}{% endcapture %}
{% if excerpted == 'true' %}
<footer>
<a rel="full-article" href="{{ root_url }}{{ post.url }}">{{ site.excerpt_link }}</a>
</footer>
{% endif %}
{% else %}
<div class="entry-content">
<!-- example on how to use it in post page -->
{% if page.remove_secondary_content_from_excerpt == true %}
{% capture secondary_content %}{{ page.excerpt | excerpt_get_secondary_content }}{% endcapture %}
{{ page.excerpt | remove: secondary_content }}
{{ secondary_content }}
{{ page.content | markdownify | remove: page.excerpt }}
{% else %}
{{ content }}
{% endif %}
</div>
{% endif %}
。。。
{%end除非%}
{%if索引%}
{%if post.remove_secondary_content_from_extract==true%}
{%capture secondary_content%}{{post.extract | extract_get_secondary_content}{%endcapture%}
{{post.extract | remove:secondary_content}
{%else%}
{{post.extract}}
{%endif%}
{%capture-extracted%}{{content | has_-extracted}}{%endcapture%}
{%if extracted=='true%}
{%endif%}
{%else%}
{%if page.remove_secondary_content_from_extract==true%}
{%capture secondary_content%}{{page.extract}extract_get_secondary_content}{%endcapture%}
{{page.摘录|删除:次要内容}
{{secondary_content}}
{{page.content | markdownify | remove:page.extract}}
{%else%}
{{content}}
{%endif%}
{%endif%}
In_plugins/octopress_filters.rb
...
module OctopressLiquidFilters
def excerpt_get_secondary_content(input)
require 'nokogiri'
doc = Nokogiri::HTML(input)
# as excerpt can surrounded by one <p> (when no double newline in it)
# or with multiple <p> when a double newline is found
multiparagraph = doc.css("p").length > 1
if multiparagraph
# look for parent <p>
xpathString = "span.secondary/.."
end
# look only for the span element
xpathString = "span.secondary"
else
secondary = doc.css(xpathString)
secondary.to_s
end
...
。。。
八达通滤波器模块
def摘录获取辅助内容(输入)
需要“nokogiri”
doc=Nokogiri::HTML(输入)
#as摘录可以由一个包围(当其中没有双换行符时)
#或在发现双换行时使用多个
multiparagraph=doc.css(“p”)。长度>1
if多道图
#寻找父母
xpathString=“span.secondary/”
结束
#仅查找跨度元素
xpathString=“span.secondary”
其他的
secondary=doc.css(xpathString)
中学
结束
...
安装Nokogiribundle更新
我希望你的
rake generate
会让你开心。编辑:我现在明白你想做什么了
我假设您使用的是默认的octopressmarkdown:rdisont
让我们来看看过滤方式:
在Gemfile中添加gem'nokogiri'
在您的帖子中,我们的想法是在有时需要剥离的零件上添加一个span.secondary。内容
...
remove_secondary_content_from_excerpt : true
---
This is the first paragraph. It will be included in the excerpt.
[[Jump to third paragraph](#para3). This paragraph should **not**
be in the excerpt.](class:secondary)
This is the second paragraph. It will be included in the excerpt.
<!--more-->
### This is the TEXT title
This is **the text**
。。。
从摘录中删除次要内容:true
---
这是第一段。这将包括在摘录中。
[[跳到第三段](#para3)。该段不应**
在摘录中。](班级:中学)
这是第二段。这将包括在摘录中。
###这是文本标题
这是课文**
在_includes/article.html中
...
</header>
{% endunless %}
{% if index %}
<div class="entry-content">
{% if post.remove_secondary_content_from_excerpt == true %}
{% capture secondary_content %}{{ post.excerpt | excerpt_get_secondary_content }}{% endcapture %}
{{ post.excerpt | remove: secondary_content }}
{% else %}
{{ post.excerpt }}
{% endif %}
</div>
{% capture excerpted %}{{ content | has_excerpt }}{% endcapture %}
{% if excerpted == 'true' %}
<footer>
<a rel="full-article" href="{{ root_url }}{{ post.url }}">{{ site.excerpt_link }}</a>
</footer>
{% endif %}
{% else %}
<div class="entry-content">
<!-- example on how to use it in post page -->
{% if page.remove_secondary_content_from_excerpt == true %}
{% capture secondary_content %}{{ page.excerpt | excerpt_get_secondary_content }}{% endcapture %}
{{ page.excerpt | remove: secondary_content }}
{{ secondary_content }}
{{ page.content | markdownify | remove: page.excerpt }}
{% else %}
{{ content }}
{% endif %}
</div>
{% endif %}
。。。
{%end除非%}
{%if索引%}
{%if post.remove_secondary_content_from_extract==true%}
{%capture secondary_content%}{{post.extract | extract_get_secondary_content}{%endcapture%}
{{post.extract | remove:secondary_content}
{%else%}
{{post.extract}}
{%endif%}
{%capture-extracted%}{{content | has_-extracted}}{%endcapture%}
{%if extracted=='true%}
{%endif%}
{%else%}
{%if page.remove_secondary_content_from_extract==true%}
{%capture secondary_content%}{{page.extract}extract_get_secondary_content}{%endcapture%}
{{page.摘录|删除:次要内容}
{{secondary_content}}
{{page.content | markdownify | remove:page.extract}}
{%else%}
{{content}}
{%endif%}
{%endif%}
In_plugins/octopress_filters.rb
...
module OctopressLiquidFilters
def excerpt_get_secondary_content(input)
require 'nokogiri'
doc = Nokogiri::HTML(input)
# as excerpt can surrounded by one <p> (when no double newline in it)
# or with multiple <p> when a double newline is found
multiparagraph = doc.css("p").length > 1
if multiparagraph
# look for parent <p>
xpathString = "span.secondary/.."
end
# look only for the span element
xpathString = "span.secondary"
else
secondary = doc.css(xpathString)
secondary.to_s
end
...
。。。
八达通滤波器模块
def摘录获取辅助内容(输入)
需要“nokogiri”
doc=Nokogiri::HTML(输入)
#as摘录可以由一个包围(当其中没有双换行符时)
#或在发现双换行时使用多个
multiparagraph=doc.css(“p”)。长度>1
if多道图
#寻找父母
xpathString=“span.secondary/”
结束
#仅查找跨度元素
xpathString=“span.secondary”
其他的
secondary=doc.css(xpathString)
中学
结束
...
安装Nokogiribundle更新
我希望你的
rake generate
会让你开心。编辑:我现在明白你想做什么了
我假设您使用的是默认的octopressmarkdown:rdisont
让我们来看看过滤方式:
在Gemfile中添加gem'nokogiri'
在您的帖子中,我们的想法是在有时需要剥离的零件上添加一个span.secondary。内容
...
remove_secondary_content_from_excerpt : true
---
This is the first paragraph. It will be included in the excerpt.
[[Jump to third paragraph](#para3). This paragraph should **not**
be in the excerpt.](class:secondary)
This is the second paragraph. It will be included in the excerpt.
<!--more-->
### This is the TEXT title
This is **the text**
。。。
从摘录中删除次要内容:true
---
这是第一段。信息技术