Add read time to all pages

This commit is contained in:
Congon4tor
2025-01-03 02:52:56 +01:00
parent 7a0a0329a7
commit c520826284
2 changed files with 7 additions and 7 deletions

View File

@@ -67,6 +67,12 @@ def ref(matchobj):
return result
def add_read_time(content):
regex = r'(# .*(?=\n))'
new_content = re.sub(regex, lambda x: x.group(0) + "\n\nReading time: {{ #reading_time }}", content)
return new_content
def iterate_chapters(sections):
if isinstance(sections, dict) and "PartTitle" in sections: # Not a chapter section
return
@@ -91,12 +97,12 @@ if __name__ == '__main__':
logger.debug(f"Context: {context}")
for chapter in iterate_chapters(book['sections']):
logger.debug(f"Chapter: {chapter['path']}")
current_chapter = chapter
regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}'
new_content = re.sub(regex, ref, chapter['content'])
new_content = add_read_time(new_content)
chapter['content'] = new_content
content = json.dumps(book)

View File

@@ -1,7 +1,5 @@
# HackTricks Cloud
Reading time: {{ #reading_time }}
{{#include ./banners/hacktricks-training.md}}
<figure><img src="images/cloud.gif" alt=""><figcaption></figcaption></figure>
@@ -34,7 +32,3 @@ _Hacktricks logos & motion designed by_ [_@ppiernacho_](https://www.instagram.co
![HackTricks Cloud Github Stats](https://repobeats.axiom.co/api/embed/1dfdbb0435f74afa9803cd863f01daac17cda336.svg)
{{#include ./banners/hacktricks-training.md}}