about summary refs log blame commit diff stats
path: root/src/html/entity.nim
blob: f2f55277a3fd0bd5ca3ce27978e3baf5952432d5 (plain) (tree)
1
2
3
4
5
6
7
8
9
           
 
                      
 
                                          
                                                                                

                                 
                             
 
                                                           
                                    
 
                         
                                                                         

                                          
import json

import utils/radixtree

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

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

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