Skip to content

Instantly share code, notes, and snippets.

@shhyou
Created April 2, 2021 19:58
Show Gist options
  • Save shhyou/820847a4c5d99d4ad64a7853e75de1ba to your computer and use it in GitHub Desktop.
Save shhyou/820847a4c5d99d4ad64a7853e75de1ba to your computer and use it in GitHub Desktop.
#lang pollen
◊(define lam "\\lambda")
$◊lam x . \, ◊mathit{function \, body}$
◊textnormal{◊textbf unapplied text command}
#lang pollen
◊(define lam "\\lambda")
$◊lam x . \, ◊mathit{function \, body}$
#lang racket/base
(module setup racket/base
(require (for-template "top-with-loc.rkt"))
(provide allow-unbound-ids?)
(define allow-unbound-ids? #'top-with-loc)
)
(require (for-syntax racket/base)
"top-with-loc.rkt")
(provide
(rename-out [checked-unbound-id-app #%app]))
(define-syntax (checked-unbound-id-app stx)
(syntax-case stx ()
[(_ id . args)
#'(#%app checked-app id . args)]
[(_ . args)
#'(#%app . args)]))
(define (checked-app proc . args)
(for ([arg (in-list args)])
;; logs problematic tags (with source location)
(when (default-tag-function-with-loc? arg)
(log-error "~a: unapplied tag function: ~s"
(default-tag-function-with-loc-src arg)
(default-tag-function-with-loc-proc arg))))
(apply proc args))
\documentclass{article}
\usepackage{amsmath}
\begin{document}
◊(require racket/match)
◊(apply string-append
;; (cdr doc) drops 'root
(let tex-traverse ([elems (cdr doc)])
(apply append
(for/list ([elem (in-list elems)])
(match elem
[(? string? literal)
(list literal)]
[(cons (? symbol? tex-cmd) args)
`("\\"
,(symbol->string tex-cmd)
"{"
,@(tex-traverse args)
"}")])))))
\end{document}
#lang racket/base
(require (for-syntax racket/base)
syntax/location
pollen/tag)
(provide top-with-loc
(struct-out default-tag-function-with-loc))
(struct default-tag-function-with-loc (proc src)
#:property prop:procedure (struct-field-index proc))
(define (make-default-tag-function-with-loc id src-string)
(default-tag-function-with-loc
(default-tag-function id)
src-string))
(define-syntax (top-with-loc stx)
(syntax-case stx ()
[(_ . ID)
#`(make-default-tag-function-with-loc 'ID (quote-srcloc-string ID))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment