Changeset 15505 in project
- Timestamp:
- 08/17/09 04:38:34 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
release/4/qwiki/trunk/qwiki-sxml.scm
r15504 r15505 43 43 (import chicken scheme) 44 44 45 (use posix srfi-1 srfi-13 data-structures regex )45 (use posix srfi-1 srfi-13 data-structures regex ) 46 46 (use sxml-transforms doctype uri-generic) 47 47 … … 237 237 "\\end{" env-name "}" nl)) 238 238 239 (define (LaTeX-use-package package-name options)239 (define (LaTeX-use-package package-name . options) 240 240 (list "\\usepackage{" package-name "}" 241 241 (if (pair? options) (list "[" options "]") '()) 242 242 nl)) 243 244 (define (LaTeX-label str) 245 (define (f0 str) 246 (let* ((cs (string-split str " ")) 247 (ins (map (lambda (s) 248 (let ((s (string-downcase s))) 249 (string-copy s 0 (min 3 (- (string-length s) 1))))) cs))) 250 (string-concatenate ins))) 251 (cond ((pair? str) (string-concatenate (map f0 str))) 252 (else (f0 (->string str))))) 243 253 244 254 (define (qwiki-LaTeX-transformation-rules content) … … 300 310 ((4) "subsubsection") 301 311 (else (error "unsupported section level: " level))) 302 "{" head-word elems "}" nl))) 312 "{" head-word elems "}" nl 313 (if (= level 1) 314 (list "\\label{" (LaTeX-label head-word) "}") 315 (list)) nl))) 303 316 304 317 (TOC . ,(lambda (tag . elems) (list nl "\\tableofcontents{}" nl))) … … 321 334 . ,(lambda (tag href . contents) 322 335 (add-LaTeX-package! 'hyperref "hypertex") 323 `("\\href{" (href ,href) "}" 324 "{" ,(if (pair? contents) contents href) "}"))) 336 `((tex "\\hyperref[" ,(LaTeX-label href) "]") 337 (tex "{") 338 ,(if (null? contents) href (or contents href)) 339 (tex "}")))) 325 340 326 341 ; Standard typography 342 (small 343 . ,(lambda (tag . elems) 344 (list "{\\small{}" elems "}"))) 345 346 (strong 347 . ,(lambda (tag . elems) 348 (list "{\\rmfamily\\bfseries{}" elems "}"))) 349 350 (type 351 . ,(lambda (tag . elems) 352 (list "{\\ttfamily{}" elems "}"))) 353 327 354 (em 328 355 . ,(lambda (tag . elems) … … 340 367 . ,(lambda (tag) 341 368 (list "\\\\ "))) 369 370 (hr . ,(lambda (tag) 371 (list "\\begin{center}" 372 "\\rule{0.8\\textwidth}{0.4pt}" 373 "\\end{center}" nl))) 342 374 343 375 (indent … … 384 416 385 417 386 (blockquote387 . ,(lambda (tag . elems)388 (in-LaTeX-env "quote" '() elems)))389 390 (definition391 *macro*392 . ,(lambda (_ type . contents)393 (in-LaTeX-env "description" '()394 `(type ,@contents))))395 396 418 (special 397 419 *macro* … … 399 421 `(,(string->symbol (string-upcase (symbol->string name))) ,arg))) 400 422 423 (definition 424 . ,(lambda (_ type . elems) 425 (in-LaTeX-env "description" '() 426 (list "{\\ttfamily{}" elems "}")))) 427 428 (blockquote 429 . ,(lambda (tag . elems) 430 (in-LaTeX-env "quote" '() elems))) 431 401 432 (preformatted 402 433 *macro* … … 404 435 `(verbatim ,elems))) 405 436 406 (type407 *macro*408 . ,(lambda (tag . terms)409 `("\\begin{texttt}" ,@terms "\\end{texttt}")))410 411 437 412 438 (verbatim ; set off pieces of code: one or several lines … … 624 650 625 651 626 (small627 . ,(lambda (tag . elems)628 (list "{\\small{}" elems "}")))629 630 (strong631 . ,(lambda (tag . elems)632 (list "{\\rmfamily\\bfseries{}" elems "}")))633 634 652 (history . ,(lambda (history items) (list))) 635 653 (page-specific-links . ,(lambda _ (list))) … … 637 655 (tex ; raw tex expression 638 656 *preorder* 639 . ,(lambda (tag str) str))657 . ,(lambda (tag . str) str)) 640 658 641 659 )))
Note: See TracChangeset
for help on using the changeset viewer.