bookish-press 0.4.47 → 0.4.49

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 (533) hide show
  1. package/components/Auth.svelte +55 -0
  2. package/components/Auth.svelte.d.ts +16 -0
  3. package/{src/lib/components/Authentication.ts → components/Authentication.d.ts} +0 -2
  4. package/components/Authentication.js +1 -0
  5. package/{src/lib/components → components}/BookPreview.svelte +22 -27
  6. package/components/BookPreview.svelte.d.ts +18 -0
  7. package/{src/lib/components → components}/External.svelte +1 -2
  8. package/components/External.svelte.d.ts +18 -0
  9. package/components/Link.svelte +51 -0
  10. package/components/Link.svelte.d.ts +18 -0
  11. package/{src/lib/components → components}/app/BookList.svelte +3 -6
  12. package/components/app/BookList.svelte.d.ts +18 -0
  13. package/{src/lib/components → components}/app/Button.svelte +4 -5
  14. package/components/app/Button.svelte.d.ts +22 -0
  15. package/{src/lib/components → components}/app/Feedback.svelte +7 -11
  16. package/components/app/Feedback.svelte.d.ts +18 -0
  17. package/{src/lib/components → components}/app/Head.svelte +1 -2
  18. package/components/app/Head.svelte.d.ts +18 -0
  19. package/{src/lib/components → components}/app/Large.svelte +0 -0
  20. package/components/app/Large.svelte.d.ts +27 -0
  21. package/{src/lib/components → components}/app/Lead.svelte +0 -0
  22. package/components/app/Lead.svelte.d.ts +27 -0
  23. package/{src/lib/components → components}/app/Link.svelte +3 -4
  24. package/components/app/Link.svelte.d.ts +20 -0
  25. package/{src/lib/components → components}/app/Options.svelte +4 -5
  26. package/components/app/Options.svelte.d.ts +19 -0
  27. package/{src/lib/components → components}/app/Paragraph.svelte +1 -2
  28. package/components/app/Paragraph.svelte.d.ts +18 -0
  29. package/{src/lib/components → components}/app/Section.svelte +0 -0
  30. package/components/app/Section.svelte.d.ts +27 -0
  31. package/{src/lib/components → components}/app/Table.svelte +0 -0
  32. package/components/app/Table.svelte.d.ts +27 -0
  33. package/{src/lib/components → components}/app/TextInput.svelte +9 -12
  34. package/components/app/TextInput.svelte.d.ts +22 -0
  35. package/{src/lib/components → components}/chapter/Atom.svelte +12 -18
  36. package/components/chapter/Atom.svelte.d.ts +19 -0
  37. package/components/chapter/Block.svelte +37 -0
  38. package/components/chapter/Block.svelte.d.ts +17 -0
  39. package/{src/lib/components → components}/chapter/Callout.svelte +3 -6
  40. package/components/chapter/Callout.svelte.d.ts +17 -0
  41. package/{src/lib/components → components}/chapter/CaptionedCode.svelte +13 -21
  42. package/components/chapter/CaptionedCode.svelte.d.ts +17 -0
  43. package/{src/lib/components → components}/chapter/ChapterBody.svelte +9 -13
  44. package/components/chapter/ChapterBody.svelte.d.ts +19 -0
  45. package/{src/lib/components → components}/chapter/Citations.svelte +33 -34
  46. package/components/chapter/Citations.svelte.d.ts +17 -0
  47. package/{src/lib/components → components}/chapter/Code.svelte +60 -64
  48. package/components/chapter/Code.svelte.d.ts +22 -0
  49. package/{src/lib/components → components}/chapter/Comment.svelte +18 -30
  50. package/components/chapter/Comment.svelte.d.ts +17 -0
  51. package/{src/lib/components → components}/chapter/Definition.svelte +17 -23
  52. package/components/chapter/Definition.svelte.d.ts +17 -0
  53. package/{src/lib/components → components}/chapter/Embed.svelte +77 -97
  54. package/components/chapter/Embed.svelte.d.ts +20 -0
  55. package/components/chapter/ErrorMessage.svelte +9 -0
  56. package/components/chapter/ErrorMessage.svelte.d.ts +17 -0
  57. package/components/chapter/ExtendedPrism.d.ts +2 -0
  58. package/{src/lib/components → components}/chapter/ExtendedPrism.js +0 -0
  59. package/{src/lib/components → components}/chapter/Figure.svelte +26 -34
  60. package/components/chapter/Figure.svelte.d.ts +24 -0
  61. package/{src/lib/components → components}/chapter/Footnote.svelte +20 -32
  62. package/components/chapter/Footnote.svelte.d.ts +19 -0
  63. package/{src/lib/components → components}/chapter/Format.svelte +34 -39
  64. package/components/chapter/Format.svelte.d.ts +19 -0
  65. package/{src/lib/components → components}/chapter/InlineCode.svelte +5 -9
  66. package/components/chapter/InlineCode.svelte.d.ts +17 -0
  67. package/{src/lib/components → components}/chapter/Label.svelte +14 -23
  68. package/components/chapter/Label.svelte.d.ts +17 -0
  69. package/{src/lib/components → components}/chapter/Link.svelte +21 -27
  70. package/components/chapter/Link.svelte.d.ts +17 -0
  71. package/{src/lib/components → components}/chapter/List.svelte +3 -5
  72. package/components/chapter/List.svelte.d.ts +17 -0
  73. package/{src/lib/components → components}/chapter/Marginal.svelte +41 -54
  74. package/components/chapter/Marginal.svelte.d.ts +22 -0
  75. package/{src/lib/components → components}/chapter/Paragraph.svelte +20 -25
  76. package/components/chapter/Paragraph.svelte.d.ts +18 -0
  77. package/{src/lib/components → components}/chapter/Positioned.svelte +1 -4
  78. package/components/chapter/Positioned.svelte.d.ts +19 -0
  79. package/{src/lib/components → components}/chapter/Problem.svelte +0 -0
  80. package/components/chapter/Problem.svelte.d.ts +27 -0
  81. package/components/chapter/Python.svelte +128 -0
  82. package/components/chapter/Python.svelte.d.ts +18 -0
  83. package/{src/lib/components → components}/chapter/Quote.svelte +19 -13
  84. package/components/chapter/Quote.svelte.d.ts +17 -0
  85. package/{src/lib/components → components}/chapter/Rule.svelte +1 -4
  86. package/components/chapter/Rule.svelte.d.ts +17 -0
  87. package/{src/lib/components → components}/chapter/Table.svelte +7 -11
  88. package/components/chapter/Table.svelte.d.ts +17 -0
  89. package/components/chapter/Text.svelte +87 -0
  90. package/components/chapter/Text.svelte.d.ts +18 -0
  91. package/components/editor/BookishEditor.svelte +884 -0
  92. package/components/editor/BookishEditor.svelte.d.ts +25 -0
  93. package/components/editor/CalloutEditor.svelte +10 -0
  94. package/components/editor/CalloutEditor.svelte.d.ts +17 -0
  95. package/{src/lib/components → components}/editor/CaptionedCodeEditor.svelte +6 -10
  96. package/components/editor/CaptionedCodeEditor.svelte.d.ts +17 -0
  97. package/components/editor/CaretContext.d.ts +50 -0
  98. package/components/editor/CaretContext.js +1 -0
  99. package/{src/lib/components/editor/CaretState.ts → components/editor/CaretState.d.ts} +7 -6
  100. package/components/editor/CaretState.js +1 -0
  101. package/{src/lib/components/editor/CaretUtilities.ts → components/editor/CaretUtilities.d.ts} +0 -1
  102. package/components/editor/CaretUtilities.js +1 -0
  103. package/{src/lib/components → components}/editor/CaretView.svelte +20 -25
  104. package/components/editor/CaretView.svelte.d.ts +25 -0
  105. package/components/editor/CitationsEditor.svelte +53 -0
  106. package/components/editor/CitationsEditor.svelte.d.ts +17 -0
  107. package/{src/lib/components/editor/Clipboard.ts → components/editor/Clipboard.d.ts} +1 -2
  108. package/components/editor/Clipboard.js +1 -0
  109. package/{src/lib/components/editor/Command.ts → components/editor/Command.d.ts} +2 -8
  110. package/components/editor/Command.js +1 -0
  111. package/components/editor/Commands.d.ts +3 -0
  112. package/{src/lib/components/editor/Commands.ts → components/editor/Commands.js} +315 -730
  113. package/components/editor/ConfirmButton.svelte +49 -0
  114. package/components/editor/ConfirmButton.svelte.d.ts +19 -0
  115. package/components/editor/DefinitionEditor.svelte +36 -0
  116. package/components/editor/DefinitionEditor.svelte.d.ts +17 -0
  117. package/components/editor/EmbedEditor.svelte +137 -0
  118. package/components/editor/EmbedEditor.svelte.d.ts +17 -0
  119. package/{src/lib/components → components}/editor/Icon.svelte +1 -2
  120. package/components/editor/Icon.svelte.d.ts +16 -0
  121. package/{src/lib/components → components}/editor/ImageChooser.svelte +19 -24
  122. package/components/editor/ImageChooser.svelte.d.ts +18 -0
  123. package/components/editor/InlineCodeEditor.svelte +12 -0
  124. package/components/editor/InlineCodeEditor.svelte.d.ts +17 -0
  125. package/{src/lib/components → components}/editor/LabelEditor.svelte +9 -14
  126. package/components/editor/LabelEditor.svelte.d.ts +17 -0
  127. package/{src/lib/components → components}/editor/LanguageEditor.svelte +5 -8
  128. package/components/editor/LanguageEditor.svelte.d.ts +17 -0
  129. package/components/editor/LinkEditor.svelte +100 -0
  130. package/components/editor/LinkEditor.svelte.d.ts +17 -0
  131. package/{src/lib/components → components}/editor/Note.svelte +0 -0
  132. package/components/editor/Note.svelte.d.ts +27 -0
  133. package/{src/lib/components → components}/editor/Permissions.svelte +36 -43
  134. package/components/editor/Permissions.svelte.d.ts +20 -0
  135. package/components/editor/PositionEditor.svelte +17 -0
  136. package/components/editor/PositionEditor.svelte.d.ts +18 -0
  137. package/components/editor/QuoteEditor.svelte +10 -0
  138. package/components/editor/QuoteEditor.svelte.d.ts +17 -0
  139. package/{src/lib/components → components}/editor/Switch.svelte +11 -14
  140. package/components/editor/Switch.svelte.d.ts +20 -0
  141. package/components/editor/TableEditor.svelte +10 -0
  142. package/components/editor/TableEditor.svelte.d.ts +17 -0
  143. package/{src/lib/components → components}/editor/TextEditor.svelte +89 -101
  144. package/components/editor/TextEditor.svelte.d.ts +24 -0
  145. package/components/editor/Toggle.svelte +41 -0
  146. package/components/editor/Toggle.svelte.d.ts +19 -0
  147. package/components/editor/Toolbar.svelte +249 -0
  148. package/components/editor/Toolbar.svelte.d.ts +17 -0
  149. package/{src/lib/components → components}/editor/ToolbarGroup.svelte +3 -5
  150. package/components/editor/ToolbarGroup.svelte.d.ts +18 -0
  151. package/{src/lib/components → components}/editor/ToolbarSpacer.svelte +0 -0
  152. package/components/editor/ToolbarSpacer.svelte.d.ts +23 -0
  153. package/components/editor/URLEditor.svelte +13 -0
  154. package/components/editor/URLEditor.svelte.d.ts +18 -0
  155. package/{src/lib/components/editor/UndoState.ts → components/editor/UndoState.d.ts} +2 -3
  156. package/components/editor/UndoState.js +1 -0
  157. package/{src/lib/components → components}/editor/icons/annotate.svg +0 -0
  158. package/{src/lib/components → components}/editor/icons/block.svg +0 -0
  159. package/{src/lib/components → components}/editor/icons/bold.svg +0 -0
  160. package/{src/lib/components → components}/editor/icons/bullets.svg +0 -0
  161. package/{src/lib/components → components}/editor/icons/callout.svg +0 -0
  162. package/{src/lib/components → components}/editor/icons/citation.svg +0 -0
  163. package/{src/lib/components → components}/editor/icons/clear.svg +0 -0
  164. package/{src/lib/components → components}/editor/icons/clipboard.svg +0 -0
  165. package/{src/lib/components → components}/editor/icons/code.svg +0 -0
  166. package/{src/lib/components → components}/editor/icons/columnafter.svg +0 -0
  167. package/{src/lib/components → components}/editor/icons/columnbefore.svg +0 -0
  168. package/{src/lib/components → components}/editor/icons/comment.svg +0 -0
  169. package/{src/lib/components → components}/editor/icons/copy.svg +0 -0
  170. package/{src/lib/components → components}/editor/icons/cut.svg +0 -0
  171. package/{src/lib/components → components}/editor/icons/define.svg +0 -0
  172. package/{src/lib/components → components}/editor/icons/deletecolumn.svg +0 -0
  173. package/{src/lib/components → components}/editor/icons/deleterow.svg +0 -0
  174. package/{src/lib/components → components}/editor/icons/footnote.svg +0 -0
  175. package/{src/lib/components → components}/editor/icons/header1.svg +0 -0
  176. package/{src/lib/components → components}/editor/icons/header2.svg +0 -0
  177. package/{src/lib/components → components}/editor/icons/header3.svg +0 -0
  178. package/{src/lib/components → components}/editor/icons/home.svg +0 -0
  179. package/{src/lib/components → components}/editor/icons/indent.svg +0 -0
  180. package/{src/lib/components → components}/editor/icons/italic.svg +0 -0
  181. package/{src/lib/components → components}/editor/icons/label.svg +0 -0
  182. package/{src/lib/components → components}/editor/icons/left.svg +0 -0
  183. package/{src/lib/components → components}/editor/icons/level.svg +0 -0
  184. package/{src/lib/components → components}/editor/icons/link.svg +0 -0
  185. package/{src/lib/components → components}/editor/icons/list.svg +0 -0
  186. package/{src/lib/components → components}/editor/icons/media.svg +0 -0
  187. package/{src/lib/components → components}/editor/icons/middle.svg +0 -0
  188. package/{src/lib/components → components}/editor/icons/numbers.svg +0 -0
  189. package/{src/lib/components → components}/editor/icons/paragraph.svg +0 -0
  190. package/{src/lib/components → components}/editor/icons/paste.svg +0 -0
  191. package/{src/lib/components → components}/editor/icons/quote.svg +0 -0
  192. package/{src/lib/components → components}/editor/icons/redo.svg +0 -0
  193. package/{src/lib/components → components}/editor/icons/right.svg +0 -0
  194. package/{src/lib/components → components}/editor/icons/rowabove.svg +0 -0
  195. package/{src/lib/components → components}/editor/icons/rowbelow.svg +0 -0
  196. package/{src/lib/components → components}/editor/icons/rule.svg +0 -0
  197. package/{src/lib/components → components}/editor/icons/sub.svg +0 -0
  198. package/{src/lib/components → components}/editor/icons/super.svg +0 -0
  199. package/{src/lib/components → components}/editor/icons/table.svg +0 -0
  200. package/{src/lib/components → components}/editor/icons/text.svg +0 -0
  201. package/{src/lib/components → components}/editor/icons/time.svg +0 -0
  202. package/{src/lib/components → components}/editor/icons/undo.svg +0 -0
  203. package/{src/lib/components → components}/editor/icons/unindent.svg +0 -0
  204. package/{src/lib/components → components}/editor/icons/unlink.svg +0 -0
  205. package/{src/lib/components → components}/page/Acknowledgements.svelte +10 -19
  206. package/components/page/Acknowledgements.svelte.d.ts +14 -0
  207. package/components/page/Authors.svelte +85 -0
  208. package/components/page/Authors.svelte.d.ts +21 -0
  209. package/components/page/BookLoader.svelte +59 -0
  210. package/components/page/BookLoader.svelte.d.ts +16 -0
  211. package/components/page/BulkReferenceEditor.svelte +63 -0
  212. package/components/page/BulkReferenceEditor.svelte.d.ts +14 -0
  213. package/components/page/Chapter.svelte +393 -0
  214. package/components/page/Chapter.svelte.d.ts +18 -0
  215. package/components/page/ChapterContext.d.ts +10 -0
  216. package/components/page/ChapterContext.js +1 -0
  217. package/{src/lib/components → components}/page/ChapterNumber.svelte +0 -0
  218. package/components/page/ChapterNumber.svelte.d.ts +27 -0
  219. package/{src/lib/components → components}/page/ChapterTitle.svelte +2 -4
  220. package/components/page/ChapterTitle.svelte.d.ts +18 -0
  221. package/components/page/Contexts.d.ts +47 -0
  222. package/components/page/Contexts.js +133 -0
  223. package/{src/lib/components → components}/page/DefinitionView.svelte +38 -53
  224. package/components/page/DefinitionView.svelte.d.ts +18 -0
  225. package/{src/lib/components → components}/page/Description.svelte +7 -15
  226. package/components/page/Description.svelte.d.ts +14 -0
  227. package/components/page/Edition.svelte +161 -0
  228. package/components/page/Edition.svelte.d.ts +20 -0
  229. package/components/page/EditionLoader.svelte +99 -0
  230. package/components/page/EditionLoader.svelte.d.ts +18 -0
  231. package/{src/lib/components → components}/page/Editions.svelte +18 -22
  232. package/components/page/Editions.svelte.d.ts +14 -0
  233. package/{src/lib/components → components}/page/Glossary.svelte +28 -33
  234. package/components/page/Glossary.svelte.d.ts +14 -0
  235. package/{src/lib/components → components}/page/Header.svelte +52 -59
  236. package/components/page/Header.svelte.d.ts +29 -0
  237. package/{src/lib/components → components}/page/Index.svelte +47 -50
  238. package/components/page/Index.svelte.d.ts +14 -0
  239. package/{src/lib/components → components}/page/Instructions.svelte +1 -2
  240. package/components/page/Instructions.svelte.d.ts +18 -0
  241. package/{src/lib/components → components}/page/License.svelte +9 -17
  242. package/components/page/License.svelte.d.ts +14 -0
  243. package/{src/lib/components → components}/page/Loading.svelte +0 -0
  244. package/components/page/Loading.svelte.d.ts +23 -0
  245. package/{src/lib/components → components}/page/Media.svelte +27 -44
  246. package/components/page/Media.svelte.d.ts +14 -0
  247. package/{src/lib/components → components}/page/MediaPreview.svelte +2 -3
  248. package/components/page/MediaPreview.svelte.d.ts +19 -0
  249. package/{src/lib/components → components}/page/Muted.svelte +0 -0
  250. package/components/page/Muted.svelte.d.ts +27 -0
  251. package/{src/lib/components → components}/page/Outline.svelte +110 -140
  252. package/components/page/Outline.svelte.d.ts +19 -0
  253. package/components/page/Page.svelte +84 -0
  254. package/components/page/Page.svelte.d.ts +19 -0
  255. package/{src/lib/components → components}/page/PageHeader.svelte +1 -2
  256. package/components/page/PageHeader.svelte.d.ts +18 -0
  257. package/{src/lib/components → components}/page/PageParagraph.svelte +0 -0
  258. package/components/page/PageParagraph.svelte.d.ts +27 -0
  259. package/components/page/PossibleChapter.svelte +14 -0
  260. package/components/page/PossibleChapter.svelte.d.ts +14 -0
  261. package/components/page/PossibleReference.svelte +11 -0
  262. package/components/page/PossibleReference.svelte.d.ts +18 -0
  263. package/{src/lib/components → components}/page/Print.svelte +3 -5
  264. package/components/page/Print.svelte.d.ts +14 -0
  265. package/{src/lib/components → components}/page/Publish.svelte +52 -59
  266. package/components/page/Publish.svelte.d.ts +14 -0
  267. package/{src/lib/components → components}/page/Reference.svelte +30 -39
  268. package/components/page/Reference.svelte.d.ts +17 -0
  269. package/{src/lib/components → components}/page/References.svelte +14 -18
  270. package/components/page/References.svelte.d.ts +14 -0
  271. package/{src/lib/components → components}/page/Rows.svelte +0 -0
  272. package/components/page/Rows.svelte.d.ts +27 -0
  273. package/components/page/Search.svelte +133 -0
  274. package/components/page/Search.svelte.d.ts +14 -0
  275. package/{src/lib/components → components}/page/Status.svelte +3 -5
  276. package/components/page/Status.svelte.d.ts +14 -0
  277. package/{src/lib/components → components}/page/SubdomainEditor.svelte +13 -16
  278. package/components/page/SubdomainEditor.svelte.d.ts +14 -0
  279. package/{src/lib/components → components}/page/TableOfContents.svelte +68 -79
  280. package/components/page/TableOfContents.svelte.d.ts +14 -0
  281. package/components/page/TableOfContentsImage.svelte +18 -0
  282. package/components/page/TableOfContentsImage.svelte.d.ts +16 -0
  283. package/{src/lib/components → components}/page/TableOfContentsRow.svelte +24 -34
  284. package/components/page/TableOfContentsRow.svelte.d.ts +24 -0
  285. package/{src/lib/components → components}/page/ThemeEditor.svelte +33 -44
  286. package/components/page/ThemeEditor.svelte.d.ts +14 -0
  287. package/{src/lib/components → components}/page/ThemeEditorPreview.svelte +12 -21
  288. package/components/page/ThemeEditorPreview.svelte.d.ts +17 -0
  289. package/components/page/ThemeSetEditor.svelte +19 -0
  290. package/components/page/ThemeSetEditor.svelte.d.ts +18 -0
  291. package/{src/lib/components → components}/page/ThemeVariableEditor.svelte +14 -18
  292. package/components/page/ThemeVariableEditor.svelte.d.ts +18 -0
  293. package/{src/lib/components → components}/page/Title.svelte +0 -0
  294. package/components/page/Title.svelte.d.ts +27 -0
  295. package/{src/lib/components → components}/page/Unknown.svelte +8 -10
  296. package/components/page/Unknown.svelte.d.ts +16 -0
  297. package/components/page/margins.d.ts +2 -0
  298. package/{src/lib/components/page/margins.ts → components/page/margins.js} +46 -79
  299. package/index.d.ts +15 -0
  300. package/{src/lib/index.js → index.js} +0 -0
  301. package/models/CRUD.d.ts +27 -0
  302. package/models/CRUD.js +262 -0
  303. package/models/Firebase.d.ts +5 -0
  304. package/{src/lib/models/Firebase.ts → models/Firebase.js} +16 -26
  305. package/models/book/Book.d.ts +61 -0
  306. package/models/book/Book.js +135 -0
  307. package/models/book/BookMedia.d.ts +23 -0
  308. package/models/book/BookMedia.js +108 -0
  309. package/models/book/BookSaveStatus.d.ts +7 -0
  310. package/models/book/BookSaveStatus.js +8 -0
  311. package/models/book/Chapter.d.ts +81 -0
  312. package/models/book/Chapter.js +212 -0
  313. package/models/book/ChapterID.d.ts +10 -0
  314. package/{src/lib/models/book/ChapterID.ts → models/book/ChapterID.js} +0 -1
  315. package/models/book/Definition.d.ts +6 -0
  316. package/models/book/Definition.js +1 -0
  317. package/models/book/Edition.d.ts +139 -0
  318. package/models/book/Edition.js +620 -0
  319. package/models/book/Reference.d.ts +24 -0
  320. package/models/book/Reference.js +78 -0
  321. package/models/book/Schema.d.ts +174 -0
  322. package/{src/lib/models/book/Schema.ts → models/book/Schema.js} +0 -1
  323. package/models/book/Theme.d.ts +113 -0
  324. package/{src/lib/models/book/Theme.ts → models/book/Theme.js} +6 -110
  325. package/{src/lib/models/book/ThemeColors.ts → models/book/ThemeColors.d.ts} +0 -6
  326. package/models/book/ThemeColors.js +1 -0
  327. package/models/book/Words.d.ts +2 -0
  328. package/{src/lib/models/book/Words.ts → models/book/Words.js} +0 -1
  329. package/models/chapter/AtomNode.d.ts +18 -0
  330. package/{src/lib/models/chapter/AtomNode.ts → models/chapter/AtomNode.js} +10 -30
  331. package/models/chapter/BlockNode.d.ts +20 -0
  332. package/{src/lib/models/chapter/BlockNode.ts → models/chapter/BlockNode.js} +47 -80
  333. package/models/chapter/BlocksNode.d.ts +50 -0
  334. package/{src/lib/models/chapter/BlocksNode.ts → models/chapter/BlocksNode.js} +359 -571
  335. package/models/chapter/BlocksNode.test.d.ts +1 -0
  336. package/models/chapter/BlocksNode.test.js +568 -0
  337. package/{src/lib/models/chapter/Bookkeeping.ts → models/chapter/Bookkeeping.d.ts} +0 -0
  338. package/models/chapter/Bookkeeping.js +1 -0
  339. package/models/chapter/CalloutNode.d.ts +17 -0
  340. package/models/chapter/CalloutNode.js +58 -0
  341. package/models/chapter/Caret.d.ts +23 -0
  342. package/{src/lib/models/chapter/Caret.ts → models/chapter/Caret.js} +26 -50
  343. package/models/chapter/ChapterNode.d.ts +34 -0
  344. package/models/chapter/ChapterNode.js +117 -0
  345. package/models/chapter/CitationsNode.d.ts +16 -0
  346. package/{src/lib/models/chapter/CitationsNode.ts → models/chapter/CitationsNode.js} +10 -17
  347. package/models/chapter/CodeNode.d.ts +35 -0
  348. package/{src/lib/models/chapter/CodeNode.ts → models/chapter/CodeNode.js} +62 -125
  349. package/models/chapter/CommentNode.d.ts +18 -0
  350. package/models/chapter/CommentNode.js +48 -0
  351. package/models/chapter/DefinitionNode.d.ts +12 -0
  352. package/{src/lib/models/chapter/DefinitionNode.ts → models/chapter/DefinitionNode.js} +8 -14
  353. package/models/chapter/Edit.d.ts +7 -0
  354. package/models/chapter/Edit.js +1 -0
  355. package/models/chapter/EmbedNode.d.ts +45 -0
  356. package/models/chapter/EmbedNode.js +168 -0
  357. package/models/chapter/ErrorNode.d.ts +17 -0
  358. package/{src/lib/models/chapter/ErrorNode.ts → models/chapter/ErrorNode.js} +8 -15
  359. package/models/chapter/FootnoteNode.d.ts +18 -0
  360. package/models/chapter/FootnoteNode.js +47 -0
  361. package/models/chapter/FormatNode.d.ts +60 -0
  362. package/{src/lib/models/chapter/FormatNode.ts → models/chapter/FormatNode.js} +262 -443
  363. package/models/chapter/FormatNode.test.d.ts +1 -0
  364. package/models/chapter/FormatNode.test.js +96 -0
  365. package/models/chapter/InlineCodeNode.d.ts +12 -0
  366. package/{src/lib/models/chapter/InlineCodeNode.ts → models/chapter/InlineCodeNode.js} +9 -17
  367. package/models/chapter/LabelNode.d.ts +17 -0
  368. package/{src/lib/models/chapter/LabelNode.ts → models/chapter/LabelNode.js} +10 -26
  369. package/models/chapter/LinkNode.d.ts +12 -0
  370. package/{src/lib/models/chapter/LinkNode.ts → models/chapter/LinkNode.js} +7 -12
  371. package/models/chapter/ListNode.d.ts +51 -0
  372. package/{src/lib/models/chapter/ListNode.ts → models/chapter/ListNode.js} +200 -277
  373. package/models/chapter/ListNode.test.d.ts +1 -0
  374. package/{src/lib/models/chapter/ListNode.test.ts → models/chapter/ListNode.test.js} +20 -57
  375. package/models/chapter/MetadataNode.d.ts +17 -0
  376. package/models/chapter/MetadataNode.js +32 -0
  377. package/models/chapter/Node.d.ts +38 -0
  378. package/{src/lib/models/chapter/Node.ts → models/chapter/Node.js} +71 -155
  379. package/models/chapter/Node.test.d.ts +1 -0
  380. package/{src/lib/models → models}/chapter/Node.test.js +0 -0
  381. package/models/chapter/ParagraphNode.d.ts +33 -0
  382. package/{src/lib/models/chapter/ParagraphNode.ts → models/chapter/ParagraphNode.js} +58 -95
  383. package/models/chapter/ParagraphNode.test.d.ts +1 -0
  384. package/models/chapter/ParagraphNode.test.js +30 -0
  385. package/models/chapter/Parser.d.ts +75 -0
  386. package/{src/lib/models/chapter/Parser.ts → models/chapter/Parser.js} +184 -369
  387. package/models/chapter/Parser.test.d.ts +1 -0
  388. package/{src/lib/models/chapter/Parser.test.ts → models/chapter/Parser.test.js} +0 -7
  389. package/{src/lib/models/chapter/Position.ts → models/chapter/Position.d.ts} +0 -0
  390. package/models/chapter/Position.js +1 -0
  391. package/models/chapter/QuoteNode.d.ts +25 -0
  392. package/models/chapter/QuoteNode.js +99 -0
  393. package/{src/lib/models/chapter/RootNode.ts → models/chapter/RootNode.d.ts} +0 -2
  394. package/models/chapter/RootNode.js +1 -0
  395. package/models/chapter/RuleNode.d.ts +15 -0
  396. package/{src/lib/models/chapter/RuleNode.ts → models/chapter/RuleNode.js} +6 -9
  397. package/models/chapter/TableNode.d.ts +37 -0
  398. package/{src/lib/models/chapter/TableNode.ts → models/chapter/TableNode.js} +82 -141
  399. package/models/chapter/TableNode.test.d.ts +1 -0
  400. package/{src/lib/models/chapter/TableNode.test.ts → models/chapter/TableNode.test.js} +10 -27
  401. package/models/chapter/TextNode.d.ts +36 -0
  402. package/{src/lib/models/chapter/TextNode.ts → models/chapter/TextNode.js} +65 -117
  403. package/models/chapter/TextNode.test.d.ts +1 -0
  404. package/{src/lib/models/chapter/TextNode.test.ts → models/chapter/TextNode.test.js} +0 -2
  405. package/package.json +270 -53
  406. package/util/getSubdomain.d.ts +3 -0
  407. package/{src/lib/util/getSubdomain.ts → util/getSubdomain.js} +8 -14
  408. package/util/isMobile.d.ts +2 -0
  409. package/{src/lib/util/isMobile.ts → util/isMobile.js} +0 -1
  410. package/util/mineReference.d.ts +4 -0
  411. package/{src/lib/util/mineReference.ts → util/mineReference.js} +25 -45
  412. package/util/scrollToEyeLevel.d.ts +2 -0
  413. package/{src/lib/util/scrollToEyeLevel.ts → util/scrollToEyeLevel.js} +2 -4
  414. package/.env.example +0 -8
  415. package/.firebaserc +0 -8
  416. package/.prettierignore +0 -8
  417. package/.prettierrc.json +0 -5
  418. package/_update-notifier-last-checked +0 -0
  419. package/firebase.json +0 -46
  420. package/firestore.indexes.json +0 -4
  421. package/firestore.rules +0 -59
  422. package/functions/.eslintrc.js +0 -28
  423. package/functions/package-lock.json +0 -12595
  424. package/functions/package.json +0 -43
  425. package/functions/src/index.ts +0 -345
  426. package/functions/tsconfig.dev.json +0 -3
  427. package/functions/tsconfig.json +0 -15
  428. package/scripts/claims.cjs +0 -99
  429. package/src/app.d.ts +0 -9
  430. package/src/app.html +0 -24
  431. package/src/lib/components/Auth.svelte +0 -65
  432. package/src/lib/components/Link.svelte +0 -58
  433. package/src/lib/components/chapter/Block.svelte +0 -42
  434. package/src/lib/components/chapter/ErrorMessage.svelte +0 -12
  435. package/src/lib/components/chapter/Python.svelte +0 -144
  436. package/src/lib/components/chapter/Text.svelte +0 -109
  437. package/src/lib/components/editor/BookishEditor.svelte +0 -1101
  438. package/src/lib/components/editor/CalloutEditor.svelte +0 -14
  439. package/src/lib/components/editor/CaretContext.ts +0 -55
  440. package/src/lib/components/editor/CitationsEditor.svelte +0 -64
  441. package/src/lib/components/editor/ConfirmButton.svelte +0 -51
  442. package/src/lib/components/editor/DefinitionEditor.svelte +0 -44
  443. package/src/lib/components/editor/EmbedEditor.svelte +0 -152
  444. package/src/lib/components/editor/InlineCodeEditor.svelte +0 -16
  445. package/src/lib/components/editor/LinkEditor.svelte +0 -110
  446. package/src/lib/components/editor/PositionEditor.svelte +0 -21
  447. package/src/lib/components/editor/QuoteEditor.svelte +0 -14
  448. package/src/lib/components/editor/TableEditor.svelte +0 -14
  449. package/src/lib/components/editor/Toggle.svelte +0 -47
  450. package/src/lib/components/editor/Toolbar.svelte +0 -297
  451. package/src/lib/components/editor/URLEditor.svelte +0 -15
  452. package/src/lib/components/page/Authors.svelte +0 -92
  453. package/src/lib/components/page/BookLoader.svelte +0 -77
  454. package/src/lib/components/page/BulkReferenceEditor.svelte +0 -86
  455. package/src/lib/components/page/Chapter.svelte +0 -449
  456. package/src/lib/components/page/ChapterContext.ts +0 -13
  457. package/src/lib/components/page/Contexts.ts +0 -176
  458. package/src/lib/components/page/Edition.svelte +0 -189
  459. package/src/lib/components/page/EditionLoader.svelte +0 -123
  460. package/src/lib/components/page/Page.svelte +0 -94
  461. package/src/lib/components/page/PossibleChapter.svelte +0 -16
  462. package/src/lib/components/page/PossibleReference.svelte +0 -14
  463. package/src/lib/components/page/Search.svelte +0 -153
  464. package/src/lib/components/page/TableOfContentsImage.svelte +0 -22
  465. package/src/lib/components/page/ThemeSetEditor.svelte +0 -21
  466. package/src/lib/models/CRUD.ts +0 -469
  467. package/src/lib/models/book/Book.ts +0 -283
  468. package/src/lib/models/book/BookMedia.ts +0 -182
  469. package/src/lib/models/book/BookSaveStatus.ts +0 -8
  470. package/src/lib/models/book/Chapter.ts +0 -462
  471. package/src/lib/models/book/Definition.ts +0 -2
  472. package/src/lib/models/book/Edition.ts +0 -1216
  473. package/src/lib/models/book/Reference.ts +0 -171
  474. package/src/lib/models/chapter/BlocksNode.test.ts +0 -867
  475. package/src/lib/models/chapter/CalloutNode.ts +0 -79
  476. package/src/lib/models/chapter/ChapterNode.ts +0 -169
  477. package/src/lib/models/chapter/CommentNode.ts +0 -61
  478. package/src/lib/models/chapter/Edit.ts +0 -6
  479. package/src/lib/models/chapter/EmbedNode.ts +0 -257
  480. package/src/lib/models/chapter/FootnoteNode.ts +0 -59
  481. package/src/lib/models/chapter/FormatNode.test.ts +0 -137
  482. package/src/lib/models/chapter/MetadataNode.ts +0 -44
  483. package/src/lib/models/chapter/ParagraphNode.test.ts +0 -54
  484. package/src/lib/models/chapter/QuoteNode.ts +0 -135
  485. package/src/params/edition.ts +0 -3
  486. package/src/routes/+error.svelte +0 -12
  487. package/src/routes/+layout.svelte +0 -241
  488. package/src/routes/+page.svelte +0 -43
  489. package/src/routes/Footer.svelte +0 -0
  490. package/src/routes/Header.svelte +0 -112
  491. package/src/routes/[bookid]/+layout.svelte +0 -5
  492. package/src/routes/[bookid]/[[editionid=edition]]/+error.svelte +0 -14
  493. package/src/routes/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
  494. package/src/routes/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
  495. package/src/routes/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
  496. package/src/routes/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
  497. package/src/routes/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
  498. package/src/routes/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
  499. package/src/routes/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
  500. package/src/routes/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
  501. package/src/routes/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
  502. package/src/routes/[bookid]/editions/+page.svelte +0 -20
  503. package/src/routes/about/+page.svelte +0 -102
  504. package/src/routes/confirm/+page.svelte +0 -62
  505. package/src/routes/email/+page.svelte +0 -99
  506. package/src/routes/login/+page.svelte +0 -66
  507. package/src/routes/read/+page.svelte +0 -38
  508. package/src/routes/write/+error.svelte +0 -10
  509. package/src/routes/write/+layout.svelte +0 -11
  510. package/src/routes/write/+page.svelte +0 -114
  511. package/src/routes/write/[bookid]/+layout.svelte +0 -5
  512. package/src/routes/write/[bookid]/[[editionid=edition]]/+layout.svelte +0 -7
  513. package/src/routes/write/[bookid]/[[editionid=edition]]/+page.svelte +0 -5
  514. package/src/routes/write/[bookid]/[[editionid=edition]]/[chapterid]/+page.svelte +0 -5
  515. package/src/routes/write/[bookid]/[[editionid=edition]]/glossary/+page.svelte +0 -5
  516. package/src/routes/write/[bookid]/[[editionid=edition]]/index/[[letter]]/+page.svelte +0 -5
  517. package/src/routes/write/[bookid]/[[editionid=edition]]/media/+page.svelte +0 -5
  518. package/src/routes/write/[bookid]/[[editionid=edition]]/print/+page.svelte +0 -5
  519. package/src/routes/write/[bookid]/[[editionid=edition]]/references/+page.svelte +0 -5
  520. package/src/routes/write/[bookid]/[[editionid=edition]]/search/+page.svelte +0 -5
  521. package/src/routes/write/[bookid]/[[editionid=edition]]/theme/+page.svelte +0 -5
  522. package/src/routes/write/[bookid]/[[editionid=edition]]/unknown/+page.svelte +0 -5
  523. package/src/routes/write/[bookid]/editions/+page.svelte +0 -20
  524. package/src/vite-env.d.ts +0 -1
  525. package/static/icons/favicon.png +0 -0
  526. package/static/icons/icon.png +0 -0
  527. package/static/icons/ios-icon.png +0 -0
  528. package/storage.rules +0 -9
  529. package/svelte.config.js +0 -19
  530. package/tsconfig.json +0 -18
  531. package/tsconfig.node.json +0 -9
  532. package/vite.config.ts +0 -8
  533. package/vite.reader.config.ts +0 -32
