Skip to content

Commit

Permalink
Remove spurious blank line in snippets
Browse files Browse the repository at this point in the history
@satcar77 kindly pointed me into the right direction to fix there being
spurious newlines when doing a snippet that doesn't start at the first
of a file.
  • Loading branch information
PerilousApricot committed Feb 13, 2024
1 parent 2e65245 commit eed1572
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docs/_includes/includesnippet
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Example:
{%- capture filecontent -%}
{%- include {{include.filename}} -%}
{%- endcapture -%}
{%- assign lines = filecontent | rstrip | newline_to_br | split: '<br />' -%}
{%- assign lines = filecontent | rstrip | split: "
" -%}
{%- assign start = {{include.start}} -%}
{%- assign count = {{include.count}} -%}
{%- for line in lines -%}
Expand All @@ -30,6 +31,10 @@ Example:
{%- assign count = end | minus: start -%}
{%- endif -%}
{%- endfor -%}
{%- for line in lines offset: {{start}} limit: {{count}} -%}
{{- line | rstrip -}}
{%- endfor -%}
{% for line in lines offset: {{start}} limit: {{count}} -%}
{% if forloop.last -%}
{{- line | rstrip -}}
{%- else -%}
{{- line | rstrip }}
{% endif -%}
{% endfor -%}

0 comments on commit eed1572

Please sign in to comment.