m-ric HF staff commited on
Commit
5582229
β€’
1 Parent(s): 07a76f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -17,7 +17,6 @@ if torch.cuda.is_available():
17
 
18
  STYLE = """
19
  .custom-container {
20
- width: 100%;
21
  display: grid;
22
  align-items: center;
23
  margin: 0!important;
@@ -29,6 +28,10 @@ STYLE = """
29
  .prose li {
30
  margin-bottom: 0!important;
31
  }
 
 
 
 
32
  .prose td, th {
33
  padding-left: 2px;
34
  padding-right: 2px;
@@ -46,6 +49,12 @@ STYLE = """
46
  text-align: center;
47
  display:inline-block;
48
  }
 
 
 
 
 
 
49
  .tree ul {
50
  padding-left: 20px;
51
  position: relative;
@@ -80,7 +89,7 @@ STYLE = """
80
  }
81
  .tree li::after {
82
  top: 50%;
83
- height: 70%;
84
  bottom: auto;
85
  border-top: 1px solid var(--body-text-color);
86
  }
@@ -118,12 +127,14 @@ STYLE = """
118
  .tree li a {
119
  border: 1px solid var(--body-text-color);
120
  padding: 5px;
121
- display: inline-grid;
122
  border-radius: 5px;
123
  text-decoration-line: none;
124
  border-radius: 5px;
125
  transition: .5s;
126
- width: 200px;
 
 
 
127
  }
128
  .tree li a span {
129
  padding: 5px;
@@ -141,20 +152,21 @@ STYLE = """
141
  }
142
  .chosen {
143
  background-color: #ea580c;
 
144
  }
145
  """
146
 
147
 
148
- def generate_nodes(token, node):
149
  """Recursively generate HTML for the tree nodes."""
150
 
151
- html_content = f" <li> <a href='#' class={('chosen' if node.table is None else '')}> <span> <b>{token}</b> </span> "
152
  html_content += node.table if node.table is not None else ""
153
  html_content += "</a>"
154
  if len(node.children.keys()) > 0:
155
  html_content += "<ul> "
156
  for token, subnode in node.children.items():
157
- html_content += generate_nodes(token, subnode)
158
  html_content += "</ul>"
159
  html_content += "</li>"
160
  return html_content
 
17
 
18
  STYLE = """
19
  .custom-container {
 
20
  display: grid;
21
  align-items: center;
22
  margin: 0!important;
 
28
  .prose li {
29
  margin-bottom: 0!important;
30
  }
31
+ .prose table {
32
+ margin-bottom: 0!important;
33
+ }
34
+
35
  .prose td, th {
36
  padding-left: 2px;
37
  padding-right: 2px;
 
49
  text-align: center;
50
  display:inline-block;
51
  }
52
+
53
+ #root {
54
+ display: inline-grid!important;
55
+ width:auto!important;
56
+ }
57
+
58
  .tree ul {
59
  padding-left: 20px;
60
  position: relative;
 
89
  }
90
  .tree li::after {
91
  top: 50%;
92
+ height: 55%;
93
  bottom: auto;
94
  border-top: 1px solid var(--body-text-color);
95
  }
 
127
  .tree li a {
128
  border: 1px solid var(--body-text-color);
129
  padding: 5px;
 
130
  border-radius: 5px;
131
  text-decoration-line: none;
132
  border-radius: 5px;
133
  transition: .5s;
134
+ width: 260px;
135
+ display: flex;
136
+ align-items: center;
137
+ justify-content: space-around;
138
  }
139
  .tree li a span {
140
  padding: 5px;
 
152
  }
153
  .chosen {
154
  background-color: #ea580c;
155
+ width:auto!important;
156
  }
157
  """
158
 
159
 
160
+ def generate_nodes(token, node, step=0):
161
  """Recursively generate HTML for the tree nodes."""
162
 
163
+ html_content = f" <li> <a href='#' class='{('chosen' if node.table is None else '')}' id='{('root' if step==0 else '')}'> <span> <b>{token}</b> </span> "
164
  html_content += node.table if node.table is not None else ""
165
  html_content += "</a>"
166
  if len(node.children.keys()) > 0:
167
  html_content += "<ul> "
168
  for token, subnode in node.children.items():
169
+ html_content += generate_nodes(token, subnode, step=step + 1)
170
  html_content += "</ul>"
171
  html_content += "</li>"
172
  return html_content