From 1329429130705ee582a6b2de89aefc68a2d2de9c Mon Sep 17 00:00:00 2001 From: darken Date: Fri, 20 Jun 2025 09:49:27 +0200 Subject: [PATCH] Refactor: Improve CHANGELOG.md formatting This commit refactors the Liquid templating in `CHANGELOG.md` to: - Indent Liquid logic for better readability. - Improve spacing around headings (##, ###) and list items (-) for a cleaner rendered output. --- CHANGELOG.md | 91 +++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e9b2c0..b6817fbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,9 @@ title: "Changelog" {% assign no_comments = clean_body | replace: "" %} {% if no_comments.size > 1 %} -{% assign clean_content = no_comments[1] | strip %} + {% assign clean_content = no_comments[1] | strip %} {% else %} -{% assign clean_content = no_comments[0] | strip %} + {% assign clean_content = no_comments[0] | strip %} {% endif %} {% comment %} Make links clickable {% endcomment %} @@ -24,58 +24,67 @@ title: "Changelog" " %} {% assign processed_lines = "" %} {% for line in lines %} -{% if line contains "**Full Changelog**:" %} -{% comment %} Handle Full Changelog links {% endcomment %} -{% assign parts = line | split: ": " %} -{% if parts.size > 1 %} -{% assign url = parts[1] | strip %} -{% assign clickable_line = "**[View Changes](" | append: url | append: ")**" %} -{% assign processed_lines = processed_lines | append: clickable_line | append: " + {% if line contains "**Full Changelog**:" %} + {% comment %} Handle Full Changelog links {% endcomment %} + {% assign parts = line | split: ": " %} + {% if parts.size > 1 %} + {% assign url = parts[1] | strip %} + {% assign clickable_line = "**[View Changes](" | append: url | append: ")**" %} + {% assign processed_lines = processed_lines | append: clickable_line | append: " " %} -{% else %} -{% assign processed_lines = processed_lines | append: line | append: " + {% else %} + {% assign processed_lines = processed_lines | append: line | append: " " %} -{% endif %} -{% elsif line contains " in https://github.com/" and line contains "/pull/" %} -{% comment %} Handle pull request links {% endcomment %} -{% assign pr_parts = line | split: " in https://github.com/" %} -{% if pr_parts.size > 1 %} -{% assign before_url = pr_parts[0] %} -{% assign after_url = pr_parts[1] %} -{% assign url = "https://github.com/" | append: after_url %} -{% assign pr_number = after_url | split: "/pull/" %} -{% if pr_number.size > 1 %} -{% assign pr_num = pr_number[1] | split: " " | first %} -{% assign clickable_line = before_url | append: " in [#" | append: pr_num | append: "](" | append: url | append: ")" %} -{% assign processed_lines = processed_lines | append: clickable_line | append: " + {% endif %} + {% elsif line contains " in https://github.com/" and line contains "/pull/" %} + {% comment %} Handle pull request links {% endcomment %} + {% assign pr_parts = line | split: " in https://github.com/" %} + {% if pr_parts.size > 1 %} + {% assign before_url = pr_parts[0] %} + {% assign after_url = pr_parts[1] %} + {% assign url = "https://github.com/" | append: after_url %} + {% assign pr_number = after_url | split: "/pull/" %} + {% if pr_number.size > 1 %} + {% assign pr_num = pr_number[1] | split: " " | first %} + {% assign clickable_line = before_url | append: " in [#" | append: pr_num | append: "](" | append: url | append: ")" %} + {% assign processed_lines = processed_lines | append: clickable_line | append: " " %} -{% else %} -{% assign processed_lines = processed_lines | append: line | append: " + {% else %} + {% assign processed_lines = processed_lines | append: line | append: " " %} -{% endif %} -{% else %} -{% assign processed_lines = processed_lines | append: line | append: " + {% endif %} + {% else %} + {% assign processed_lines = processed_lines | append: line | append: " " %} -{% endif %} -{% else %} -{% assign processed_lines = processed_lines | append: line | append: " + {% endif %} + {% else %} + {% assign processed_lines = processed_lines | append: line | append: " " %} -{% endif %} + {% endif %} {% endfor %} -{% comment %} Check if there are any bullet points (actual release notes) {% endcomment %} -{% if processed_lines contains "## " or processed_lines contains "- " %} -{% assign spaced_content = processed_lines | replace: " +{% comment %} Add proper spacing between sections and bullet points {% endcomment %} +{% assign final_content = processed_lines | replace: " +### ", " +### " %} +{% assign final_content = final_content | replace: " +## ", " + +## " %} +{% assign final_content = final_content | replace: " - ", " - " %} - {{ spaced_content | markdownify }} - {% else %} - *No release notes available.* - {{ processed_lines | markdownify }} - {% endif %} +{% comment %} Check if there are any bullet points (actual release notes) {% endcomment %} +{% if final_content contains "## " or final_content contains "- " %} + {{ final_content | markdownify }} +{% else %} + *No release notes available.* + + {{ final_content | markdownify }} +{% endif %} --- {% endfor %} \ No newline at end of file