mirror of
https://github.com/SouthFox-D/SouthFox-D.github.io.git
synced 2025-01-18 06:46:20 +01:00
[feat] build font subset file
This commit is contained in:
parent
5050ca1d4c
commit
1bcd7de0d0
1 changed files with 21 additions and 2 deletions
23
utils.hy
23
utils.hy
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env hy
|
||||
(import requests)
|
||||
|
||||
(import argparse)
|
||||
(import sys)
|
||||
(import os)
|
||||
(import json)
|
||||
|
@ -18,6 +19,24 @@
|
|||
(let [file (os.path.join root -file)]
|
||||
(when (and (in "posts" file) (file.endswith ".md"))
|
||||
(markdown-files.append file))))
|
||||
(print markdown-files))
|
||||
(return markdown-files))
|
||||
|
||||
(get-post-files)
|
||||
(defn subset-font-file [post-files]
|
||||
(let [str-set #{}]
|
||||
(for [f post-files]
|
||||
(with [o (open f "r" :encoding "utf-8")]
|
||||
(for [w (o.read)]
|
||||
(str-set.add w))))
|
||||
|
||||
(print f"{(len str-set)} characters in all files.")
|
||||
(print (.join "" str-set))
|
||||
(with [f (open "strdb.txt" "w")]
|
||||
(f.write (.join "" str-set)))))
|
||||
|
||||
(setv parser (argparse.ArgumentParser))
|
||||
(parser.add_argument "-d" :dest "deploy" :action "store_true")
|
||||
(setv args (parser.parse_args))
|
||||
|
||||
(when args.deploy
|
||||
(let [post-files (get-post-files)]
|
||||
(subset-font-file post-files)))
|
||||
|
|
Loading…
Reference in a new issue