bookish-press 0.5.62 → 0.5.73

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.
Files changed (43) hide show
  1. package/README.md +30 -1
  2. package/dist/components/app/Options.svelte +1 -0
  3. package/dist/components/app/Table.svelte +0 -1
  4. package/dist/components/chapter/CaptionedCode.svelte +21 -19
  5. package/dist/components/chapter/Figure.svelte +5 -3
  6. package/dist/components/chapter/Figure.svelte.d.ts +1 -0
  7. package/dist/components/chapter/Link.svelte +4 -0
  8. package/dist/components/chapter/Paragraph.svelte +18 -0
  9. package/dist/components/chapter/Table.svelte +1 -1
  10. package/dist/components/editor/BookishEditor.svelte +15 -6
  11. package/dist/components/editor/CaretView.svelte +8 -3
  12. package/dist/components/editor/Commands.js +22 -4
  13. package/dist/components/editor/LinkEditor.svelte +18 -5
  14. package/dist/components/editor/icons/header4.svg +7 -0
  15. package/dist/components/page/Analytics.svelte +19 -0
  16. package/dist/components/page/Analytics.svelte.d.ts +16 -0
  17. package/dist/components/page/BulkReferenceEditor.svelte +1 -1
  18. package/dist/components/page/Chapter.svelte +4 -5
  19. package/dist/components/page/DefinitionView.svelte +4 -3
  20. package/dist/components/page/Edition.svelte +2 -2
  21. package/dist/components/page/EditionLoader.svelte +9 -18
  22. package/dist/components/page/Editions.svelte +4 -3
  23. package/dist/components/page/Glossary.svelte +8 -2
  24. package/dist/components/page/Index.svelte +5 -2
  25. package/dist/components/page/Media.svelte +5 -2
  26. package/dist/components/page/Reference.svelte +24 -15
  27. package/dist/components/page/References.svelte +6 -2
  28. package/dist/components/page/Search.svelte +5 -3
  29. package/dist/components/page/SubdomainEditor.svelte +4 -3
  30. package/dist/components/page/TableOfContents.svelte +42 -11
  31. package/dist/components/page/TableOfContentsRow.svelte +3 -1
  32. package/dist/models/CRUD.d.ts +1 -2
  33. package/dist/models/CRUD.js +4 -6
  34. package/dist/models/book/BookMedia.js +8 -3
  35. package/dist/models/book/Chapter.js +2 -3
  36. package/dist/models/book/Edition.d.ts +10 -4
  37. package/dist/models/book/Edition.js +35 -34
  38. package/dist/models/chapter/ParagraphNode.js +4 -14
  39. package/dist/models/chapter/Parser.d.ts +1 -0
  40. package/dist/models/chapter/Parser.js +2 -1
  41. package/dist/models/chapter/TableNode.js +3 -1
  42. package/dist/util/mineReference.js +8 -6
  43. package/package.json +13 -10
@@ -68,22 +68,12 @@ export default class ParagraphNode extends BlockNode {
68
68
  return this.#format.toText();
69
69
  }
