mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-05 20:40:18 -08:00
Add read time to all pages
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||

|
||||
|
||||
{{#include ./banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user