@memorysmithapp/markdown-renderer 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/DataTable.js +118 -3
- package/dist/Markdown.d.ts +17 -1
- package/dist/Markdown.js +21 -4
- package/dist/NoteBody.js +48 -5
- package/dist/appendices.d.ts +51 -0
- package/dist/appendices.js +102 -0
- package/dist/diagnose.d.ts +2 -1
- package/dist/diagnose.js +10 -1
- package/dist/edit/NoteEditor.js +36 -5
- package/dist/edit/StyleDialog.d.ts +16 -0
- package/dist/edit/StyleDialog.js +64 -0
- package/dist/edit/analyze.d.ts +20 -1
- package/dist/edit/analyze.js +30 -1
- package/dist/edit/blocks.d.ts +11 -0
- package/dist/edit/blocks.js +24 -2
- package/dist/edit/heights.d.ts +1 -1
- package/dist/edit/heights.js +3 -0
- package/dist/edit/live.js +68 -2
- package/dist/edit/style.d.ts +29 -0
- package/dist/edit/style.js +71 -0
- package/dist/edit/table.d.ts +1 -1
- package/dist/edit/table.js +4 -1
- package/dist/host.d.ts +31 -1
- package/dist/host.js +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/justified.d.ts +25 -0
- package/dist/justified.js +96 -0
- package/dist/note-style.d.ts +38 -0
- package/dist/note-style.js +53 -0
- package/dist/source.js +3 -2
- package/dist/strings.d.ts +36 -5
- package/dist/strings.js +20 -4
- package/dist/style-block.d.ts +78 -0
- package/dist/style-block.js +178 -0
- package/dist/table-block.d.ts +14 -0
- package/dist/theme.d.ts +12 -1
- package/dist/theme.js +8 -6
- package/package.json +2 -2
- package/structure.css +107 -0
- package/theme-default.css +132 -14
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `:::{style}` block (`SPEC.md` §7.16, #164): a passage of a note set apart from the notebook's
|
|
3
|
+
* style, a colon fence holding its options in a `---` block, as MyST writes a directive.
|
|
4
|
+
*
|
|
5
|
+
* ```markdown
|
|
6
|
+
* :::{style}
|
|
7
|
+
* ---
|
|
8
|
+
* text: justify
|
|
9
|
+
* headings: center
|
|
10
|
+
* ---
|
|
11
|
+
* # Ata da assembleia
|
|
12
|
+
* :::
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* No parser of this package reads a colon fence, so the block is found here, on the text, as the
|
|
16
|
+
* code regions and the comments are: a fence inside code is an example and is never read. Each
|
|
17
|
+
* fence line and each line of the options is then written as spaces of its own length, which keeps
|
|
18
|
+
* every offset and every line of the text, and leaves the content parsed exactly as it would be on
|
|
19
|
+
* its own — a line of options is no setext heading (§3.4), and the content's headings are the
|
|
20
|
+
* note's (§3.3). What a block sets is drawn by wrapping the content it holds, by its lines.
|
|
21
|
+
*
|
|
22
|
+
* A block opens at the margin, up to three spaces in, never inside a quote or a list. A bare colon
|
|
23
|
+
* fence closes the innermost open block whose fence it is at least as long as; one that closes
|
|
24
|
+
* nothing is text. A block never closed runs to the end of the note. A key or a value the style
|
|
25
|
+
* cannot take, and a block never closed, are its notices (§7.13); none is an error.
|
|
26
|
+
*/
|
|
27
|
+
import { codeRegions, insideCode } from './source.js';
|
|
28
|
+
import { STYLE_KEYS, justifies, styleProperties, takes } from './note-style.js';
|
|
29
|
+
const OPEN = /^ {0,3}(:{3,})\{style\}[ \t]*$/;
|
|
30
|
+
const CLOSE = /^ {0,3}(:{3,})[ \t]*$/;
|
|
31
|
+
const RULE = /^ {0,3}---[ \t]*$/;
|
|
32
|
+
const OPTION = /^([A-Za-z_][\w-]*)[ \t]*:[ \t]*(.*?)[ \t]*$/;
|
|
33
|
+
/** Every style block of a text, and the text with their fences and options blanked. */
|
|
34
|
+
export function findStyleBlocks(text) {
|
|
35
|
+
if (!text.includes(':::'))
|
|
36
|
+
return { text, blocks: [], problems: [] };
|
|
37
|
+
const lines = text.split('\n');
|
|
38
|
+
const starts = [];
|
|
39
|
+
let offset = 0;
|
|
40
|
+
for (const line of lines) {
|
|
41
|
+
starts.push(offset);
|
|
42
|
+
offset += line.length + 1;
|
|
43
|
+
}
|
|
44
|
+
const code = codeRegions(text);
|
|
45
|
+
const blank = new Set();
|
|
46
|
+
const blocks = [];
|
|
47
|
+
const problems = [];
|
|
48
|
+
const open = [];
|
|
49
|
+
const problem = (code, index) => {
|
|
50
|
+
problems.push({ code, line: index + 1, at: starts[index] ?? 0, end: (starts[index] ?? 0) + (lines[index] ?? '').length });
|
|
51
|
+
};
|
|
52
|
+
for (let index = 0; index < lines.length; index++) {
|
|
53
|
+
const line = lines[index] ?? '';
|
|
54
|
+
if (!line.includes(':') || insideCode(code, starts[index] ?? 0))
|
|
55
|
+
continue;
|
|
56
|
+
const opening = OPEN.exec(line);
|
|
57
|
+
if (opening) {
|
|
58
|
+
blank.add(index);
|
|
59
|
+
let from = index + 1;
|
|
60
|
+
const style = {};
|
|
61
|
+
// The options: a `---` on the line after the fence, up to the next `---`, as the frontmatter
|
|
62
|
+
// is read (§6.2). With no `---` to close them, there are none, and the lines are content.
|
|
63
|
+
if (RULE.test(lines[index + 1] ?? '')) {
|
|
64
|
+
const end = lines.findIndex((each, at) => at > index + 1 && RULE.test(each));
|
|
65
|
+
if (end !== -1) {
|
|
66
|
+
const seen = new Set();
|
|
67
|
+
for (let at = index + 1; at <= end; at++)
|
|
68
|
+
blank.add(at);
|
|
69
|
+
for (let at = index + 2; at < end; at++) {
|
|
70
|
+
const option = lines[at] ?? '';
|
|
71
|
+
if (option.trim() === '')
|
|
72
|
+
continue;
|
|
73
|
+
const read = OPTION.exec(option.trim());
|
|
74
|
+
const key = read?.[1]?.toLowerCase();
|
|
75
|
+
if (!read || !key || !STYLE_KEYS.includes(key) || seen.has(key)) {
|
|
76
|
+
problem('style-key-unknown', at);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
seen.add(key);
|
|
80
|
+
const value = (read[2] ?? '').replace(/^(['"])(.*)\1$/, '$2').trim().toLowerCase();
|
|
81
|
+
if (takes(key, value))
|
|
82
|
+
style[key] = value;
|
|
83
|
+
else
|
|
84
|
+
problem('style-value-invalid', at);
|
|
85
|
+
}
|
|
86
|
+
from = end + 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
open.push({ open: index + 1, colons: opening[1].length, from: from + 1, style: style });
|
|
90
|
+
index = from - 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const closing = CLOSE.exec(line);
|
|
94
|
+
if (closing && open.length > 0 && closing[1].length >= open[open.length - 1].colons) {
|
|
95
|
+
const block = open.pop();
|
|
96
|
+
blank.add(index);
|
|
97
|
+
blocks.push({ open: block.open, close: index + 1, from: block.from, to: index, style: block.style, depth: open.length });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// A block never closed runs to the end of the note, as an unclosed fence does.
|
|
101
|
+
while (open.length > 0) {
|
|
102
|
+
const block = open.pop();
|
|
103
|
+
problem('style-unclosed', block.open - 1);
|
|
104
|
+
blocks.push({ open: block.open, close: null, from: block.from, to: lines.length, style: block.style, depth: open.length });
|
|
105
|
+
}
|
|
106
|
+
if (blocks.length === 0)
|
|
107
|
+
return { text, blocks: [], problems };
|
|
108
|
+
const blanked = lines.map((line, index) => (blank.has(index) ? ' '.repeat(line.length) : line)).join('\n');
|
|
109
|
+
blocks.sort((a, b) => a.open - b.open);
|
|
110
|
+
problems.sort((a, b) => a.at - b.at);
|
|
111
|
+
return { text: blanked, blocks, problems };
|
|
112
|
+
}
|
|
113
|
+
/** The blocks that reach the lines `first` to `last` of the text, in those lines' own count. */
|
|
114
|
+
export function rangesFor(blocks, first, last) {
|
|
115
|
+
return blocks.flatMap((block) => {
|
|
116
|
+
const from = Math.max(block.from, first);
|
|
117
|
+
const to = Math.min(block.to, last);
|
|
118
|
+
return from > to ? [] : [{ from: from - first + 1, to: to - first + 1, style: block.style, depth: block.depth }];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** What a line of the text is set as, every block that holds it merged, the innermost winning. */
|
|
122
|
+
export function styleAt(blocks, line) {
|
|
123
|
+
return blocks
|
|
124
|
+
.filter((block) => block.from <= line && line <= block.to)
|
|
125
|
+
.sort((a, b) => a.depth - b.depth)
|
|
126
|
+
.reduce((merged, block) => ({ ...merged, ...block.style }), {});
|
|
127
|
+
}
|
|
128
|
+
/** The attributes of the element that draws a block: its class, its style's custom properties, what it sets, and the language when it justifies. */
|
|
129
|
+
export function blockAttributes(style, locale) {
|
|
130
|
+
const css = Object.entries(styleProperties(style))
|
|
131
|
+
.map(([name, value]) => `${name}:${value}`)
|
|
132
|
+
.join(';');
|
|
133
|
+
return {
|
|
134
|
+
className: ['style-block'],
|
|
135
|
+
...(css ? { style: css } : {}),
|
|
136
|
+
...Object.fromEntries(STYLE_KEYS.flatMap((key) => (style[key] ? [[`data${key[0].toUpperCase()}${key.slice(1)}`, style[key]]] : []))),
|
|
137
|
+
...(justifies(style) ? { lang: locale } : {}),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Wraps what each block holds, by its lines, in the element that draws it: a `div.style-block`
|
|
142
|
+
* carrying its style as custom properties, which its content inherits and an inner block's own
|
|
143
|
+
* override. The last plugin of a run, so every other one reads the tree as the parser left it.
|
|
144
|
+
*/
|
|
145
|
+
export function remarkStyleBlocks(options) {
|
|
146
|
+
return (tree) => {
|
|
147
|
+
if (options.ranges.length === 0)
|
|
148
|
+
return;
|
|
149
|
+
const root = tree;
|
|
150
|
+
root.children = wrap(root.children ?? [], [...options.ranges].sort((a, b) => a.from - b.from || a.depth - b.depth), options.locale);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function wrap(children, ranges, locale) {
|
|
154
|
+
if (ranges.length === 0)
|
|
155
|
+
return children;
|
|
156
|
+
// The outermost ranges here; the others lie inside one of them.
|
|
157
|
+
const outer = ranges.filter((range) => !ranges.some((other) => other !== range && other.depth < range.depth && other.from <= range.from && range.to <= other.to));
|
|
158
|
+
// Each child at the line it starts on; one with no position goes with the child before it.
|
|
159
|
+
let line = 0;
|
|
160
|
+
const lines = children.map((child) => (line = child.position?.start.line ?? line));
|
|
161
|
+
const result = [];
|
|
162
|
+
let index = 0;
|
|
163
|
+
while (index < children.length) {
|
|
164
|
+
const at = lines[index];
|
|
165
|
+
const range = outer.find((each) => each.from <= at && at <= each.to);
|
|
166
|
+
if (!range) {
|
|
167
|
+
result.push(children[index]);
|
|
168
|
+
index++;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const held = [];
|
|
172
|
+
while (index < children.length && lines[index] <= range.to && lines[index] >= range.from)
|
|
173
|
+
held.push(children[index++]);
|
|
174
|
+
const inner = ranges.filter((each) => each !== range && each.depth > range.depth && range.from <= each.from && each.to <= range.to);
|
|
175
|
+
result.push({ type: 'styleBlock', data: { hName: 'div', hProperties: blockAttributes(range.style, locale) }, children: wrap(held, inner, locale) });
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
package/dist/table-block.d.ts
CHANGED
|
@@ -137,6 +137,20 @@ export interface TableRequest {
|
|
|
137
137
|
/** The column whose sum over the whole filter closes the table, or `null`. */
|
|
138
138
|
readonly total: string | null;
|
|
139
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* A row of a `table` block a reader opened whole (#163): a cell holds one line on the screen, and a
|
|
142
|
+
* click or Enter on its row shows every value of it. The host shows it in its own dialog.
|
|
143
|
+
*/
|
|
144
|
+
export interface TableRowView {
|
|
145
|
+
/** The table, as the block names it. */
|
|
146
|
+
readonly table: string;
|
|
147
|
+
/** The columns the block draws, in its order, with their kinds. */
|
|
148
|
+
readonly columns: readonly TableColumn[];
|
|
149
|
+
/** The row as the host answered it. */
|
|
150
|
+
readonly row: TableRow;
|
|
151
|
+
/** Each column's value as the table draws it, in the reader's locale and as text, in the order of `columns`. */
|
|
152
|
+
readonly values: readonly string[];
|
|
153
|
+
}
|
|
140
154
|
/** What the host answers for a table it keeps (#138). */
|
|
141
155
|
export interface TablePage {
|
|
142
156
|
/** The table's columns, in its own order, with their kinds. */
|
package/dist/theme.d.ts
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* property set. It is the theme every other one starts from, since a property
|
|
21
21
|
* is read by the default theme's rules.
|
|
22
22
|
*/
|
|
23
|
+
import { type NoteStyle } from './note-style.js';
|
|
23
24
|
import type { ReactNode } from 'react';
|
|
24
25
|
import type { FileShape } from './file-types.js';
|
|
25
26
|
import type { KeptFile } from './host.js';
|
|
@@ -75,6 +76,8 @@ export interface ThemeProperties {
|
|
|
75
76
|
readonly fontSans?: string;
|
|
76
77
|
readonly fontDisplay?: string;
|
|
77
78
|
readonly fontMono?: string;
|
|
79
|
+
/** The face of a note, or of a passage, whose style is `serif` (#164). */
|
|
80
|
+
readonly fontSerif?: string;
|
|
78
81
|
readonly fontHeading?: string;
|
|
79
82
|
readonly radius?: string;
|
|
80
83
|
readonly radiusLarge?: string;
|
|
@@ -105,6 +108,14 @@ export interface ThemeProperties {
|
|
|
105
108
|
readonly tableHeaderRule?: string;
|
|
106
109
|
readonly tableStripeBg?: string;
|
|
107
110
|
readonly tableHoverBg?: string;
|
|
111
|
+
readonly pagerBg?: string;
|
|
112
|
+
readonly pagerColor?: string;
|
|
113
|
+
readonly pagerBorder?: string;
|
|
114
|
+
readonly pagerRadius?: string;
|
|
115
|
+
readonly pagerPadding?: string;
|
|
116
|
+
readonly pagerFont?: string;
|
|
117
|
+
readonly pagerHoverBg?: string;
|
|
118
|
+
readonly pagerWordsFrom?: string;
|
|
108
119
|
readonly embedRule?: string;
|
|
109
120
|
readonly titleFont?: string;
|
|
110
121
|
readonly titleSize?: string;
|
|
@@ -345,4 +356,4 @@ export declare const DEFAULT_THEME: Theme;
|
|
|
345
356
|
/** The scheme a theme is drawn in, given the one asked for. */
|
|
346
357
|
export declare function schemeOf(theme: Theme, asked: Scheme): Scheme;
|
|
347
358
|
/** The custom properties the root of a note carries for a theme in a scheme. */
|
|
348
|
-
export declare function rootStyle(theme: Theme, scheme: Scheme): Record<string, string>;
|
|
359
|
+
export declare function rootStyle(theme: Theme, scheme: Scheme, style?: NoteStyle): Record<string, string>;
|
package/dist/theme.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* property set. It is the theme every other one starts from, since a property
|
|
21
21
|
* is read by the default theme's rules.
|
|
22
22
|
*/
|
|
23
|
+
import { styleProperties } from './note-style.js';
|
|
23
24
|
/** The names of `ThemeProperties`, in the order the documentation lists them. */
|
|
24
25
|
export const THEME_PROPERTIES = Object.keys({
|
|
25
26
|
bg: 1, surface: 1, border: 1, text: 1, textSoft: 1, accent: 1, pending: 1, parameter: 1,
|
|
@@ -29,7 +30,7 @@ export const THEME_PROPERTIES = Object.keys({
|
|
|
29
30
|
calloutTitleLinkDecoration: 1, calloutTitleLinkOffset: 1,
|
|
30
31
|
iconNote: 1, iconInfo: 1, iconSummary: 1, iconTip: 1, iconSuccess: 1, iconQuestion: 1, iconWarning: 1,
|
|
31
32
|
iconFailure: 1, iconDanger: 1, iconExample: 1, iconQuote: 1, iconChevron: 1,
|
|
32
|
-
fontSans: 1, fontDisplay: 1, fontMono: 1, fontHeading: 1,
|
|
33
|
+
fontSans: 1, fontDisplay: 1, fontMono: 1, fontSerif: 1, fontHeading: 1,
|
|
33
34
|
radius: 1, radiusLarge: 1,
|
|
34
35
|
fontSize: 1, lineHeight: 1, lineHeightTight: 1, rootLineHeight: 1, paragraphSpacing: 1, headingSpacing: 1,
|
|
35
36
|
listIndent: 1, listSpacing: 1,
|
|
@@ -37,6 +38,7 @@ export const THEME_PROPERTIES = Object.keys({
|
|
|
37
38
|
h1Weight: 1, h6Color: 1,
|
|
38
39
|
quoteBorderColor: 1, quoteBorderWidth: 1, quoteColor: 1,
|
|
39
40
|
tableBorder: 1, tableCellPadding: 1, tableHeaderBg: 1, tableHeaderRule: 1, tableStripeBg: 1, tableHoverBg: 1,
|
|
41
|
+
pagerBg: 1, pagerColor: 1, pagerBorder: 1, pagerRadius: 1, pagerPadding: 1, pagerFont: 1, pagerHoverBg: 1, pagerWordsFrom: 1,
|
|
40
42
|
embedRule: 1,
|
|
41
43
|
titleFont: 1, titleSize: 1, titleWeight: 1, titleColor: 1,
|
|
42
44
|
propertiesRule: 1, propertiesLabelFont: 1, propertiesLabelColor: 1, propertiesKeyColor: 1,
|
|
@@ -94,16 +96,16 @@ export function schemeOf(theme, asked) {
|
|
|
94
96
|
return schemes.includes(asked) ? asked : (schemes[0] ?? asked);
|
|
95
97
|
}
|
|
96
98
|
/** The custom properties the root of a note carries for a theme in a scheme. */
|
|
97
|
-
export function rootStyle(theme, scheme) {
|
|
99
|
+
export function rootStyle(theme, scheme, style = {}) {
|
|
98
100
|
const properties = theme.properties;
|
|
99
101
|
if (!properties)
|
|
100
|
-
return
|
|
102
|
+
return styleProperties(style);
|
|
101
103
|
const values = isPerScheme(properties) ? (properties[scheme] ?? {}) : properties;
|
|
102
|
-
const
|
|
104
|
+
const css = {};
|
|
103
105
|
for (const name of THEME_PROPERTIES) {
|
|
104
106
|
const value = values[name];
|
|
105
107
|
if (value !== undefined)
|
|
106
|
-
|
|
108
|
+
css[customPropertyOf(name)] = value;
|
|
107
109
|
}
|
|
108
|
-
return style;
|
|
110
|
+
return { ...css, ...styleProperties(style) };
|
|
109
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memorysmithapp/markdown-renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A React component that draws a MemorySmith note exactly as MemorySmith's reading page does.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"unified": "11.0.5"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@memorysmithapp/markdown-spec": "0.
|
|
83
|
+
"@memorysmithapp/markdown-spec": "0.12.0",
|
|
84
84
|
"@types/hast": "3.0.5",
|
|
85
85
|
"@types/react": "19.2.18",
|
|
86
86
|
"@types/react-dom": "19.2.4",
|
package/structure.css
CHANGED
|
@@ -283,6 +283,14 @@
|
|
|
283
283
|
.markdown .edit-attach .edit-source-frame {
|
|
284
284
|
height: min(34rem, calc(100vh - 4rem));
|
|
285
285
|
}
|
|
286
|
+
/* The form of a style block is as tall as its four fields, and narrow (#166). */
|
|
287
|
+
.markdown .edit-source.edit-style {
|
|
288
|
+
max-width: min(28rem, calc(100vw - 2rem));
|
|
289
|
+
}
|
|
290
|
+
.markdown .edit-style .edit-source-frame {
|
|
291
|
+
height: auto;
|
|
292
|
+
max-height: calc(100vh - 4rem);
|
|
293
|
+
}
|
|
286
294
|
.markdown .edit-attach-ways {
|
|
287
295
|
display: flex;
|
|
288
296
|
flex: none;
|
|
@@ -532,3 +540,102 @@
|
|
|
532
540
|
min-width: 0;
|
|
533
541
|
}
|
|
534
542
|
}
|
|
543
|
+
|
|
544
|
+
/* A `table` block on the screen (#163): its columns at the width of the
|
|
545
|
+
block, each fixed by `DataTable` on a `col` from the first answer, so no
|
|
546
|
+
page and no order moves them; a cell of one line, a longer value ending in
|
|
547
|
+
an ellipsis, which its row shows whole; rows that fill a shorter last page,
|
|
548
|
+
so the footer stays where it was; and the block scrolling sideways below the
|
|
549
|
+
least width its columns take. Paper wraps every value of every row (§7.15),
|
|
550
|
+
so none of this reaches it. The block is a container, so its Previous and
|
|
551
|
+
Next show their words only from `--markdown-pager-words-from` on, through
|
|
552
|
+
the same switch as a responsive button's word (#96). */
|
|
553
|
+
@media screen {
|
|
554
|
+
.markdown .data-table {
|
|
555
|
+
container-type: inline-size;
|
|
556
|
+
}
|
|
557
|
+
.markdown .data-table-scroll {
|
|
558
|
+
overflow-x: auto;
|
|
559
|
+
}
|
|
560
|
+
.markdown .data-table:not(.data-table-printing) table {
|
|
561
|
+
display: table;
|
|
562
|
+
table-layout: fixed;
|
|
563
|
+
width: 100%;
|
|
564
|
+
}
|
|
565
|
+
.markdown .data-table:not(.data-table-printing) :is(th, td),
|
|
566
|
+
.markdown .data-table:not(.data-table-printing) .data-table-sort {
|
|
567
|
+
overflow: hidden;
|
|
568
|
+
white-space: nowrap;
|
|
569
|
+
text-overflow: ellipsis;
|
|
570
|
+
}
|
|
571
|
+
.markdown .data-table-row {
|
|
572
|
+
cursor: pointer;
|
|
573
|
+
}
|
|
574
|
+
.markdown .data-table-filler {
|
|
575
|
+
visibility: hidden;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
@media print {
|
|
579
|
+
.markdown .data-table-filler {
|
|
580
|
+
display: none;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
.markdown .data-table-page {
|
|
584
|
+
display: inline-flex;
|
|
585
|
+
align-items: center;
|
|
586
|
+
justify-content: center;
|
|
587
|
+
}
|
|
588
|
+
.markdown .data-table-page-word {
|
|
589
|
+
overflow: hidden;
|
|
590
|
+
white-space: nowrap;
|
|
591
|
+
max-width: calc(clamp(0px, (100cqi - var(--markdown-pager-words-from, 420px)) * 1000, 1px) * 10000);
|
|
592
|
+
margin-inline: min(calc(clamp(0px, (100cqi - var(--markdown-pager-words-from, 420px)) * 1000, 1px) * 10000), 0.3em);
|
|
593
|
+
}
|
|
594
|
+
/* A row shown whole, where the host shows none (#163): the dialog scrolls,
|
|
595
|
+
and a value wraps as long as it needs. */
|
|
596
|
+
.markdown .data-table-dialog {
|
|
597
|
+
max-width: min(36rem, calc(100vw - 2rem));
|
|
598
|
+
max-height: calc(100vh - 4rem);
|
|
599
|
+
overflow: auto;
|
|
600
|
+
}
|
|
601
|
+
.markdown .data-table-dialog dd {
|
|
602
|
+
margin: 0;
|
|
603
|
+
white-space: pre-wrap;
|
|
604
|
+
overflow-wrap: anywhere;
|
|
605
|
+
}
|
|
606
|
+
/* A table printed as an appendix opens a page of its own (#165); a host lays
|
|
607
|
+
`.table-appendix` on a named page of its own to choose its orientation. */
|
|
608
|
+
@media print {
|
|
609
|
+
.markdown .table-appendix {
|
|
610
|
+
break-before: page;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/* How a note is set, as its style says (#164): the alignment of its headings,
|
|
614
|
+
its text and its tables, from the custom properties `noteStyle` writes on the
|
|
615
|
+
root and a `:::{style}` block on itself, the nearer one winning by
|
|
616
|
+
inheritance. Unset, each is the start of the line, as before. A column's own
|
|
617
|
+
delimiter is its cell's `style`, which wins over this; a `table` block's
|
|
618
|
+
numbers keep the end of their cells. Justified text hyphenates where its
|
|
619
|
+
element carries a language. */
|
|
620
|
+
.markdown :is(p, li) {
|
|
621
|
+
text-align: var(--ms-align-text, start);
|
|
622
|
+
hyphens: var(--ms-hyphens-text, manual);
|
|
623
|
+
}
|
|
624
|
+
.markdown :is(h1, h2, h3, h4, h5, h6) {
|
|
625
|
+
text-align: var(--ms-align-headings, start);
|
|
626
|
+
}
|
|
627
|
+
.markdown :is(th, td),
|
|
628
|
+
.markdown .data-table-dialog dd {
|
|
629
|
+
text-align: var(--ms-align-tables, start);
|
|
630
|
+
hyphens: var(--ms-hyphens-tables, manual);
|
|
631
|
+
}
|
|
632
|
+
/* In edit mode the text is lines of the editor, not paragraphs and headings:
|
|
633
|
+
each takes the alignment its style sets, notation and code left as written
|
|
634
|
+
(#166). */
|
|
635
|
+
.markdown .markdown-editor .cm-line:not(.cm-ms-heading, .cm-ms-code-line, .cm-ms-yaml, .cm-ms-table-source, .cm-ms-callout-source, .cm-ms-style-source) {
|
|
636
|
+
text-align: var(--ms-align-text, start);
|
|
637
|
+
hyphens: var(--ms-hyphens-text, manual);
|
|
638
|
+
}
|
|
639
|
+
.markdown .markdown-editor .cm-line.cm-ms-heading {
|
|
640
|
+
text-align: var(--ms-align-headings, start);
|
|
641
|
+
}
|
package/theme-default.css
CHANGED
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
--ms-font-sans: var(--markdown-font-sans, 'Inter', 'Segoe UI', system-ui, sans-serif);
|
|
73
73
|
--ms-font-display: var(--markdown-font-display, 'Space Grotesk', 'Segoe UI', system-ui, sans-serif);
|
|
74
74
|
--ms-font-mono: var(--markdown-font-mono, ui-monospace, 'Cascadia Code', Consolas, monospace);
|
|
75
|
+
/* The face of a note, or a passage, whose style is serif (#164). */
|
|
76
|
+
--ms-font-serif: var(--markdown-font-serif, Georgia, 'Times New Roman', serif);
|
|
75
77
|
--ms-radius: var(--markdown-radius, 8px);
|
|
76
78
|
--ms-radius-large: var(--markdown-radius-large, 12px);
|
|
77
79
|
|
|
@@ -113,6 +115,15 @@
|
|
|
113
115
|
--ms-table-stripe-bg: var(--markdown-table-stripe-bg, transparent);
|
|
114
116
|
--ms-table-hover-bg: var(--markdown-table-hover-bg, var(--ms-code-bg));
|
|
115
117
|
--ms-embed-rule: var(--markdown-embed-rule, var(--ms-accent));
|
|
118
|
+
/* The Previous and Next of a `table` block, which a host styles as its own
|
|
119
|
+
buttons (#163); left unset, a neutral bordered button. */
|
|
120
|
+
--ms-pager-bg: var(--markdown-pager-bg, var(--ms-surface));
|
|
121
|
+
--ms-pager-color: var(--markdown-pager-color, var(--ms-text));
|
|
122
|
+
--ms-pager-border: var(--markdown-pager-border, 1px solid var(--ms-border));
|
|
123
|
+
--ms-pager-radius: var(--markdown-pager-radius, 6px);
|
|
124
|
+
--ms-pager-padding: var(--markdown-pager-padding, 0.2rem 0.5rem);
|
|
125
|
+
--ms-pager-font: var(--markdown-pager-font, var(--ms-font-sans));
|
|
126
|
+
--ms-pager-hover-bg: var(--markdown-pager-hover-bg, var(--ms-code-bg));
|
|
116
127
|
|
|
117
128
|
/* The frontmatter, drawn above the body as MemorySmith's note page draws it:
|
|
118
129
|
the name as the title, in the face and at the size of a first heading, and
|
|
@@ -156,7 +167,8 @@
|
|
|
156
167
|
draws it. */
|
|
157
168
|
background: var(--ms-bg);
|
|
158
169
|
color: var(--ms-text);
|
|
159
|
-
|
|
170
|
+
/* The face a style chooses (#164), else the text face. */
|
|
171
|
+
font-family: var(--ms-face, var(--ms-font-sans));
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
/* Dark: brand "Fundo escuro" #0B1220, Papel as text. */
|
|
@@ -225,8 +237,13 @@
|
|
|
225
237
|
overflow-wrap: break-word;
|
|
226
238
|
}
|
|
227
239
|
|
|
240
|
+
/* A style block sets the face of its passage (#164): declared again where the
|
|
241
|
+
block's own custom property can reach it. */
|
|
242
|
+
.markdown .style-block {
|
|
243
|
+
font-family: var(--ms-face, var(--ms-font-sans));
|
|
244
|
+
}
|
|
228
245
|
.markdown :is(h1, h2, h3, h4, h5, h6) {
|
|
229
|
-
font-family: var(--ms-font-heading);
|
|
246
|
+
font-family: var(--ms-face-heading, var(--ms-font-heading));
|
|
230
247
|
font-weight: var(--ms-heading-weight);
|
|
231
248
|
color: var(--ms-heading-color);
|
|
232
249
|
line-height: var(--ms-line-height-tight);
|
|
@@ -429,7 +446,6 @@
|
|
|
429
446
|
.markdown :is(th, td) {
|
|
430
447
|
border: 1px solid var(--ms-table-border);
|
|
431
448
|
padding: var(--ms-table-cell-padding);
|
|
432
|
-
text-align: start;
|
|
433
449
|
}
|
|
434
450
|
/* The header is told apart by the type and by a heavier rule, and not by a
|
|
435
451
|
fill; the only tint a table has is the row under the pointer. */
|
|
@@ -459,7 +475,8 @@
|
|
|
459
475
|
|
|
460
476
|
/* A `table` block drawn as its table (§7.15): the note's table, with a header
|
|
461
477
|
that sorts for the reader alone, numbers to the end of their cells, the
|
|
462
|
-
total under its column,
|
|
478
|
+
total under its column, rows a click opens whole, and under the table the
|
|
479
|
+
rows shown on the left and Previous and Next on the right (#163). */
|
|
463
480
|
.markdown .data-table {
|
|
464
481
|
margin-block: var(--ms-p-spacing);
|
|
465
482
|
}
|
|
@@ -503,6 +520,17 @@
|
|
|
503
520
|
.markdown .data-table-loading {
|
|
504
521
|
color: var(--ms-text-soft);
|
|
505
522
|
}
|
|
523
|
+
/* A printed note's tables as appendices (#165): in place of each, the line
|
|
524
|
+
that sends the reader to it, and at the end of the note each under its
|
|
525
|
+
title. */
|
|
526
|
+
.markdown .table-reference {
|
|
527
|
+
font-style: italic;
|
|
528
|
+
color: var(--ms-text-soft);
|
|
529
|
+
}
|
|
530
|
+
.markdown .table-appendix-title {
|
|
531
|
+
margin-block: 0 var(--ms-p-spacing);
|
|
532
|
+
font-size: var(--ms-h3-size);
|
|
533
|
+
}
|
|
506
534
|
/* A block that cannot be answered says why, in place of its table. */
|
|
507
535
|
.markdown .data-table-problems {
|
|
508
536
|
margin-block: var(--ms-p-spacing);
|
|
@@ -550,7 +578,7 @@
|
|
|
550
578
|
.markdown .data-table thead {
|
|
551
579
|
display: table-header-group;
|
|
552
580
|
}
|
|
553
|
-
.markdown .data-table-
|
|
581
|
+
.markdown .data-table-pages,
|
|
554
582
|
.markdown .data-table-sort span {
|
|
555
583
|
display: none;
|
|
556
584
|
}
|
|
@@ -565,24 +593,76 @@
|
|
|
565
593
|
font-size: 0.875em;
|
|
566
594
|
color: var(--ms-text-soft);
|
|
567
595
|
}
|
|
596
|
+
/* Previous and Next stand closer when they are their arrows alone, below
|
|
597
|
+
--markdown-pager-words-from, through the switch `structure.css` uses. */
|
|
568
598
|
.markdown .data-table-pages {
|
|
569
599
|
display: inline-flex;
|
|
570
600
|
align-items: center;
|
|
571
|
-
gap: 0.
|
|
601
|
+
gap: calc(0.25rem + min(calc(clamp(0px, (100cqi - var(--markdown-pager-words-from, 420px)) * 1000, 1px) * 10000), 0.25rem));
|
|
572
602
|
}
|
|
573
|
-
.markdown .data-table-page
|
|
603
|
+
.markdown .data-table-page,
|
|
604
|
+
.markdown .data-table-dialog-close {
|
|
574
605
|
min-width: 2rem;
|
|
575
606
|
min-height: 2rem;
|
|
576
|
-
|
|
577
|
-
border
|
|
578
|
-
|
|
579
|
-
|
|
607
|
+
padding: var(--ms-pager-padding);
|
|
608
|
+
border: var(--ms-pager-border);
|
|
609
|
+
border-radius: var(--ms-pager-radius);
|
|
610
|
+
background: var(--ms-pager-bg);
|
|
611
|
+
color: var(--ms-pager-color);
|
|
612
|
+
font-family: var(--ms-pager-font);
|
|
613
|
+
font-size: inherit;
|
|
580
614
|
cursor: pointer;
|
|
581
615
|
}
|
|
616
|
+
.markdown .data-table-page:hover:not(:disabled),
|
|
617
|
+
.markdown .data-table-dialog-close:hover {
|
|
618
|
+
background: var(--ms-pager-hover-bg);
|
|
619
|
+
}
|
|
582
620
|
.markdown .data-table-page:disabled {
|
|
583
621
|
cursor: default;
|
|
584
622
|
opacity: 0.4;
|
|
585
623
|
}
|
|
624
|
+
/* The rows that fill a shorter page are space, not an empty grid: their rules
|
|
625
|
+
give way to the last row's and to the total's. */
|
|
626
|
+
.markdown .data-table-filler td {
|
|
627
|
+
border-color: transparent;
|
|
628
|
+
}
|
|
629
|
+
.markdown .data-table-row:focus-visible {
|
|
630
|
+
outline: 2px solid var(--ms-accent);
|
|
631
|
+
outline-offset: -2px;
|
|
632
|
+
}
|
|
633
|
+
.markdown .data-table-dialog {
|
|
634
|
+
padding: 1rem 1.25rem;
|
|
635
|
+
border: 1px solid var(--ms-border);
|
|
636
|
+
border-radius: var(--ms-radius-large);
|
|
637
|
+
background: var(--ms-surface);
|
|
638
|
+
color: var(--ms-text);
|
|
639
|
+
font-family: var(--ms-face, var(--ms-font-sans));
|
|
640
|
+
line-height: var(--ms-line-height);
|
|
641
|
+
}
|
|
642
|
+
.markdown .data-table-dialog::backdrop {
|
|
643
|
+
background: rgba(0, 0, 0, 0.35);
|
|
644
|
+
}
|
|
645
|
+
.markdown .data-table-dialog-title {
|
|
646
|
+
margin: 0 0 0.75rem;
|
|
647
|
+
font-family: var(--ms-font-display);
|
|
648
|
+
font-weight: 600;
|
|
649
|
+
}
|
|
650
|
+
.markdown .data-table-dialog dl {
|
|
651
|
+
display: grid;
|
|
652
|
+
gap: 0.6rem;
|
|
653
|
+
margin: 0;
|
|
654
|
+
}
|
|
655
|
+
.markdown .data-table-dialog dt {
|
|
656
|
+
font-size: 0.875em;
|
|
657
|
+
color: var(--ms-text-soft);
|
|
658
|
+
}
|
|
659
|
+
.markdown .data-table-dialog .data-table-number {
|
|
660
|
+
text-align: start;
|
|
661
|
+
font-variant-numeric: tabular-nums;
|
|
662
|
+
}
|
|
663
|
+
.markdown .data-table-dialog-close {
|
|
664
|
+
margin-top: 1rem;
|
|
665
|
+
}
|
|
586
666
|
|
|
587
667
|
.markdown hr {
|
|
588
668
|
margin-block: calc(var(--ms-p-spacing) * 2);
|
|
@@ -599,7 +679,7 @@
|
|
|
599
679
|
would read as a link. */
|
|
600
680
|
.markdown .note-title {
|
|
601
681
|
margin: 0 0 0.6rem;
|
|
602
|
-
font-family: var(--ms-title-font);
|
|
682
|
+
font-family: var(--ms-face-heading, var(--ms-title-font));
|
|
603
683
|
font-size: var(--ms-title-size);
|
|
604
684
|
font-weight: var(--ms-title-weight);
|
|
605
685
|
line-height: var(--ms-line-height-tight);
|
|
@@ -1901,7 +1981,7 @@
|
|
|
1901
1981
|
/* The text: the line height of a run, and the caret in the accent. */
|
|
1902
1982
|
.markdown .markdown-editor .cm-content {
|
|
1903
1983
|
padding: 0;
|
|
1904
|
-
font-family: var(--ms-font-sans);
|
|
1984
|
+
font-family: var(--ms-face, var(--ms-font-sans));
|
|
1905
1985
|
line-height: var(--ms-line-height-normal);
|
|
1906
1986
|
caret-color: var(--ms-accent);
|
|
1907
1987
|
}
|
|
@@ -1921,8 +2001,46 @@
|
|
|
1921
2001
|
font-weight: normal;
|
|
1922
2002
|
font-style: normal;
|
|
1923
2003
|
}
|
|
2004
|
+
/* A line or a drawn block a style block holds carries its style (#166): its
|
|
2005
|
+
face is declared again where the block's own custom property reaches it. */
|
|
2006
|
+
.markdown .markdown-editor .cm-line.cm-ms-styled:not(.cm-ms-heading, .cm-ms-code-line),
|
|
2007
|
+
.markdown .markdown-editor .cm-ms-block {
|
|
2008
|
+
font-family: var(--ms-face, var(--ms-font-sans));
|
|
2009
|
+
}
|
|
2010
|
+
/* A style block's opening while the author is elsewhere: what it sets, small
|
|
2011
|
+
and soft, over a rule that its closing fence draws again at its end. */
|
|
2012
|
+
.markdown .edit-style-summary {
|
|
2013
|
+
display: flex;
|
|
2014
|
+
flex-wrap: wrap;
|
|
2015
|
+
align-items: center;
|
|
2016
|
+
gap: 0.25rem 0.75rem;
|
|
2017
|
+
padding: 0.15rem 0 0.25rem;
|
|
2018
|
+
border-bottom: 1px dashed var(--ms-border);
|
|
2019
|
+
font-family: var(--ms-font-display);
|
|
2020
|
+
font-size: 0.8rem;
|
|
2021
|
+
color: var(--ms-text-soft);
|
|
2022
|
+
cursor: pointer;
|
|
2023
|
+
}
|
|
2024
|
+
.markdown .edit-style-summary-title {
|
|
2025
|
+
display: inline-flex;
|
|
2026
|
+
align-items: center;
|
|
2027
|
+
gap: 0.3rem;
|
|
2028
|
+
font-weight: 600;
|
|
2029
|
+
}
|
|
2030
|
+
.markdown .edit-style-summary svg {
|
|
2031
|
+
width: 0.9rem;
|
|
2032
|
+
height: 0.9rem;
|
|
2033
|
+
}
|
|
2034
|
+
.markdown .cm-ms-style-end {
|
|
2035
|
+
height: 0;
|
|
2036
|
+
margin: 0.25rem 0;
|
|
2037
|
+
border-top: 1px dashed var(--ms-border);
|
|
2038
|
+
}
|
|
2039
|
+
.markdown .cm-ms-style-source {
|
|
2040
|
+
color: var(--ms-text-soft);
|
|
2041
|
+
}
|
|
1924
2042
|
.markdown .cm-ms-heading {
|
|
1925
|
-
font-family: var(--ms-font-heading);
|
|
2043
|
+
font-family: var(--ms-face-heading, var(--ms-font-heading));
|
|
1926
2044
|
font-weight: var(--ms-heading-weight);
|
|
1927
2045
|
color: var(--ms-heading-color);
|
|
1928
2046
|
line-height: var(--ms-line-height-tight);
|