70
70
  toBookdown() {
71
- return ((this.#level === 1
72
- ? '# '
73
- : this.#level === 2
74
- ? '## '
75
- : this.#level === 3
76
- ? '### '
77
- : '') + this.#format.toBookdown());
71
+ return this.#level === 0
72
+ ? this.#format.toBookdown()
73
+ : `${'#'.repeat(this.#level)} ${this.#format.toBookdown()}`;
78
74
  }
79
75
  toHTML() {
80
- const tag = this.#level === 1
81
- ? 'h1'
82
- : this.#level === 2
83
- ? 'h2'
84
- : this.#level === 3
85
- ? 'h2'
86
- : 'p';
76
+ const tag = this.#level === 0 ? 'p' : `h${this.#level}`;
87
77
  return `<${tag}>${this.#format.toHTML()}</${tag}>`;
88
78
  }
89
79
  withLevel(level) {
@@ -22,6 +22,7 @@ import type Position from './Position';
22
22
  import type BlockNode from './BlockNode';
23
23
  import type Bookkeeping from './Bookkeeping';
24
24
  import LineBreakNode from './LineBreakNode';
25
+ export declare const Reserved: RegExp;
25
26
  export default class Parser {
26
27
  book: Edition | undefined;
27
28
  text: string;
@@ -46,6 +46,7 @@ const bulletRE = /^\*+\s+/;
46
46
  // LINK :: [CONTENT|TEXT]
47
47
  // FOOTNOTE :: {TEXT}
48
48
  // TEXT :: (.+)
49
+ export const Reserved = /([_*`@~:^<>{}\[\]])/g;
49
50
  export default class Parser {
50
51
  book;
51
52
  text;
@@ -355,7 +356,7 @@ export default class Parser {
355
356
  // Read any whitespace after the hashes.
356
357
  this.readWhitespace();
357
358
  // Parse some content.
358
- return new ParagraphNode(Math.min(3, count), this.parseFormat());
359
+ return new ParagraphNode(Math.min(4, count), this.parseFormat());
359
360
  }
360
361
  parseRule() {
361
362
  // Read until the end of the line. Ignore all text that follows.
@@ -168,8 +168,10 @@ export default class TableNode extends BlockNode {
168
168
  if (index < 0 || index >= this.getColumnCount())
169
169
  return;
170
170
  const newRows = this.#rows.slice();
171
- for (let r = 0; r < this.#rows.length; r++)
171
+ for (let r = 0; r < this.#rows.length; r++) {
172
+ newRows[r] = newRows[r].slice();
172
173
  newRows[r].splice(index, 1);
174
+ }
173
175
  return new TableNode(newRows, this.#position, this.#caption);
174
176
  }
175
177
  withNewColumn(index) {
@@ -1,12 +1,16 @@
1
1
  import Reference from '../models/book/Reference';
2
2
  export function mineReference(ids, text) {
3
3
  // First find the year, since it's the most easily detected. Optional parens.
4
- let yearMatches = text.match(/(\(?[0-9]{4}\)?)/);
4
+ let yearMatches = text.match(/(\(?[0-9]{4}(,[a-zA-Z ]+)?\)?)/);
5
5
  let year = yearMatches !== null && yearMatches.length > 0
6
6
  ? yearMatches[1].replace('(', '').replace(')', '')
7
7
  : undefined;
8
- if (year && yearMatches)
8
+ if (year && yearMatches) {
9
+ const digits = year.match(/([0-9]{4})/);
10
+ if (digits !== null)
11
+ year = digits[1];
9
12
  text = text.replace(yearMatches[1], '');
13
+ }
10
14
  // Next, find the URL
11
15
  let url = null;
12
16
  let urlMatches = text.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/);
@@ -38,9 +42,7 @@ export function mineReference(ids, text) {
38
42
  source = source.trim();
39
43
  }
40
44
  // If there's anything left, fall back to just a string.
41
- return chunks.length > 0
42
- ? new Reference(getUniqueReferenceID(ids), text)
43
- : new Reference(getUniqueReferenceID(ids, authors, year), authors || '', year || '', title || '', source || '', url || '', '', false);
45
+ return new Reference(getUniqueReferenceID(ids, authors, year), authors || '', year || '', title || '', source || '', url || '', '', false);
44
46
  }
45
47
  export function splitIntoSentences(text) {
46
48
  // Split the remaining text by period-space sequences, assuming chunks of information are segmented by sentences
@@ -92,7 +94,7 @@ export function getUniqueReferenceID(ids, authors, year) {
92
94
  return revisedID;
93
95
  }
94
96
  else {
95
- let id = 'ref';
97
+ let id = '00';
96
98
  for (let i = 0; i < 4; i++)
97
99
  id = id + Math.round(Math.random() * 9);
98
100
  return id;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bookish-press",
3
3
  "private": false,
4
- "version": "0.5.62",
4
+ "version": "0.5.73",
5
5
  "type": "module",
6
6
  "description": "A platform for reading and writing readable, accessible, beautiful online books.",
7
7
  "license": "MIT",
@@ -20,45 +20,48 @@
20
20
  "//env": "echo 'This copies the .env file corresponding to the current Firebase project specified with firebase use, defaulting to local'",
21
21
  "env": "cp .env.${GCLOUD_PROJECT:-example} .env",
22
22
  "//stage": "echo 'switch to the dev project, deploy, relying on Firebase's predeploy hook to run the build script above before release'",
23
- "stage": "firebase use dev && firebase deploy",
23
+ "stage": "firebase use dev && cp .env.bookish-dev-21ac3 .env && firebase deploy",
24
24
  "//release": "echo 'switch to the prod project, deploy, relying on Firebase's predeploy hook to run the build script above before release'",
25
- "release": "firebase use prod && firebase deploy",
25
+ "release": "firebase use prod && cp .env.bookish-prod .env && firebase deploy",
26
26
  "//merge": "merge dev into main, push to remote",
27
27
  "merge": "git checkout main && git merge dev && git push origin main && git checkout dev"
28
28
  },
29
29
  "devDependencies": {
30
- "@sveltejs/adapter-static": "^2",
31
- "@sveltejs/kit": "^1.22",
32
- "@sveltejs/package": "^2",
30
+ "@sveltejs/adapter-static": "^2.0",
31
+ "@sveltejs/adapter-auto": "^2.1.1",
32
+ "@sveltejs/kit": "^1.27",
33
+ "@sveltejs/package": "^2.2",
33
34
  "@types/prismjs": "^1.26",
34
35
  "@types/smoothscroll-polyfill": "^0",
35
36
  "@types/uuid": "^9.0",
36
37
  "prettier": "^3",
37
38
  "prettier-plugin-svelte": "^3",
38
39
  "svelte-adapter-firebase": "^0.15.0",
39
- "svelte-check": "^3",
40
- "svelte-preprocess": "^5",
40
+ "svelte-check": "^3.6",
41
+ "svelte-preprocess": "^5.1",
41
42
  "tslib": "^2",
42
43
  "typescript": "^5",
43
44
  "vite": "^4",
44
45
  "vitest": "^0"
45
46
  },
46
47
  "dependencies": {
48
+ "@sveltejs/kit": "^1.27",
47
49
  "ajv": "^8",
48
50
  "ajv-formats": "^2",
49
51
  "firebase": "latest",
50
52
  "firebase-functions": "latest",
51
53
  "prismjs": "^1.29",
52
54
  "smoothscroll-polyfill": "^0.4",
53
- "svelte": "^4.0",
54
- "@sveltejs/kit": "^1.22",
55
+ "svelte": "^4.2",
55
56
  "uuid": "^9.0"
56
57
  },
57
58
  "types": "./dist/index.d.ts",
59
+ "main": "./dist/index.js",
58
60
  "exports": {
59
61
  "./package.json": "./package.json",
60
62
  ".": {
61
63
  "types": "./dist/index.d.ts",
64
+ "main": "./dist/index.js",
62
65
  "svelte": "./dist/index.js",
63
66
  "default": "./dist/index.js"
64
67
  },