@@ -1,4 +1,3 @@
1
- import type Edition from '../book/Edition';
2
1
  import CalloutNode from './CalloutNode';
3
2
  import ChapterNode from './ChapterNode';
4
3
  import CitationsNode from './CitationsNode';
@@ -9,7 +8,6 @@ import EmbedNode from './EmbedNode';
9
8
  import ErrorNode from './ErrorNode';
10
9
  import FootnoteNode from './FootnoteNode';
11
10
  import FormatNode from './FormatNode';
12
- import type { Format, FormatNodeSegmentType } from './FormatNode';
13
11
  import InlineCodeNode from './InlineCodeNode';
14
12
  import LabelNode from './LabelNode';
15
13
  import LinkNode from './LinkNode';
@@ -20,13 +18,8 @@ import Reference from '../book/Reference';
20
18
  import RuleNode from './RuleNode';
21
19
  import TableNode from './TableNode';
22
20
  import TextNode from './TextNode';
23
- import type Position from './Position';
24
- import type BlockNode from './BlockNode';
25
- import type Bookkeeping from './Bookkeeping';
26
-
27
21
  const numberedRE = /^[0-9]+\.+/;
28
22
  const bulletRE = /^\*+\s+/;
29
-
30
23
  // TODO This grammar is slightly out of date.
