Skip to content

Commit

Permalink
Make sure feeds are cleaned up of any magic elements
Browse files Browse the repository at this point in the history
  • Loading branch information
danott committed Jan 15, 2024
1 parent 5540e49 commit 42988dd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/feed_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def description
content = File.read(post_data.fetch("source_path"))
content = Kramdown::Document.new(content, kramdown_options).to_html.strip
content = remove_html_comments(content)
content = remove_magic_elements(content)
content = remove_html_title(content)
content = make_urls_absolute(content)
content = append_rss_footer(content)
Expand All @@ -94,6 +95,13 @@ def remove_html_comments(content)
content.gsub(/<!--.*?-->/m, "")
end

def remove_magic_elements(content)
content
.gsub(%r{<template data-parse.*?</template>}m, "")
.gsub(%r{<include-in-header>.*?</include-in-header>}m, "")
.gsub(%r{<eval-ruby>.*?</eval-ruby>}m, "")
end

def remove_html_title(content)
content.sub(%r{<h1>.*?</h1>}m, "")
end
Expand Down

0 comments on commit 42988dd

Please sign in to comment.