Browse Source

Makes Atom feed honor specifications (see below)

+ Fixes `type` of `content` and `summary` entries
- Removes `script` and `iframe` tags from entries content (from JSON feed too)

There is actually an issue with Jekyll when using `capture` and incremental build.
It was actually not related to `highlighter` config entry, so `f17a8ff3` has been partly reverted.
An issue has been opened upstream ([jekyll/jekyll#8062]).
From now, incremental build will be disabled.
master
Samuel FORESTIER 4 months ago
parent
commit
a4f115b287
4 changed files with 27 additions and 6 deletions
  1. +1
    -2
      _config.yml
  2. +12
    -0
      _plugins/re_substitute.rb
  3. +8
    -3
      atom.xml
  4. +6
    -1
      feed.json

+ 1
- 2
_config.yml View File

@@ -34,7 +34,6 @@ plugins:
- jekyll-paginate-v2

markdown: kramdown
highlighter: rouge
emoji:
src: "/img/"
## _______ ##
@@ -82,6 +81,6 @@ autopages:
## __________ ##

## BUILD OPTIONS ##
incremental: true
incremental: false # Waiting for [jekyll/jekyll#8062].
strict_front_matter: true
## _____________ ##

+ 12
- 0
_plugins/re_substitute.rb View File

@@ -0,0 +1,12 @@

# From <https://stackoverflow.com/a/25802375>.
module Jekyll
module RegexFilter
def re_substitute(input, reg_str, repl_str)
regexp = Regexp.new reg_str, Regexp::MULTILINE
input.gsub regexp, repl_str
end
end
end

Liquid::Template.register_filter(Jekyll::RegexFilter)

+ 8
- 3
atom.xml View File

@@ -25,14 +25,19 @@ regenerate: true

{% for post in site.posts limit: site.feed.limit %}
{%- unless post.draft %}
{%- capture post_content -%}{{ post.content }}{%- endcapture -%}
{%- capture post_content -%}
{{ post.content |
re_substitute: '<\bscript\b.+?>.+?<\/\bscript\b>', '' |
re_substitute: '<\biframe\b.+?>.+?<\/\biframe\b>', ''
}}
{%- endcapture -%}
<entry>
<id>{{ site.url }}{{ post.url }}</id>
<title>{{ post.title | xml_escape }}</title>
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
<content type="text/html">{{ post_content | markdownify | xml_escape }}</content>
<content type="html">{{ post_content | markdownify | xml_escape }}</content>
<link rel="alternate" type="text/html" href="{{ site.url }}{{ post.url }}"/>
<summary type="text/html">{{ post.description | xml_escape }}</summary>
<summary>{{ post.description | xml_escape }}</summary>
<category term="{{ post.category | downcase | xml_escape }}"/>
<published>{{ post.date | date_to_xmlschema }}</published>
</entry>


+ 6
- 1
feed.json View File

@@ -15,7 +15,12 @@ regenerate: true
"icon": "{{ site.url }}{{ site.logo }}",
"favicon": "{{ site.url }}/img/favicon/favicon.ico",
"items": [{% for post in site.posts limit: site.feed.limit %}{% unless post.draft %}
{%- capture post_content -%}{{ post.content }}{%- endcapture -%}
{%- capture post_content -%}
{{ post.content |
re_substitute: '<\bscript\b.+?>.+?<\/\bscript\b>', '' |
re_substitute: '<\biframe\b.+?>.+?<\/\biframe\b>', ''
}}
{%- endcapture -%}
{
"title": {{ post.title | jsonify }},
"date_published": {{ post.date | date_to_xmlschema | jsonify }},


Loading…
Cancel
Save