31
24
  // A simple recursive descent parser for this grammar.
32
25
  // Embeds a tokenizer, since the lexical grammar is simple.
@@ -52,19 +45,16 @@ const bulletRE = /^\*+\s+/;
52
45
  // LINK :: [CONTENT|TEXT]
53
46
  // FOOTNOTE :: {TEXT}
54
47
  // TEXT :: (.+)
55
-
56
48
  export default class Parser {
57
- book: Edition | undefined;
58
- text: string;
59
- index: number;
60
- openedDoubleQuote: boolean;
49
+ book;
50
+ text;
51
+ index;
52
+ openedDoubleQuote;
61
53
  // We pass this to all parsing functions to gather information strewn about the document.
62
- metadata: Bookkeeping;
63
-
64
- constructor(book: Edition | undefined, text: string) {
54
+ metadata;
55
+ constructor(book, text) {
65
56
  if (typeof text !== 'string')
66
57
  throw 'Parser expected a string but received ' + typeof text;
67
-
68
58
  this.book = book;
69
59
  this.text = text;
70
60
  this.index = 0; // Start at the first character.
@@ -73,91 +63,65 @@ export default class Parser {
73
63
  symbols: {},
74
64
  };
75
65
  }
76
-
77
- static preprocessSymbols(book: Edition, text: string) {
66
+ static preprocessSymbols(book, text) {
78
67
  // Replace any remaining symbols with any definitions given.
79
68
  if (book && book.getSymbols()) {
80
- for (const [symbol, definition] of Object.entries(
81
- book.getSymbols()
82
- )) {
69
+ for (const [symbol, definition] of Object.entries(book.getSymbols())) {
83
70
  // Don't replace escaped at symbols. Otherwise, be liberal in replacing any matching symbol that starts with the symbol
84
71
  // name and ends with a word boundary.
85
- text = text.replace(
86
- new RegExp('([^\\\\])@' + symbol + '\\b', 'g'),
87
- '$1' + definition
88
- );
72
+ text = text.replace(new RegExp('([^\\\\])@' + symbol + '\\b', 'g'), '$1' + definition);
89
73
  }
90
74
  }
91
75
  return text;
92
76
  }
93
-
94
- static parseChapter(book: Edition | undefined, text: string) {
95
- return new Parser(
96
- book,
97
- book === undefined ? text : Parser.preprocessSymbols(book, text)
98
- ).parseChapter();
99
- }
100
-
101
- static parseFormat(book: Edition | undefined, text: string) {
102
- return new Parser(
103
- book,
104
- book === undefined ? text : Parser.preprocessSymbols(book, text)
105
- ).parseFormat();
106
- }
107
-
108
- static parseEmbed(book: Edition | undefined, text: string) {
109
- return new Parser(
110
- book,
111
- book === undefined ? text : Parser.preprocessSymbols(book, text)
112
- ).parseEmbed();
113
- }
114
-
77
+ static parseChapter(book, text) {
78
+ return new Parser(book, book === undefined ? text : Parser.preprocessSymbols(book, text)).parseChapter();
79
+ }
80
+ static parseFormat(book, text) {
81
+ return new Parser(book, book === undefined ? text : Parser.preprocessSymbols(book, text)).parseFormat();
82
+ }
83
+ static parseEmbed(book, text) {
84
+ return new Parser(book, book === undefined ? text : Parser.preprocessSymbols(book, text)).parseEmbed();
85
+ }
115
86
  // Get the next character, if there is one, null otherwise.
116
- peek(): string | null {
87
+ peek() {
117
88
  return this.more() ? this.text.charAt(this.index) : null;
118
89
  }
119
-
120
90
  // True if there are more characters to parse.
121
- more(): boolean {
91
+ more() {
122
92
  return this.index < this.text.length;
123
93
  }
124
-
125
94
  nextIsEmptyParagraph() {
126
- return (
127
- this.text.charAt(this.index) === '\n' &&
95
+ return (this.text.charAt(this.index) === '\n' &&
128
96
  this.text.charAt(this.index + 1) === '\n' &&
129
- this.text.charAt(this.index + 2) === '\n'
130
- );
97
+ this.text.charAt(this.index + 2) === '\n');
131
98
  }
132
-
133
99
  nextIsWhitespace() {
134
- return (
135
- (this.peek() === ' ' ||
136
- this.peek() === '\t' ||
137
- this.peek() === '\n') &&
138
- !this.nextIsEmptyParagraph()
139
- );
100
+ return ((this.peek() === ' ' ||
101
+ this.peek() === '\t' ||
102
+ this.peek() === '\n') &&
103
+ !this.nextIsEmptyParagraph());
140
104
  }
141
-
142
105
  // Return the current character--if there is one-- and increment the index.
143
- read(smarten = true): string | null {
144
- if (!this.more()) return null;
145
-
106
+ read(smarten = true) {
107
+ if (!this.more())
108
+ return null;
146
109
  let char = this.text.charAt(this.index);
147
-
148
110
  if (smarten) {
149
- if (char === '\n') this.openedDoubleQuote = false;
150
-
111
+ if (char === '\n')
112
+ this.openedDoubleQuote = false;
151
113
  // As we read, replace straight quotes with smart quotes.
152
114
  if (char === '"') {
153
115
  // Replace left quotes after whitespace.
154
116
  if (this.openedDoubleQuote) {
155
117
  char = '\u201d';
156
- } else {
118
+ }
119
+ else {
157
120
  char = '\u201c';
158
121
  }
159
122
  this.openedDoubleQuote = !this.openedDoubleQuote;
160
- } else if (char === "'") {
123
+ }
124
+ else if (char === "'") {
161
125
  // If there's whitespace before this, it's a left single quote.
162
126
  if (/\s/.test(this.text.charAt(this.index - 1)))
163
127
  char = '\u2018';
@@ -166,70 +130,53 @@ export default class Parser {
166
130
  char = '\u2019';
167
131
  }
168
132
  }
169
-
170
- if (
171
- char === '-' &&
133
+ if (char === '-' &&
172
134
  this.text.charAt(this.index + 1) === '-' &&
173
- this.text.charAt(this.index) !== '\n'
174
- ) {
135
+ this.text.charAt(this.index) !== '\n') {
175
136
  this.index++;
176
137
  char = '\u2014';
177
138
  }
178
139
  }
179
-
180
140
  // Advance to the next character in the document.
181
141
  this.index++;
182
-
183
142
  return char;
184
143
  }
185
-
186
- unread(): void {
144
+ unread() {
187
145
  this.index--;
188
146
  }
189
-
190
147
  // All of the text including and after the current index.
191
- rest(): string {
148
+ rest() {
192
149
  return this.text.substring(this.index);
193
150
  }
194
-
195
151
  // The character before
196
- charBeforeNext(): string | null {
152
+ charBeforeNext() {
197
153
  return this.index === 0 ? null : this.text.charAt(this.index - 1);
198
154
  }
199
-
200
155
  // The character after
201
- charAfterNext(): string | null {
156
+ charAfterNext() {
202
157
  return this.index === this.text.length - 1
203
158
  ? null
204
159
  : this.text.charAt(this.index + 1);
205
160
  }
206
-
207
161
  // All the text until the next newline
208
- restOfLine(): string {
209
- const nextNewline =
210
- this.text.substring(this.index).indexOf('\n') + this.index;
211
- if (nextNewline < 0) return this.text.substring(this.index);
162
+ restOfLine() {
163
+ const nextNewline = this.text.substring(this.index).indexOf('\n') + this.index;
164
+ if (nextNewline < 0)
165
+ return this.text.substring(this.index);
212
166
  else
213
- return this.text.substring(
214
- this.index,
215
- Math.max(this.index, nextNewline)
216
- );
167
+ return this.text.substring(this.index, Math.max(this.index, nextNewline));
217
168
  }
218
-
219
169
  // True if the given string is occurs next in the text.
220
- nextIs(text: string) {
221
- if (!this.more()) return false;
222
- return (
223
- this.text.substring(this.index, this.index + text.length) === text
224
- );
170
+ nextIs(text) {
171
+ if (!this.more())
172
+ return false;
173
+ return (this.text.substring(this.index, this.index + text.length) === text);
225
174
  }
226
-
227
175
  // A critical list that tells inline formatting parsers to stop being greedy.
228
- nextIsContentDelimiter(): boolean {
176
+ nextIsContentDelimiter() {
229
177
  const next = this.peek();
230
178
  const charAfterNext = this.charAfterNext();
231
- return (
232
- next === '\n' ||
179
+ return (next === '\n' ||
233
180
  next === '_' ||
234
181
  next === '*' ||
235
182
  next === '`' ||
@@ -243,69 +190,56 @@ export default class Parser {
243
190
  next === '{' ||
244
191
  (this.charBeforeNext() === ' ' && next === '%') ||
245
192
  next === '[' ||
246
- next === '\\'
247
- );
193
+ next === '\\');
248
194
  }
249
-
250
195
  // True if the next part of this string matches the given regular expression.
251
- nextMatches(regex: RegExp): boolean {
252
- if (!this.more()) return false;
196
+ nextMatches(regex) {
197
+ if (!this.more())
198
+ return false;
253
199
  return regex.test(this.rest());
254
200
  }
255
-
256
201
  // Returns true if all of the text between the current character and the next newline is whitespace.
257
- isBlankLine(): boolean {
202
+ isBlankLine() {
258
203
  return this.restOfLine().trim() === '';
259
204
  }
260
-
261
205
  // Read until encountering something other than a tab or a space.
262
- readWhitespace(): void {
206
+ readWhitespace() {
263
207
  let peek = this.peek();
264
208
  while (peek !== null && /^[ \t]/.test(peek)) {
265
209
  this.read();
266
210
  peek = this.peek();
267
211
  }
268
212
  }
269
-
270
213
  // Read until the end of the line.
271
- readUntilNewLine(): string {
214
+ readUntilNewLine() {
272
215
  let text = '';
273
- while (this.more() && this.peek() !== '\n') text = text + this.read();
216
+ while (this.more() && this.peek() !== '\n')
217
+ text = text + this.read();
274
218
  return text;
275
219
  }
276
-
277
220
  // Read until encountering the given string and return the read text.
278
- readUntilNewlineOr(string: string): string {
221
+ readUntilNewlineOr(string) {
279
222
  let text = '';
280
223
  while (this.more() && !this.nextIs('\n') && !this.nextIs(string))
281
224
  text = text + this.read();
282
225
  return text;
283
226
  }
284
-
285
- parseChapter(): ChapterNode {
286
- let blocks: BlockNode[] = [];
287
-
227
+ parseChapter() {
228
+ let blocks = [];
288
229
  // Read any symbols declared for this chapter.
289
230
  this.parseSymbols();
290
-
291
231
  // Get the remaining text.
292
232
  let declarations = this.text.substring(0, this.index);
293
233
  let rest = this.rest();
294
-
295
234
  // First, replace any occurrences of the symbol with the symbol's text.
296
235
  for (const [symbol, text] of Object.entries(this.metadata.symbols)) {
297
- rest = rest.replace(
298
- new RegExp('([^\\\\])@' + symbol + '\\b', 'g'),
299
- '$1' + text
300
- );
236
+ rest = rest.replace(new RegExp('([^\\\\])@' + symbol + '\\b', 'g'), '$1' + text);
301
237
  }
302
-
303
238
  // Replace all of the remaining symbols using book symbol definitions.
304
- if (this.book) rest = Parser.preprocessSymbols(this.book, rest);
305
-
239
+ if (this.book)
240
+ rest = Parser.preprocessSymbols(this.book, rest);
306
241
  // Replace the text with the pre-processed text.
307
242
  this.text = declarations + rest;
308
-
309
243
  // While there's more text, parse a line.
310
244
  let trailingNewlines = 0;
311
245
  while (this.more()) {
@@ -314,90 +248,73 @@ export default class Parser {
314
248
  blocks.push(this.parseBlock());
315
249
  // Read whitespace until we find the next thing.
316
250
  while (this.nextIsWhitespace()) {
317
- if (this.peek() === '\n') trailingNewlines++;
251
+ if (this.peek() === '\n')
252
+ trailingNewlines++;
318
253
  this.read();
319
254
  }
320
255
  }
321
-
322
256
  // If there are no blocks, or the chapter ended with two newlines, append an empty paragraph with an empty format node and an empty text node.
323
257
  if (blocks.length === 0 || trailingNewlines > 1)
324
258
  blocks.push(new ParagraphNode());
325
-
326
259
  // Make the chapter node so we can pass it around.
327
260
  return new ChapterNode(blocks, this.metadata);
328
261
  }
329
-
330
262
  parseSymbols() {
331
263
  // Read whitespace before the symbols
332
264
  this.readWhitespace();
333
-
334
265
  // Keep reading symbols
335
266
  while (this.nextIs('@')) {
336
267
  // Read the @
337
268
  this.read();
338
-
339
269
  // Read the name.
340
270
  let name = this.readUntilNewlineOr(':');
341
-
342
271
  // Names need to be letter and numbers only.
343
272
  if (!/^[a-zA-Z0-9]+$/.test(name)) {
344
- new ErrorNode(
345
- this.readUntilNewLine(),
346
- name.trim() === ''
347
- ? 'Did you mean to declare a symbol? Use an @ symbol, then a name of only numbers and letters, then a colon, then whatever content you want it to represent.'
348
- : "'" +
349
- name +
350
- "' isn't a valid name for a symbol; letters and numbers only"
351
- );
273
+ new ErrorNode(this.readUntilNewLine(), name.trim() === ''
274
+ ? 'Did you mean to declare a symbol? Use an @ symbol, then a name of only numbers and letters, then a colon, then whatever content you want it to represent.'
275
+ : "'" +
276
+ name +
277
+ "' isn't a valid name for a symbol; letters and numbers only");
352
278
  return;
353
279
  }
354
-
355
280
  // Read any whitespace until the colon.
356
281
  this.readWhitespace();
357
-
358
282
  // Name declarations need to be terminated with a colon before the block starts.
359
283
  if (!this.nextIs(':')) {
360
- new ErrorNode(
361
- this.readUntilNewLine(),
362
- "Symbol names are to be followed by a ':'"
363
- );
284
+ new ErrorNode(this.readUntilNewLine(), "Symbol names are to be followed by a ':'");
364
285
  return;
365
286
  }
366
-
367
287
  // Read the colon
368
288
  this.read();
369
-
370
289
  // Read any whitespace after the colon.
371
290
  this.readWhitespace();
372
-
373
291
  // Remember where the text starts
374
292
  let startIndex = this.index;
375
-
376
293
  // Parse a block, any block.
377
294
  this.parseBlock();
378
-
379
295
  // Remember the text we parsed.
380
296
  this.metadata.symbols[name] = this.text
381
297
  .substring(startIndex, this.index)
382
298
  .trim();
383
-
384
299
  // Read whitespace until we find the next non-whitespace thing.
385
- while (this.nextIsWhitespace()) this.read();
300
+ while (this.nextIsWhitespace())
301
+ this.read();
386
302
  }
387
303
  }
388
-
389
- parseBlock(): BlockNode {
304
+ parseBlock() {
390
305
  // Read comment lines
391
306
  while (this.nextIs('%')) {
392
307
  this.readUntilNewLine();
393
308
  }
394
-
395
309
  // Parse and return a header if it starts with a hash
396
- if (this.nextIs('#')) return this.parseHeader();
310
+ if (this.nextIs('#'))
311
+ return this.parseHeader();
397
312
  // Parse and return a horizontal rule if it starts with a dash
398
- else if (this.nextIs('-')) return this.parseRule();
313
+ else if (this.nextIs('-'))
314
+ return this.parseRule();
399
315
  // Parse and return an embed if it starts with a bar
400
- else if (this.nextIs('|')) return this.parseEmbed();
316
+ else if (this.nextIs('|'))
317
+ return this.parseEmbed();
401
318
  // Parse and return a bulleted or numbered list
402
319
  else if (this.nextMatches(bulletRE) || this.nextMatches(numberedRE))
403
320
  return this.parseList();
@@ -405,75 +322,69 @@ export default class Parser {
405
322
  else if (this.nextMatches(/^`[a-zA-Z!]*[ \t]*\n/))
406
323
  return this.parseCode();
407
324
  // Parse and return a quote block if it starts with "
408
- else if (this.nextMatches(/^"[ \t]*\n/)) return this.parseQuote();
325
+ else if (this.nextMatches(/^"[ \t]*\n/))
326
+ return this.parseQuote();
409
327
  // Parse and return a callout if the line starts with =
410
- else if (this.nextMatches(/^=[ \t]*\n/)) return this.parseCallout();
328
+ else if (this.nextMatches(/^=[ \t]*\n/))
329
+ return this.parseCallout();
411
330
  // Parse and return a table if the line starts with a ,
412
- else if (this.nextIs(',')) return this.parseTable();
331
+ else if (this.nextIs(','))
332
+ return this.parseTable();
413
333
  // Parse the text as paragraph;
414
- else return this.parseParagraph();
334
+ else
335
+ return this.parseParagraph();
415
336
  }
416
-
417
- parseParagraph(): ParagraphNode {
337
+ parseParagraph() {
418
338
  if (this.nextIsEmptyParagraph()) {
419
339
  this.read();
420
340
  this.read();
421
341
  return new ParagraphNode(0, new FormatNode('', [new TextNode()]));
422
- } else return new ParagraphNode(0, this.parseFormat());
342
+ }
343
+ else
344
+ return new ParagraphNode(0, this.parseFormat());
423
345
  }
424
-
425
- parseHeader(): ParagraphNode {
346
+ parseHeader() {
426
347
  // Read a sequence of hashes
427
348
  let count = 0;
428
349
  while (this.nextIs('#')) {
429
350
  this.read();
430
351
  count++;
431
352
  }
432
-
433
353
  // Read any whitespace after the hashes.
434
354
  this.readWhitespace();
435
-
436
355
  // Parse some content.
437
356
  return new ParagraphNode(Math.min(3, count), this.parseFormat());
438
357
  }
439
-
440
- parseRule(): RuleNode {
358
+ parseRule() {
441
359
  // Read until the end of the line. Ignore all text that follows.
442
360
  this.readUntilNewLine();
443
-
444
361
  return new RuleNode();
445
362
  }
446
-
447
- parseList(): ListNode {
363
+ parseList() {
448
364
  let numbered = this.nextMatches(numberedRE);
449
-
450
- const items: (FormatNode | ListNode)[] = [];
365
+ const items = [];
451
366
  let lastLevel = undefined;
452
367
  let currentLevel = undefined;
453
-
454
368
  // Keep parsing bullets until there aren't any. They must be of the same type, otherwise we stop.
455
369
  while (this.nextMatches(numberedRE) || this.nextMatches(bulletRE)) {
456
370
  numbered = this.nextMatches(numberedRE);
457
-
458
371
  // Remember the last level
459
372
  lastLevel = currentLevel;
460
-
461
373
  // Start the current level at 0
462
374
  currentLevel = 0;
463
-
464
375
  let digits = undefined;
465
376
  if (numbered) {
466
377
  // Read the digits and remember how many there were so we can backtrack.
467
378
  digits = this.index;
468
379
  this.readUntilNewlineOr('.');
469
380
  digits = this.index - digits;
470
-
471
381
  // Figure out this level.
472
382
  while (this.nextIs('.')) {
473
383
  this.read();
474
384
  currentLevel++;
475
385
  }
476
- } else {
386
+ }
387
+ else {
477
388
  // Figure out this level.
478
389
  currentLevel = 0;
479
390
  while (this.nextIs('*')) {
@@ -481,18 +392,15 @@ export default class Parser {
481
392
  currentLevel++;
482
393
  }
483
394
  }
484
-
485
395
  // If this is the first bullet, or its the same level, just parse another bullet.
486
396
  if (lastLevel === undefined || lastLevel === currentLevel) {
487
397
  // Read the whitespace after the bullet.
488
398
  this.readWhitespace();
489
399
  // Parse content after the bullet.
490
400
  const format = this.parseFormat();
491
- items.push(
492
- format.isEmpty()
493
- ? format.withSegmentAppended(new TextNode())
494
- : format
495
- );
401
+ items.push(format.isEmpty()
402
+ ? format.withSegmentAppended(new TextNode())
403
+ : format);
496
404
  }
497
405
  // Otherwise, unread the stars, then either stop parsing or parse nested list.
498
406
  else {
@@ -502,7 +410,6 @@ export default class Parser {
502
410
  this.unread();
503
411
  count--;
504
412
  }
505
-
506
413
  // Unread the digits if there are any
507
414
  if (digits !== undefined) {
508
415
  while (digits > 0) {
@@ -510,9 +417,9 @@ export default class Parser {
510
417
  digits--;
511
418
  }
512
419
  }
513
-
514
420
  // If this new bullet is a lower level, then stop reading bullets.
515
- if (currentLevel < lastLevel) break;
421
+ if (currentLevel < lastLevel)
422
+ break;
516
423
  // Otherwise, it's greater, and we should read another list.
517
424
  else {
518
425
  items.push(this.parseList());
@@ -520,7 +427,6 @@ export default class Parser {
520
427
  currentLevel = lastLevel;
521
428
  }
522
429
  }
523
-
524
430
  // Read trailing whitespace and newlines.
525
431
  this.readWhitespace();
526
432
  while (this.nextIsWhitespace()) {
@@ -529,23 +435,19 @@ export default class Parser {
529
435
  // Read whitespace before the next block.
530
436
  this.readWhitespace();
531
437
  }
532
-
533
438
  // Stop if we reach an empty paragraph.
534
- if (this.nextIsEmptyParagraph()) break;
439
+ if (this.nextIsEmptyParagraph())
440
+ break;
535
441
  }
536
442
  return new ListNode(items, numbered);
537
443
  }
538
-
539
- parseCode(): CodeNode {
444
+ parseCode() {
540
445
  // Parse the back tick
541
446
  this.read();
542
-
543
447
  // Parse through the next new line
544
448
  let language = this.readUntilNewLine();
545
-
546
449
  // Read the newline
547
450
  this.read();
548
-
549
451
  // Read until we encounter a closing back tick.
550
452
  let code = '';
551
453
  while (this.more() && !this.nextIs('`')) {
@@ -558,172 +460,142 @@ export default class Parser {
558
460
  }
559
461
  code = code + next;
560
462
  }
561
-
562
463
  // Trim the code.
563
464
  code = code.trim();
564
-
565
465
  // Read the backtick.
566
- if (this.nextIs('`')) this.read();
567
-
466
+ if (this.nextIs('`'))
467
+ this.read();
568
468
  let position = this.parsePosition();
569
-
570
469
  // Read the caption. Note that parsing inline content stops at a newline,
571
470
  // so if there's a line break after the last row, there won't be a caption.
572
471
  const caption = this.parseFormat();
573
-
574
472
  return new CodeNode(new TextNode(code), language, position, caption);
575
473
  }
576
-
577
- parsePosition(): Position {
578
- let position: Position = '|';
474
+ parsePosition() {
475
+ let position = '|';
579
476
  // Is there a position indicator?
580
477
  if (this.nextIs('<')) {
581
478
  position = '<';
582
479
  this.read();
583
- } else if (this.nextIs('>')) {
480
+ }
481
+ else if (this.nextIs('>')) {
584
482
  position = '>';
585
483
  this.read();
586
484
  }
587
-
588
485
  return position;
589
486
  }
590
-
591
- parseQuote(): QuoteNode {
592
- const blocks: BlockNode[] = [];
593
-
487
+ parseQuote() {
488
+ const blocks = [];
594
489
  // Parse the ", then any whitespace, then the newline
595
490
  this.read();
596
-
597
491
  // Then read any whitespace after the quote
598
492
  this.readWhitespace();
599
-
600
493
  // Then read the newline.
601
494
  this.read();
602
-
603
495
  while (this.more() && !this.nextIs('"')) {
604
496
  // Read a block
605
497
  const block = this.parseBlock();
606
498
  // Add it to the list if we parsed something.
607
- if (block !== null) blocks.push(block);
499
+ if (block !== null)
500
+ blocks.push(block);
608
501
  // Read whitespace until we find the next thing.
609
- while (this.nextIsWhitespace()) this.read();
502
+ while (this.nextIsWhitespace())
503
+ this.read();
610
504
  }
611
-
612
505
  // Read the closing " and the whitespace that follows.
613
506
  this.read();
614
-
615
507
  // Is there a position indicator?
616
508
  const position = this.parsePosition();
617
-
618
509
  // Read any whitespace after the position indicator.
619
510
  this.readWhitespace();
620
-
621
511
  // Read the credit.
622
512
  const credit = this.nextIs('\n') ? undefined : this.parseFormat();
623
-
624
513
  return new QuoteNode(blocks, credit, position);
625
514
  }
626
-
627
- parseCallout(): CalloutNode {
628
- const blocks: BlockNode[] = [];
629
-
515
+ parseCallout() {
516
+ const blocks = [];
630
517
  // Parse the = ...
631
518
  this.read();
632
-
633
519
  // ...then any whitespace
634
520
  this.readWhitespace();
635
-
636
521
  // ...then read the newline.
637
522
  this.read();
638
-
639
523
  // Then, read until we find a closing _
640
524
  while (this.more() && !this.nextIs('=')) {
641
525
  // Read a block
642
526
  const block = this.parseBlock();
643
527
  // Add it to the list if we parsed something.
644
- if (block !== null) blocks.push(block);
528
+ if (block !== null)
529
+ blocks.push(block);
645
530
  // Read whitespace until we find the next thing.
646
- while (
647
- this.peek() === ' ' ||
531
+ while (this.peek() === ' ' ||
648
532
  this.peek() === '\t' ||
649
- this.peek() === '\n'
650
- )
533
+ this.peek() === '\n')
651
534
  this.read();
652
535
  }
653
-
654
536
  // Read the closing =
655
537
  this.read();
656
-
657
538
  // Is there a position indicator?
658
539
  const position = this.parsePosition();
659
-
660
540
  // Read whitespace that follows.
661
541
  this.readWhitespace();
662
-
663
542
  return new CalloutNode(blocks, position);
664
543
  }
665
-
666
- parseTable(): TableNode {
667
- const rows: FormatNode[][] = [];
668
-
544
+ parseTable() {
545
+ const rows = [];
669
546
  // Parse rows until the lines stop starting with ,
670
547
  while (this.more() && this.nextIs(',')) {
671
548
  let row = [];
672
-
673
549
  while (this.more() && !this.nextIs('\n')) {
674
550
  // Read the starting , or next |
675
551
  this.read();
676
-
677
552
  // Read whitespace that follows.
678
553
  this.readWhitespace();
679
-
680
554
  // Read content until reaching another | or the end of the line.
681
555
  row.push(this.parseFormat('|'));
682
556
  }
683
-
684
557
  // Add the row.
685
558
  rows.push(row);
686
-
687
559
  // Read the newline
688
560
  this.read();
689
561
  }
690
-
691
562
  // Read the position indicator if there is one.
692
563
  const position = this.parsePosition();
693
-
694
564
  // Read the caption. Note that parsing inline content stops at a newline,
695
565
  // so if there's a line break after the last row, there won't be a caption.
696
566
  const caption = this.parseFormat();
697
-
698
567
  // Return the new table.
699
568
  return new TableNode(rows, position, caption);
700
569
  }
701
-
702
570
  // The "awaiting" argument keeps track of upstream formatting. We don't need a stack here
703
571
  // because we don't allow infinite nesting of the same formatting type.
704
- parseFormat(awaiting?: string): FormatNode {
705
- const segments: FormatNodeSegmentType[] = [];
706
-
572
+ parseFormat(awaiting) {
573
+ const segments = [];
707
574
  // Read until hitting a delimiter.
708
575
  while (this.more() && !this.nextIs('\n')) {
709
576
  const next = this.peek();
710
577
  const charAfterNext = this.charAfterNext();
711
-
712
578
  // Parse some bold, italic, subscript, superscript
713
579
  if (next === '_' || next === '*' || next === '^')
714
580
  segments.push(this.parseStyle(next));
715
581
  // Parse unformatted text
716
- else if (this.nextIs('`')) segments.push(this.parseInlineCode());
582
+ else if (this.nextIs('`'))
583
+ segments.push(this.parseInlineCode());
717
584
  // Parse a citation list
718
- else if (this.nextIs('<')) segments.push(this.parseCitations());
585
+ else if (this.nextIs('<'))
586
+ segments.push(this.parseCitations());
719
587
  // Parse a footnote
720
- else if (this.nextIs('{')) segments.push(this.parseFootnote());
588
+ else if (this.nextIs('{'))
589
+ segments.push(this.parseFootnote());
721
590
  // Parse a definition
722
- else if (this.nextIs('~')) segments.push(this.parseDefinition());
591
+ else if (this.nextIs('~'))
592
+ segments.push(this.parseDefinition());
723
593
  // Parse an escaped character
724
- else if (this.nextIs('\\')) segments.push(this.parseEscaped());
594
+ else if (this.nextIs('\\'))
595
+ segments.push(this.parseEscaped());
725
596
  // Parse a link
726
- else if (this.nextIs('[')) segments.push(this.parseLink());
597
+ else if (this.nextIs('['))
598
+ segments.push(this.parseLink());
727
599
  // Parse inline comments
728
600
  else if (this.charBeforeNext() === ' ' && this.nextIs('%'))
729
601
  segments.push(this.parseComment());
@@ -738,70 +610,53 @@ export default class Parser {
738
610
  symbol = symbol + this.read();
739
611
  next = this.peek();
740
612
  }
741
- segments.push(
742
- new ErrorNode(undefined, "Couldn't find symbol @" + symbol)
743
- );
613
+ segments.push(new ErrorNode(undefined, "Couldn't find symbol @" + symbol));
744
614
  }
745
615
  // Parse a label
746
- else if (
747
- next === ':' &&
616
+ else if (next === ':' &&
748
617
  charAfterNext !== null &&
749
- charAfterNext.match(/[a-z]/i)
750
- ) {
618
+ charAfterNext.match(/[a-z]/i)) {
751
619
  segments.push(this.parseLabel());
752
620
  }
753
621
  // Keep reading text until finding a delimiter.
754
622
  else {
755
623
  let text = '';
756
- while (
757
- this.more() &&
624
+ while (this.more() &&
758
625
  (!awaiting || !this.nextIs(awaiting)) &&
759
626
  !this.nextIsContentDelimiter() &&
760
- !this.nextIs('\n')
761
- )
627
+ !this.nextIs('\n'))
762
628
  text = text + this.read();
763
629
  segments.push(new TextNode(text));
764
630
  }
765
-
766
631
  // If we've reached a delimiter we're waiting for, then stop parsing, so it can handle it. Otherwise, we'll keep reading.
767
- if (this.peek() === awaiting) break;
632
+ if (this.peek() === awaiting)
633
+ break;
768
634
  }
769
-
770
635
  return new FormatNode('', segments);
771
636
  }
772
-
773
- parseEmbed(): EmbedNode {
637
+ parseEmbed() {
774
638
  // Read |
775
639
  this.read();
776
-
777
640
  // Read the URL
778
641
  const url = this.readUntilNewlineOr('|');
779
-
780
642
  let description;
781
643
  let caption;
782
644
  let credit;
783
-
784
645
  if (this.peek() === '|') {
785
646
  // Read a |
786
647
  this.read();
787
-
788
648
  // Read the description
789
649
  description = this.readUntilNewlineOr('|');
790
-
791
650
  if (this.peek() === '|') {
792
651
  // Read a |
793
652
  this.read();
794
-
795
653
  // Parse the caption
796
654
  caption = this.parseFormat('|');
797
-
798
655
  if (this.peek() === '|') {
799
656
  // Read a |
800
657
  this.read();
801
-
802
658
  // Parse the credit
803
659
  credit = this.parseFormat('|');
804
-
805
660
  // Check for the closing delimeter
806
661
  if (this.peek() === '|')
807
662
  // Read a |
@@ -809,30 +664,23 @@ export default class Parser {
809
664
  }
810
665
  }
811
666
  }
812
-
813
667
  // Is there a position indicator?
814
668
  const position = this.parsePosition();
815
-
816
669
  return new EmbedNode(url, description ?? '', caption, credit, position);
817
670
  }
818
-
819
- parseComment(): CommentNode {
671
+ parseComment() {
820
672
  // Consume the opening %
821
673
  this.read();
822
-
823
674
  // Consume everything until the next %.
824
675
  const comment = this.parseFormat('%');
825
-
826
676
  // Consume the closing %, if we didn't reach the end of input or a newline.
827
- if (this.peek() === '%') this.read();
828
-
677
+ if (this.peek() === '%')
678
+ this.read();
829
679
  return new CommentNode(comment);
830
680
  }
831
-
832
- parseLabel(): LabelNode | ErrorNode {
681
+ parseLabel() {
833
682
  // Consume the :
834
683
  this.read();
835
-
836
684
  // Consume everything until it's not a letter.
837
685
  let id = '';
838
686
  let next = this.peek();
@@ -840,36 +688,29 @@ export default class Parser {
840
688
  id = id + this.read();
841
689
  next = this.peek();
842
690
  }
843
-
844
691
  return new LabelNode(id);
845
692
  }
846
-
847
- parseStyle(awaiting: string): FormatNode | ErrorNode {
693
+ parseStyle(awaiting) {
848
694
  // Remember what we're matching.
849
695
  const delimeter = this.read();
850
696
  let subscript = false;
851
- const segments: Array<FormatNode | TextNode | ErrorNode> = [];
697
+ const segments = [];
852
698
  let text = '';
853
-
854
699
  // Special case subscript, which has an extra delimeter.
855
700
  if (delimeter === '^' && this.peek() === 'v') {
856
701
  this.read();
857
702
  subscript = true;
858
703
  }
859
-
860
704
  if (delimeter === null)
861
- return new ErrorNode(
862
- undefined,
863
- 'Somehow parsing formatted text at end of file.'
864
- );
865
-
705
+ return new ErrorNode(undefined, 'Somehow parsing formatted text at end of file.');
866
706
  // Read some content until reaching the delimiter or the end of the line
867
707
  while (this.more() && this.peek() !== delimeter && !this.nextIs('\n')) {
868
708
  // If this is more formatted text, make a text node with whatever we've accumulated so far,
869
709
  // then parse the formatted text, then reset the accumulator.
870
710
  if (this.nextIsContentDelimiter()) {
871
711
  // If the text is a non-empty string, make a text node with what we've accumulated.
872
- if (text !== '') segments.push(new TextNode(text));
712
+ if (text !== '')
713
+ segments.push(new TextNode(text));
873
714
  // Parse the formatted content.
874
715
  segments.push(this.parseFormat(awaiting));
875
716
  // Reset the accumulator.
@@ -880,25 +721,20 @@ export default class Parser {
880
721
  text = text + this.read();
881
722
  }
882
723
  }
883
-
884
724
  // If there's more text, save it!
885
- if (text !== '') segments.push(new TextNode(text));
886
-
725
+ if (text !== '')
726
+ segments.push(new TextNode(text));
887
727
  // Read the closing delimeter
888
- if (this.nextIs(delimeter)) this.read();
728
+ if (this.nextIs(delimeter))
729
+ this.read();
889
730
  // If it wasn't closed, add an error
890
- else segments.push(new ErrorNode(undefined, 'Unclosed ' + delimeter));
891
-
892
- return new FormatNode(
893
- subscript ? 'v' : (delimeter as Format),
894
- segments
895
- );
896
- }
897
-
898
- parseInlineCode(): InlineCodeNode {
731
+ else
732
+ segments.push(new ErrorNode(undefined, 'Unclosed ' + delimeter));
733
+ return new FormatNode(subscript ? 'v' : delimeter, segments);
734
+ }
735
+ parseInlineCode() {
899
736
  // Parse the back tick
900
737
  this.read();
901
-
902
738
  // Read until we encounter a closing back tick.
903
739
  let code = '';
904
740
  while (this.more() && !this.nextIs('`')) {
@@ -911,10 +747,9 @@ export default class Parser {
911
747
  }
912
748
  code = code + next;
913
749
  }
914
-
915
750
  // Read the backtick.
916
- if (this.nextIs('`')) this.read();
917
-
751
+ if (this.nextIs('`'))
752
+ this.read();
918
753
  // If there's a letter immediately after a backtick, it's a language for an inline code name
919
754
  let language = '';
920
755
  let next = this.peek();
@@ -923,52 +758,42 @@ export default class Parser {
923
758
  language = language + this.read();
924
759
  next = this.peek();
925
760
  } while (next !== null && /^[a-z]$/.test(next));
926
- } else language = 'plaintext';
927
-
761
+ }
762
+ else
763
+ language = 'plaintext';
928
764
  return new InlineCodeNode(new TextNode(code), language);
929
765
  }
930
-
931
- parseCitations(): CitationsNode {
766
+ parseCitations() {
932
767
  let citations = '';
933
-
934
768
  // Read the <
935
769
  this.read();
936
770
  // Read the citations.
937
771
  citations = this.readUntilNewlineOr('>');
938
- if (this.peek() === '>') this.read();
939
-
772
+ if (this.peek() === '>')
773
+ this.read();
940
774
  // Trim any whitespace, then split by commas, then remove any empty IDs.
941
775
  const citationList = citations
942
776
  .split(',')
943
777
  .map((citation) => citation.trim())
944
778
  .filter((citationID) => citationID.length > 0);
945
-
946
779
  return new CitationsNode(citationList);
947
780
  }
948
-
949
- parseFootnote(): FootnoteNode {
781
+ parseFootnote() {
950
782
  // Read the {
951
783
  this.read();
952
-
953
784
  // Read the footnote content.
954
785
  const footnote = this.parseFormat('}');
955
-
956
786
  // Read the closing }
957
787
  this.read();
958
-
959
788
  return new FootnoteNode(footnote);
960
789
  }
961
-
962
- parseDefinition(): DefinitionNode {
790
+ parseDefinition() {
963
791
  // Read the ~
964
792
  this.read();
965
-
966
793
  // Read the phrase
967
794
  const text = this.readUntilNewlineOr('~');
968
-
969
795
  // Read the closing ~
970
796
  this.read();
971
-
972
797
  // Read the glossary entry ID
973
798
  let glossaryID = '';
974
799
  // Stop at the end of the name or file.
@@ -977,47 +802,37 @@ export default class Parser {
977
802
  glossaryID = glossaryID + this.read();
978
803
  next = this.peek();
979
804
  }
980
-
981
805
  return new DefinitionNode(new TextNode(text), glossaryID);
982
806
  }
983
-
984
- parseEscaped(): TextNode | ErrorNode {
807
+ parseEscaped() {
985
808
  // Skip the scape and just add the next character.
986
809
  this.read();
987
810
  const char = this.read();
988
- if (char) return new TextNode(char);
989
-
811
+ if (char)
812
+ return new TextNode(char);
990
813
  return new ErrorNode(undefined, 'Unterminated escape.');
991
814
  }
992
-
993
- parseLink(): LinkNode | ErrorNode {
815
+ parseLink() {
994
816
  // Read the [
995
817
  this.read();
996
-
997
818
  // Read pure text until funding |
998
819
  const text = this.readUntilNewlineOr('|');
999
-
1000
820
  // Catch missing bars
1001
821
  if (this.peek() !== '|') {
1002
822
  this.readUntilNewLine();
1003
823
  return new ErrorNode(undefined, "Missing '|' in link");
1004
824
  }
1005
-
1006
825
  // Read the |
1007
826
  this.read();
1008
-
1009
827
  // Read the link
1010
828
  let url = this.readUntilNewlineOr(']');
1011
-
1012
829
  // Catch missing closing
1013
830
  if (this.peek() !== ']') {
1014
831
  this.readUntilNewLine();
1015
832
  return new ErrorNode(undefined, 'Missing ] in link');
1016
833
  }
1017
-
1018
834
  // Read the ]
1019
835
  this.read();
1020
-
1021
836
  return new LinkNode(new TextNode(text), url);
1022
837
  }
1023
838
  }