File size: 2,843 Bytes
4878ed5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#tableofcontentmaker
intro = """
<details>
  <summary>Table of Contents</summary>
  <ol>
"""

outro = """
    </li>
  </ol>
</details>
"""

tableofcontents = """
- [Installation](#installation)
- [About](#about)
- [Example](#example)
- [Syntax](#syntax)
    - [Hashtag](#hashtag)
    - [Links](#links)
    - [Double Hashtag](#double-hashtag)
    - [Others](#others)
  - [Valid Hashtags](#valid-hashtags)
  - [How to get the direct links (Important!)](#how-to-get-the-direct-links-important)
  - [Huggingface's download method](#huggingfaces-download-method)
- [Additional Syntax](#additional-syntax)
  - [Rename Downloaded Files](#rename-downloaded-files)
  - [Running Shell Commands](#running-shell-commands)
  - [Extract Everyting (`@extract`)](#extract-everyting-extract)
  - [Custom Hashtag Path (`@new`)](#custom-hashtag-path-new)
  - [Custom Direct Link Download with `aria2` (`@aria2`)](#custom-direct-link-download-with-aria2-aria2)
- [Gradio Queue](#gradio-queue)
  - [Logging](#logging)
  - [Cancel](#cancel)
  - [Progress Bar](#progress-bar)
  - [Changes if `--gradio-queue` is off](#changes-if---gradio-queue-is-off)
- [Other Features](#other-features)
  - [Notification](#notification)
  - [Copy From Pastebin](#copy-from-pastebin)
  - [SDless mode](#sdless-mode)
  - [Local Installation Support](#local-installation-support)
  - [Debug Mode (Developer only)](#debug-mode-developer-only)
- [Release Notes](#release-notes)
- [Roadmap](#roadmap)
- [Known Bugs](#known-bugs)
  - [Known Fixed Bugs](#known-fixed-bugs)
- [Contributing](#contributing)
- [Contact](#contact)
- [Acknowledgments](#acknowledgments)
"""

def mlineprint(toprint):
    if toprint[-1] == '\n':
        toprint = toprint[:-1]
    print(toprint.replace('\n', '', 1))


def writehtmllist(space, namehead, hashtaghead):
    spaces = ""
    for _ in range(space):
        spaces += " "
    if initialspace >= 2:
        return spaces + f'<ul><li><a href="{hashtaghead}">{namehead}</a></li></ul>'
    else:
        return spaces + f'<li><a href="{hashtaghead}">{namehead}</a></li>'

if __name__ == "__main__":
    rows = tableofcontents.replace('\n', '', 1).splitlines()#split('\n')  # split into a list of rows
    mlineprint(intro)
    for row in rows:
        if not row == '':
            initialspace = 0
            for char in row:
                if char == ' ':
                    initialspace += 1
                else:
                    break
            extractedrow = row.split("[")
            cuttedrow = extractedrow[1].partition("](")
            headingname = cuttedrow[0]
            headinghashtag = cuttedrow[2].rstrip(")")
            print(writehtmllist(initialspace+4, headingname, headinghashtag))
            # print(cuttedrow[0])
            # print(cuttedrow[2].rstrip(")"))
            # hashtagrow = row.partit
    mlineprint(outro)