idolezal commited on
Commit
ff6fff7
β€’
1 Parent(s): f3684c5

Markdown esacape

Browse files
Files changed (1) hide show
  1. server.py +21 -1
server.py CHANGED
@@ -22,6 +22,26 @@ REPO = f"{ORG}/LLM_benchmark_data"
22
  HF_TOKEN = os.environ.get("HF_TOKEN")
23
  TASKS_METADATA_PATH = "./tasks_metadata.json"
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  class LeaderboardServer:
26
  def __init__(self):
27
  self.server_address = REPO
@@ -111,7 +131,7 @@ class LeaderboardServer:
111
  model_link = data["metadata"]["link_to_model"]
112
  model_title = data["metadata"]["team_name"] + "/" + data["metadata"]["model_name"]
113
  model_title_abbr = self.abbreviate(data["metadata"]["team_name"], 14) + "/" + self.abbreviate(data["metadata"]["model_name"], 14)
114
- local_results["model"] = f'<a href={xmlQuoteAttr(model_link)} title={xmlQuoteAttr(model_title)}>{xmlEscape(model_title_abbr)}</a>' # TODO: Markdown esacape
115
  release = data["metadata"].get("submission_timestamp")
116
  release = time.strftime("%Y-%m-%d", time.gmtime(release)) if release else "N/A"
117
  local_results["release"] = release
 
22
  HF_TOKEN = os.environ.get("HF_TOKEN")
23
  TASKS_METADATA_PATH = "./tasks_metadata.json"
24
 
25
+ MARKDOWN_SPECIAL_CHARACTERS = {
26
+ "#": "&#35;", # for usage in xml.sax.saxutils.escape as entities must be first
27
+ "\\": "&#92;",
28
+ "`": "&#96;",
29
+ "*": "&#42;",
30
+ "_": "&#95;",
31
+ "{": "&#123;",
32
+ "}": "&#125;",
33
+ "[": "&#91;",
34
+ "]": "&#93;",
35
+ "(": "&#40;",
36
+ ")": "&#41;",
37
+ "+": "&#43;",
38
+ "-": "&#45;",
39
+ ".": "&#46;",
40
+ "!": "&#33;",
41
+ "=": "&#61;",
42
+ "|": "&#124;"
43
+ }
44
+
45
  class LeaderboardServer:
46
  def __init__(self):
47
  self.server_address = REPO
 
131
  model_link = data["metadata"]["link_to_model"]
132
  model_title = data["metadata"]["team_name"] + "/" + data["metadata"]["model_name"]
133
  model_title_abbr = self.abbreviate(data["metadata"]["team_name"], 14) + "/" + self.abbreviate(data["metadata"]["model_name"], 14)
134
+ local_results["model"] = f'<a href={xmlQuoteAttr(model_link)} title={xmlQuoteAttr(model_title)}>{xmlEscape(model_title_abbr, MARKDOWN_SPECIAL_CHARACTERS)}</a>'
135
  release = data["metadata"].get("submission_timestamp")
136
  release = time.strftime("%Y-%m-%d", time.gmtime(release)) if release else "N/A"
137
  local_results["release"] = release