about summary refs log tree commit diff stats
path: root/src/html/entity.nim
blob: 72c5c4524bfb177a976b2c7ef8db38c46a9c8bb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import json

import ../utils/radixtree

const entity = staticRead"../../res/entity.json"
proc genEntityMap(data: seq[tuple[a: string, b: string]]): RadixNode[string] =
  result = newRadixTree[string]()
  for pair in data:
    result[pair.a] = pair.b

proc genEntityTable(): seq[tuple[a: string, b: string]] =
  let entityJson = parseJson(entity)

  for k, v in entityJson:
    result.add((k.substr(1), v{"characters"}.getStr()))
const entityTable = genEntityTable()
let entityMap* = genEntityMap(entityTable)