29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
import os
|
|
import re
|
|
|
|
files = ['kemiskinan.html', 'spbu.html', 'jalan.html', 'persil.html']
|
|
|
|
for file in files:
|
|
with open(file, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# 1. Remove nav-tabs block
|
|
# Use regex to find and remove the div with class="nav-tabs" and its contents
|
|
nav_tabs_pattern = re.compile(r'<div class="nav-tabs"[^>]*>.*?</div>', re.DOTALL)
|
|
content = nav_tabs_pattern.sub('', content)
|
|
|
|
# 2. Add back button in panel-head
|
|
panel_head_str = '<div id="panel-head">\n <h2 id="panel-title">'
|
|
back_btn_html = '''<div id="panel-head">
|
|
<a href="index.html" class="btn btn-ghost btn-sm" style="margin-bottom: 12px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none;">
|
|
<span style="font-size: 14px;">←</span> Kembali ke Beranda
|
|
</a>
|
|
<h2 id="panel-title">'''
|
|
|
|
# Only replace if not already replaced
|
|
if 'Kembali ke Beranda' not in content:
|
|
content = content.replace(panel_head_str, back_btn_html)
|
|
|
|
with open(file, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|