[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9b47ab5 13/29: Add build utilities to the repo
From: |
Vitalie Spinu |
Subject: |
[elpa] master 9b47ab5 13/29: Add build utilities to the repo |
Date: |
Tue, 7 May 2019 13:18:02 -0400 (EDT) |
branch: master
commit 9b47ab5d6b444c55a7a0378f0235ffd98c5c648f
Author: Vitalie Spinu <address@hidden>
Commit: Vitalie Spinu <address@hidden>
Add build utilities to the repo
---
msl-build.el | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/msl-build.el b/msl-build.el
new file mode 100644
index 0000000..2c690f2
--- /dev/null
+++ b/msl-build.el
@@ -0,0 +1,115 @@
+;; functions to build symbol lists
+
+(require 'cl)
+
+;; IMPORT UTILITIES
+;;
+;; Utilities for reading LUCR list from [1] and optionally PRINT. LUCR list is
a
+;; super-set of unicode-math list [2]. FILE is a local file from [3].
+;;
+;; [1] http://milde.users.sourceforge.net/LUCR/Math/
+;; [2] https://github.com/wspr/unicode-math/blob/master/unicode-math-table.tex
+;; [3] http://milde.users.sourceforge.net/LUCR/Math/data/unimathsymbols.txt
+
+(defun msl--LUCR-parse-alias (str)
+ ;; (msl--LUCR-parse-alias "= \\Theta (-slantedGreek)")
+ ;; (msl--LUCR-parse-alias "= \\mathrm{\\Theta}")
+ (when (and str (msl--no-{}-p str))
+ (if (string-match " ?= ?\\(\\\\[^() ]+\\) *$" str)
+ (cons (match-string 1 str) "latex")
+ (if (string-match " ?= ?\\(\\\\[^() ]+\\) *(\\(.+\\)) *$" str)
+ (cons (match-string 1 str) (match-string 2 str))))))
+
+(defun msl--LUCR-parse-line (line)
+ (let* ((words (split-string line "\\^"))
+ (comment (nth 7 words))
+ (aliases (when comment
+ (delq nil
+ (mapcar #'msl--LUCR-parse-alias
+ (split-string comment ", *")))))
+ (packages (when (> (length (nth 6 words)) 0)
+ (split-string (nth 6 words) " +")))
+ (usymb (nth 1 words)))
+ (when (> (length usymb) 0)
+ (list (nth 0 words) ;; 0: HEX Code
+ (when (> (length usymb) 0)
+ (substring usymb -1)) ;; 1: Unicode Symbol
+ (nth 2 words) ;; 2: La(TeX) command
+ (nth 3 words) ;; 3: unicode-math package command
+ (nth 4 words) ;; 4: Class
+ (nth 5 words) ;; 5: category
+ packages ;; 6: packages (prefixed with _
are conflicts)
+ aliases)))) ;; 7: aliases (conses of (alias
. package))
+
+(defun msl--no-{}-p (str)
+ (not (string-match "[{}]" str)))
+
+(defun msl--LUCR-read-file (file)
+ (let ((lines (with-temp-buffer
+ (insert-file-contents file)
+ (split-string (buffer-string) "\n" t))))
+ (delq nil
+ (cl-loop for l in lines
+ unless (string-match-p "^#" l)
+ collect (msl--LUCR-parse-line l)))))
+
+(defun msl--LUCR-to-msl (lucr &optional latex alias no-parse)
+ "Convert LUCR list to this package conventions.
+If LATEX is non-nil, give package and latex command instead of
+unicode-math command. If ALIAS is non-nil give package and latex
+command from alias field. "
+ (flet ((code (el) (if no-parse (car el) (string-to-number (car el) 16))))
+ (let ((sl (delq nil
+ (cond
+ (latex (mapcan (lambda (el)
+ (and (> (length (nth 2 el)) 0)
+ (> (length (nth 6 el)) 0)
+ (msl--no-{}-p (nth 2 el))
+ (mapcar (lambda (pkg)
+ (list pkg (nth 5 el) (nth
2 el) (code el) (nth 1 el)))
+ (nth 6 el))))
+ lucr))
+ (alias (mapcan (lambda (el)
+ (mapcan (lambda (pkg)
+ (and (> (length (car pkg)) 0)
+ (msl--no-{}-p (car pkg))
+ (mapcar (lambda (pkg2)
+ (list pkg2 (nth
5 el) (car pkg) (code el) (nth 1 el)))
+ (split-string
(cdr pkg) " +"))))
+ (nth 7 el)))
+ lucr))
+ (t (mapcar (lambda (el)
+ (and (string-match-p "\\\\" (nth 3 el))
+ (list (nth 5 el) (nth 3 el) (code el)
(nth 1 el))))
+ lucr))))))
+ (when (or latex alias)
+ (setq sl (mapcar (lambda (el)
+ (if (not (string-match-p "^-" (car el)))
+ el
+ (append (list (substring (car el) 1)) (cdr el)
(list t))))
+ sl)))
+ (cl-sort sl (lambda (a b) (string-lessp (concat (car a) (cadr a))
(concat (car b) (cadr b))))))))
+
+(defun msl--LUCR-filter-LaTeX-aliases (list)
+ (delq nil
+ (mapcar (lambda (el)
+ (when (cl-some (lambda (al)
+ (and (string= "latex" (cdr al))
+ (msl--no-{}-p (car al))))
+ (nth 7 el))
+ el))
+ list)))
+
+;; this is how you build those
+(setq tt (msl--LUCR-read-file "./data/unimathsymbols.txt"))
+
+;; extra aliases for basic symbols
+(setq tt2 (msl--LUCR-filter-LaTeX-aliases tt))
+(msl--LUCR-to-msl tt2 nil t)
+
+;; extended
+(msl--LUCR-to-msl tt)
+;; packages
+(msl--LUCR-to-msl tt t)
+;; aliases
+(msl--LUCR-to-msl tt nil t)
- [elpa] master 7517661 19/29: Docs, (continued)
- [elpa] master 7517661 19/29: Docs, Vitalie Spinu, 2019/05/07
- [elpa] master 1af8fdc 21/29: Version 1.2, Vitalie Spinu, 2019/05/07
- [elpa] master 4999869 24/29: Version 1.2.1, Vitalie Spinu, 2019/05/07
- [elpa] master e15ec26 22/29: Add PILCROW symbol, Vitalie Spinu, 2019/05/07
- [elpa] master 5804a3e 28/29: [math-symbol-lists] Merge commit 'dbf4a6d26', Vitalie Spinu, 2019/05/07
- [elpa] master dbf4a6d 23/29: Fix checkdoc, Vitalie Spinu, 2019/05/07
- [elpa] master 5631998 08/29: Add "left" to math-symbol-list-latex-commands, Vitalie Spinu, 2019/05/07
- [elpa] master 0f96612 04/29: Add autoloads, Vitalie Spinu, 2019/05/07
- [elpa] master 216b009 09/29: Add .dir-locals and update .gitignore, Vitalie Spinu, 2019/05/07
- [elpa] master 3eea8b2 15/29: Clarify docs of math-symbol-list-packages, Vitalie Spinu, 2019/05/07
- [elpa] master 9b47ab5 13/29: Add build utilities to the repo,
Vitalie Spinu <=
- [elpa] master 6d2ba0a 20/29: [Fix #5] Add subscript and superscripts lists, Vitalie Spinu, 2019/05/07
- [elpa] master 894a486 29/29: [math-symbol-lists] Merge from upstream, Vitalie Spinu, 2019/05/07
- [elpa] master a4bc5cf 25/29: Add copyright and license, Vitalie Spinu, 2019/05/07
- [elpa] master f5eea51 27/29: Document variables, Vitalie Spinu, 2019/05/07
- [elpa] master 5bf2a05 17/29: Add W3C source, Vitalie Spinu, 2019/05/07
- [elpa] master b5d6673 02/29: Add symbols, Vitalie Spinu, 2019/05/07
- [elpa] master 3715961 16/29: Update readme, Vitalie Spinu, 2019/05/07
- [elpa] master 335bbf8 14/29: Fix inconsistent formatting of the base list, Vitalie Spinu, 2019/05/07
- [elpa] master abe59e0 26/29: Mark as simple package, Vitalie Spinu, 2019/05/07
- [elpa] master e8c8fb0 10/29: Base extended Unicode list on LUCR database, Vitalie Spinu, 2019/05/07