|
100 | 100 | (lambda (x) |
101 | 101 | (cond ((tm-is? x 'date) (second x)) |
102 | 102 | ((tm-is? x 'tuple) |
103 | | - (string-append "\n" (list->yaml (cdr x) 2))) |
| 103 | + (string-append "\n" (list->yaml (list-sort (cdr x) string<=?) 2))) |
104 | 104 | ((tuple? x) (string-append "\n" (list->yaml x 2))) |
105 | 105 | ((bool? x) x) |
106 | 106 | ((string? x) (string-quote x))))) ; quote everything else |
|
196 | 196 | (define (md-doc-title x) |
197 | 197 | (with title (md-string (serialize-markdown* (cdr x))) |
198 | 198 | (if (hugo-extensions?) |
199 | | - (md-hugo-frontmatter `(hugo-front "title" ,title)) |
200 | | - title))) |
| 199 | + (serialize-markdown* `(hugo-front "title" ,title)) |
| 200 | + (serialize-markdown* `(document ,title ""))))) |
201 | 201 |
|
202 | 202 | (define (md-doc-subtitle x) |
203 | | - (display "FIXME: append subtitle to title") |
204 | 203 | (with subtitle (md-string (serialize-markdown* (cdr x))) |
205 | 204 | (if (hugo-extensions?) |
206 | | - (md-hugo-frontmatter `(hugo-front "subtitle" ,subtitle)) |
207 | | - subtitle))) |
| 205 | + (serialize-markdown* `(hugo-front "subtitle" ,subtitle)) |
| 206 | + (serialize-markdown* `(document ,subtitle))))) |
208 | 207 |
|
209 | 208 | (define (md-doc-author x) |
210 | 209 | ; TODO? We might want to extract other info |
|
235 | 234 | (define (md-abstract x) |
236 | 235 | (if (hugo-extensions?) |
237 | 236 | (md-hugo-frontmatter `(hugo-front "summary" ,(serialize-markdown* (cdr x)))) |
238 | | - (md-document (md-style `(em ,(cdr x)))))) |
| 237 | + (md-paragraph `(concat (strong "Abstract: ") (em ,(cdr x)))))) |
239 | 238 |
|
240 | 239 | (define (md-paragraph p) |
241 | 240 | ;; FIXME: arguments of Hugo shortcodes shouldn't be split |
|
430 | 429 | (alt (if (list-2? payload) (second payload) ""))) |
431 | 430 | (string-append " ")"))) |
432 | 431 |
|
433 | | -(define (md-figure-sub x type . args) |
434 | | - (let* ((payload (cdr x)) |
435 | | - (src (force-string (car payload))) |
| 432 | +; FIXME: clear this mess with figures, don't expect img as content, etc. |
| 433 | +(define (md-figure-sub payload) |
| 434 | + (let* ((src (force-string (car payload))) |
436 | 435 | (title |
437 | 436 | (with-globals 'num-line-breaks 0 ; Don't break lines in 'document |
438 | 437 | (string-concatenate (map serialize-markdown* (cdr payload)))))) |
439 | | - (if (hugo-extensions?) |
440 | | - (md-hugo-shortcode `(,type (src ,src) ,@args) title) |
441 | | - (md-image (list 'image src title))))) |
| 438 | + (list src title))) |
442 | 439 |
|
443 | 440 | (define (md-figure type . args) |
444 | | - (lambda (x) (md-figure-sub x type args))) |
| 441 | + (lambda (x) |
| 442 | + (with params (md-figure-sub (cdr x)) |
| 443 | + (if (hugo-extensions?) |
| 444 | + (md-hugo-shortcode `(,type (src ,(car params)) ,args) (cadr params)) |
| 445 | + (md-image (list 'image (car params) (cadr params))))))) |
| 446 | + |
| 447 | +(define (md-marginal-figure type . args) |
| 448 | + (lambda (x) |
| 449 | + (let ((params (md-figure-sub (cddr x))) |
| 450 | + (vpos (cadr x))) |
| 451 | + (if (hugo-extensions?) |
| 452 | + (md-hugo-shortcode `(,type (valign ,(marginal-style vpos)) |
| 453 | + (src ,(car params)) |
| 454 | + ,args) |
| 455 | + (cadr params)) |
| 456 | + (md-image (list 'image (car params) (cadr params))))))) |
445 | 457 |
|
446 | 458 |
|
447 | 459 | (define (md-footnote x) |
|
488 | 500 | (string-append (serialize-markdown* inner) |
489 | 501 | "{{</" (symbol->string (car x)) ">}}")))) |
490 | 502 | (string-trim-both |
491 | | - (string-recompose-space |
492 | | - `("{{<" ,shortcode ,@(map process-one arguments) ">}}" ,content)))))) |
| 503 | + (string-append |
| 504 | + (string-recompose-space |
| 505 | + `("{{<" ,shortcode ,@(map process-one arguments) ">}}")) |
| 506 | + content))))) |
493 | 507 |
|
494 | 508 | (define (md-toc x) |
495 | 509 | (if (hugo-extensions?) |
|
501 | 515 | (md-hugo-shortcode '(references)) |
502 | 516 | (md-style '(strong "Bibliography not implemented for raw Markdown")))) |
503 | 517 |
|
504 | | -(define (md-sidenote x) |
| 518 | +(define marginal-styles-table |
| 519 | + (list->ahash-table '(("b" . "bottom") ("c" . "center") |
| 520 | + ("t" . "top") ("normal" . "right")))) |
| 521 | + |
| 522 | +(define (marginal-style s) |
| 523 | + (ahash-ref marginal-styles-table s)) |
| 524 | + |
| 525 | +(define (md-sidenote-sub x numbered?) |
505 | 526 | (if (hugo-extensions?) |
506 | | - (let ((styles (list->ahash-table '(("b" . "bottom") ("c" . "center") |
507 | | - ("t" . "top") ("normal" . "right")))) |
| 527 | + (let ((numbered (if numbered? '((numbered "numbered")) '())) |
508 | 528 | (args (cdr x))) |
509 | 529 | (md-hugo-shortcode |
510 | | - `(sidenote (halign ,(ahash-ref styles (first args))) |
511 | | - (valign ,(ahash-ref styles (second args)))) |
| 530 | + (append `(sidenote (halign ,(marginal-style (first args))) |
| 531 | + (valign ,(marginal-style (second args)))) |
| 532 | + numbered) |
512 | 533 | (third args))) |
513 | | - (md-footnote (list 'footnote (third args))))) |
| 534 | + (md-footnote (list 'footnote (third (cdr x)))))) |
| 535 | + |
| 536 | +(define (md-sidenote x) |
| 537 | + (md-sidenote-sub x #t)) |
| 538 | + |
| 539 | +(define (md-sidenote* x) |
| 540 | + (md-sidenote-sub x #f)) |
514 | 541 |
|
515 | 542 | (define (md-explain-macro x) |
516 | 543 | ; FIXME: this will break with nested macros (tt style will be interrupted) |
|
633 | 660 | (list 'footnote md-footnote) |
634 | 661 | (list 'todo md-todo) |
635 | 662 | (list 'image md-image) |
636 | | - (list 'small-figure (md-figure 'tmfigure)) |
637 | | - (list 'big-figure (md-figure 'tmfigure)) |
638 | | - (list 'wide-figure (md-figure 'tmfigure 'class "wide-figure")) |
| 663 | + (list 'small-figure (md-figure 'tmfigure 'numbered "numbered")) |
| 664 | + (list 'small-figure* (md-figure 'tmfigure)) |
| 665 | + (list 'big-figure (md-figure 'tmfigure 'numbered "numbered")) |
| 666 | + (list 'big-figure* (md-figure 'tmfigure)) |
| 667 | + (list 'wide-figure (md-figure 'tmfigure 'class "wide-figure" |
| 668 | + 'numbered "numbered")) |
| 669 | + (list 'wide-figure* (md-figure 'tmfigure 'class "wide-figure")) |
| 670 | + (list 'marginal-figure (md-marginal-figure 'sidefigure)) |
| 671 | + (list 'marginal-figure* (md-marginal-figure 'sidefigure)) |
639 | 672 | (list 'hlink md-hlink) |
640 | 673 | (list 'tags md-hugo-tags) ; Hugo extension (DEPRECATED) |
641 | 674 | (list 'hugo-short md-hugo-shortcode) ; Hugo extension |
642 | 675 | (list 'hugo-front md-hugo-frontmatter) ; Hugo extension |
643 | 676 | (list 'table-of-contents md-toc) ; Hugo extension |
644 | 677 | (list 'bibliography md-bibliography) ; TfL extension |
645 | 678 | (list 'marginal-note md-sidenote) ; TfL extension |
646 | | - (list 'marginal-note* md-sidenote) ; TfL extension (TO DO) |
| 679 | + (list 'marginal-note* md-sidenote*) ; TfL extension |
647 | 680 | (list 'explain-macro md-explain-macro) |
648 | 681 | (list 'tmdoc-copyright md-tmdoc-copyright) |
649 | 682 | )) |
|
0 commit comments