Last active
March 21, 2021 12:01
-
-
Save shhyou/21e4f264a541a0848ad329bc22d2236e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang pollen | |
◊(define lam "\\lambda") | |
$◊lam_k\\nabla g_k(x)$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(module setup racket/base | |
(require (for-template "tex-top.rkt")) | |
(provide allow-unbound-ids?) | |
(define allow-unbound-ids? #'tex-top) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{amsmath} | |
\begin{document} | |
% from Pollen tutorial | |
◊(require racket/list) | |
◊(apply string-append (filter string? (flatten doc))) | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require (for-syntax racket/base racket/syntax racket/string) | |
(only-in txexpr [txexpr tex-wrapper-txexpr]) | |
pollen/tag) | |
(provide tex-top | |
(for-syntax tex-top-wrapper)) | |
(define-syntax (tex-top stx) | |
(syntax-case stx () | |
[(_ . ID) | |
(tex-top-wrapper #'ID)])) | |
(define-for-syntax (tex-top-wrapper stx) | |
(define id (symbol->string (syntax-e stx))) | |
(define has-underscore-or-caret? | |
(for/first ([i (in-naturals)] | |
[c (in-string id)] | |
#:when (or (char=? #\_ c) (char=? #\^ c) (char=? #\. c))) | |
i)) | |
(cond | |
[(and has-underscore-or-caret? (< 0 has-underscore-or-caret?)) | |
(define prefix | |
(format-id stx "~a" (substring id 0 has-underscore-or-caret?))) | |
(define suffix | |
(substring id has-underscore-or-caret?)) | |
#`(tex-wrapper-txexpr '@ '() | |
(list (def/c . #,prefix) | |
'#,suffix))] | |
[else | |
#`(default-tag-function '#,stx)])) | |
(define-syntax (def/c stx) | |
(syntax-case stx () | |
[(_ . ID) | |
(identifier-binding #'ID) | |
#'ID] | |
[(_ . ID) | |
#'(#%top . ID)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment