Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Remove line number from post snippet (artemsheludko#51).
Browse files Browse the repository at this point in the history
Involves:
- Home page
- relate posts
- search results
- feed
  • Loading branch information
cotes2020 committed May 8, 2020
1 parent efb3c46 commit ac10811
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
12 changes: 12 additions & 0 deletions _includes/no-linenos.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% comment %}
Remove line numbers from code snippets.
v2.2
https://github.com/cotes2020/jekyll-theme-chirpy
© 2020 Cotes Chung
Published under the MIT License
{% endcomment %}

{% if _content contains '<td class="rouge-gutter gl"><pre class="lineno">' %}
{% assign _content = _content | replace: '<td class="rouge-gutter gl"><pre class="lineno">', '<!-- <td class="rouge-gutter gl"><pre class="lineno">'%}
{% assign _content = _content | replace: '</td><td class="rouge-code">', '</td> --><td class="rouge-code">' %}
{% endif %}
4 changes: 3 additions & 1 deletion _includes/related-posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ <h3 class="pt-2 mt-1 mb-4 ml-1" data-toc-skip>{{ site.data.label.post.relate_pos
</span>
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
<div class="text-muted small">
<p>{{ post.content | markdownify | strip_html | truncate: 200 | replace: '&', '&amp;' }}</p>
{% assign content = post.content %}
{% include no-linenos.html %}
<p>{{ content | markdownify | strip_html | truncate: 200 | replace: '&', '&amp;' }}</p>
</div>
</div>
</a>
Expand Down
4 changes: 3 additions & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ <h1>
</h1>
<div class="post-content">
<p>
{{ post.content | strip_html | truncate: 200 | replace: '&', '&amp;' }}
{% assign _content = post.content %}
{% include no-linenos.html %}
{{ _content | markdownify | strip_html | truncate: 200 }}
</p>
</div>

Expand Down
4 changes: 3 additions & 1 deletion assets/data/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ layout: compress
"categories": "{{ post.categories | join: ', '}}",
"tags": "{{ post.tags | join: ', ' }}",
"date": "{{ post.date }}",
"snippet": "{{ post.content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
{% assign content = post.content %}
{% include no-linenos.html %}
"snippet": "{{ content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
5 changes: 4 additions & 1 deletion feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ layout: compress
{% if post.summary %}
<summary>{{ post.summary | strip }}</summary>
{% else %}
<summary>{{ post.content | strip_html | truncate: 200 }}</summary>
<summary>
{% assign content = post.content %}
{% include no-linenos.html %}
{{ content | strip_html | truncate: 200 }}</summary>
{% endif %}

</entry>
Expand Down

0 comments on commit ac10811

Please sign in to comment.