utils: read-org-table -> read-org-sexp.
This commit is contained in:
parent
a9fc272c13
commit
dbfa560081
2 changed files with 6 additions and 6 deletions
|
@ -46,7 +46,7 @@
|
|||
(check-equal? (hash-ref mp 'b) "(not b)"))
|
||||
(check-equal? (string->any "(or b (not a))") '(or b (not a)))
|
||||
(check-equal? (string->any "14") 14)
|
||||
(check-equal? (read-org-table "((\"a\" \"(and a b)\") (\"b\" \"(or b (not a))\"))")
|
||||
(check-equal? (read-org-sexp "((\"a\" \"(and a b)\") (\"b\" \"(or b (not a))\"))")
|
||||
'(("a" "(and a b)") ("b" "(or b (not a))")))
|
||||
(check-equal? (unstringify-pairs '(("a" . "1") ("b" . "(and a (not b))")))
|
||||
'((a . 1) (b . (and a (not b)))))
|
||||
|
|
10
utils.rkt
10
utils.rkt
|
@ -15,7 +15,7 @@
|
|||
[any->string (-> any/c string?)]
|
||||
[stringify-variable-mapping (-> variable-mapping? string-variable-mapping?)]
|
||||
[string->any (-> string? any/c)]
|
||||
[read-org-table (-> string? (listof any/c))]
|
||||
[read-org-sexp (-> string? (listof any/c))]
|
||||
[unstringify-pairs (-> (listof (general-pair/c string? any/c))
|
||||
(listof (general-pair/c symbol? any/c)))]
|
||||
[read-org-variable-mapping (-> string? variable-mapping?)]
|
||||
|
@ -183,9 +183,9 @@
|
|||
(define (string->any str)
|
||||
(with-input-from-string str (λ () (read))))
|
||||
|
||||
;;; Reads a table from a string produced by Org-mode for a named
|
||||
;;; table. See example.org for examples.
|
||||
(define (read-org-table str) (string->any str))
|
||||
;;; Reads a sexp from a string produced by Org-mode for a named table.
|
||||
;;; See example.org for examples.
|
||||
(define (read-org-sexp str) (string->any str))
|
||||
|
||||
;;; A contract allowing pairs constructed via cons or via list.
|
||||
(define (general-pair/c key-contract val-contract)
|
||||
|
@ -211,7 +211,7 @@
|
|||
;;; Reads a variable mapping from a string, such as the one which
|
||||
;;; Org-mode produces from tables.
|
||||
(define (read-org-variable-mapping str)
|
||||
(make-hash (unstringify-pairs (read-org-table str))))
|
||||
(make-hash (unstringify-pairs (read-org-sexp str))))
|
||||
|
||||
;;; A synonym for read-org-variable-mapping.
|
||||
(define-syntax-rule (unorg str) (read-org-variable-mapping str))
|
||||
|
|
Loading…
Reference in a new issue