git.s-ol.nu mmm / 9705547
more sidenote/reference features s-ol 1 year, 11 months ago
6 changed file(s) with 95 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
0 import div, a, i, b from require 'mmm.dom'
0 import div, span, sup, a, i, b from require 'mmm.dom'
1
2 parse_bibtex = (src) ->
3 type, key, kv = src\match '@(%w+){(.-),(.*)}'
4 with info = { _type: type, _key: key }
5 for key, val in kv\gmatch '([a-z]-)%s*=%s*{(.-)}'
6 info[key] = val
17
28 title = (info) ->
39 assert info.title, "cite doesn't have title"
410 inner = i info.title
511 if info.url
6 a inner, href: info.url
12 a inner, href: info.url, style: display: 'inline'
713 else
814 b inner
15
16 format_full = (info) ->
17 tt = title info
18 dot, com = if info.title\match '[.?!]$' then '', '' else '.', ','
19 switch info._type
20 when 'book', 'article'
21 span "#{info.author} (#{info.year}), ", tt, "#{dot} #{info.publisher}"
22 when 'web'
23 -- note = if info.note then ", #{info.note}" else ''
24 visited = if info.visited then " from #{info.visited}" else ""
25 span tt, "#{com} #{info.url}#{visited}"
26 else
27 span "#{info.author} (#{info.year}), ", tt, "#{dot} #{info.publisher}"
928
1029 {
1130 converts: {
2544 inp: 'text/bibtex'
2645 out: 'mmm/dom'
2746 cost: 1
28 transform: (src) =>
29 type, key, kv = src\match '@(%w+){(.-),(.*)}'
30 info = {}
31 for key, val in kv\gmatch '([a-z]-)%s*=%s*{(.-)}'
32 info[key] = val
47 transform: (bib) => format_full parse_bibtex bib
48 }
49 {
50 inp: 'text/bibtex'
51 out: 'mmm/dom+link'
52 cost: 1
53 transform: (bib) =>
54 info = parse_bibtex bib
55 note = format_full info
3356
34 tt = title info
35 dot, com = if info.title\match '[.?!]$' then '', '' else '.', ','
36 switch type
37 when 'book', 'article'
38 div "#{info.author} (#{info.year}), ", tt, "#{dot} #{info.publisher}"
39 when 'web'
40 -- note = if info.note then ", #{info.note}" else ''
41 div tt, "#{com} #{info.url} from #{info.visited}"
42 else
43 div "#{info.author} (#{info.year}), ", tt, "#{dot} #{info.publisher}"
57 key = tostring 1
58 id = "sideref-#{key}"
59
60 intext = sup a key, href: "##{id}"
61
62 span intext, div {
63 class: 'sidenote'
64 style:
65 'margin-top': '-1rem'
66
67 div :id, class: 'hook'
68 b key, class: 'ref'
69 ' '
70 note
71 }
4472 }
4573 }
4674 }
5252 link_to = (fileder, name, origin, attr) ->
5353 fileder = find_fileder fileder, origin
5454
55 link = fileder\get 'mmm/dom+link'
56 return link if link
57
5558 name or= fileder\get 'title: mmm/dom'
5659 name or= fileder\gett 'name: alpha'
5760
2323
2424 nav {
2525 background: inherit;
26 }
27
28 .subnav {
29 display: flex;
30 flex: 0;
31 background: $gray-darker;
32 border-bottom: 2px solid $gray-dark;
33 padding: 0.5em;
2634 }
2735
2836 .content {
44 }
55
66 .markdown {
7 position: relative;
78 max-width: 640px;
8 position: relative;
99
1010 &.wide {
1111 max-width: max-content;
1212 }
1313
1414 h1, h2, h3, h4, h5, h6 { font-weight: bold; }
15 h1 { font-size: 1.6em; }
16 h2 { font-size: 1.4em; }
17 h3 { font-size: 1.17em; }
18 h4, h5, h6 { font-size: 1em; }
19
1520 input, select, button {
1621 color: initial;
1722 &:disabled {
2227 code { font-size: 0.8em; }
2328 b, strong { font-weight: bold; }
2429 em, i { font-style: italic; }
25 a { font-size: 1em; cursor: pointer; }
2630 hr { clear: both; }
2731 ul { margin: 0; }
32
33 sup, sub {
34 vertical-align: baseline;
35 position: relative;
36 top: -0.4em;
37 }
38 sub { top: 0.4em; }
2839
2940 body {
3041 display: flex;
3950
4051 a {
4152 display: inline-block;
42
53 font-size: 1em;
4354 font-weight: bold;
4455 text-decoration: underline;
4556 text-decoration-color: transparent;
4657
58 cursor: pointer;
4759 &:hover {
4860 filter: invert(40%);
4961 text-decoration-color: currentColor;
1919 font-size: 0.8em;
2020 word-break: break-word;
2121
22 .hook {
23 position: absolute;
24 top: -4rem;
25 width: 0;
26 height: 0;
27
28 @media print {
29 top: 0;
30 }
31 }
32
33 .ref {
34 display: block;
35 position: absolute;
36
37 width: 1rem;
38 margin-left: -1.2rem;
39 text-align: right;
40 }
41
42 a {
43 display: inline;
44 }
45
2246 @include media-medium {
2347 width: initial;
2448 position: initial;