highmark-markdown 0.0.1

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 (161) hide show
  1. package/.swcrc +11 -0
  2. package/README.md +18 -0
  3. package/bin/main.js +15 -0
  4. package/example.js +43721 -0
  5. package/index.html +48 -0
  6. package/lib/attributeNames.js +30 -0
  7. package/lib/constants.js +22 -0
  8. package/lib/example/constants.js +13 -0
  9. package/lib/example/view/div/previewPane.js +256 -0
  10. package/lib/example/view/div/sizeable/left.js +135 -0
  11. package/lib/example/view/div/sizeable/right.js +135 -0
  12. package/lib/example/view/heading.js +39 -0
  13. package/lib/example/view/subHeading.js +39 -0
  14. package/lib/example/view/textarea/bnf.js +176 -0
  15. package/lib/example/view/textarea/lexicalEntries.js +183 -0
  16. package/lib/example/view/textarea/markdown.js +176 -0
  17. package/lib/example/view/textarea/parseTree.js +183 -0
  18. package/lib/example/view/textarea.js +39 -0
  19. package/lib/example/view.js +262 -0
  20. package/lib/example.js +19 -0
  21. package/lib/index.js +63 -0
  22. package/lib/markdown/bnf.js +14 -0
  23. package/lib/markdown/entries.js +93 -0
  24. package/lib/markdown/lexer.js +157 -0
  25. package/lib/markdown/parser.js +155 -0
  26. package/lib/mixins/content.js +23 -0
  27. package/lib/mixins/element.js +47 -0
  28. package/lib/mixins/node.js +30 -0
  29. package/lib/node/markdown/anchor.js +164 -0
  30. package/lib/node/markdown/blockListing.js +137 -0
  31. package/lib/node/markdown/blockListingEnd.js +120 -0
  32. package/lib/node/markdown/blockListingStart.js +143 -0
  33. package/lib/node/markdown/blockText.js +132 -0
  34. package/lib/node/markdown/className.js +130 -0
  35. package/lib/node/markdown/document.js +158 -0
  36. package/lib/node/markdown/emphasisedText.js +123 -0
  37. package/lib/node/markdown/endOfLine.js +136 -0
  38. package/lib/node/markdown/error.js +169 -0
  39. package/lib/node/markdown/footnote.js +130 -0
  40. package/lib/node/markdown/footnoteItem.js +136 -0
  41. package/lib/node/markdown/footnotesList.js +154 -0
  42. package/lib/node/markdown/hyperlink.js +170 -0
  43. package/lib/node/markdown/image.js +170 -0
  44. package/lib/node/markdown/inlineListing.js +130 -0
  45. package/lib/node/markdown/inlineText.js +132 -0
  46. package/lib/node/markdown/line.js +131 -0
  47. package/lib/node/markdown/lineBreak.js +120 -0
  48. package/lib/node/markdown/link.js +184 -0
  49. package/lib/node/markdown/orderedList.js +162 -0
  50. package/lib/node/markdown/orderedListItem.js +130 -0
  51. package/lib/node/markdown/paragraph.js +120 -0
  52. package/lib/node/markdown/primaryHeading.js +120 -0
  53. package/lib/node/markdown/quaternaryHeading.js +120 -0
  54. package/lib/node/markdown/reference.js +130 -0
  55. package/lib/node/markdown/secondaryHeading.js +120 -0
  56. package/lib/node/markdown/strongText.js +123 -0
  57. package/lib/node/markdown/stronglyEmphasisedText.js +163 -0
  58. package/lib/node/markdown/table.js +120 -0
  59. package/lib/node/markdown/tableBody.js +120 -0
  60. package/lib/node/markdown/tableBodyCell.js +130 -0
  61. package/lib/node/markdown/tableBodyRow.js +120 -0
  62. package/lib/node/markdown/tableCell.js +152 -0
  63. package/lib/node/markdown/tableHead.js +120 -0
  64. package/lib/node/markdown/tableHeadCell.js +130 -0
  65. package/lib/node/markdown/tableHeadRow.js +120 -0
  66. package/lib/node/markdown/tableSeparator.js +120 -0
  67. package/lib/node/markdown/tertiaryHeading.js +120 -0
  68. package/lib/node/markdown/text.js +130 -0
  69. package/lib/node/markdown/unorderedList.js +120 -0
  70. package/lib/node/markdown/unorderedListItem.js +120 -0
  71. package/lib/node/markdown/url.js +122 -0
  72. package/lib/node/markdown/verticalSpace.js +132 -0
  73. package/lib/node/markdown.js +246 -0
  74. package/lib/nodeMap.js +78 -0
  75. package/lib/ruleNameToHTMLMap.js +161 -0
  76. package/lib/ruleNames.js +240 -0
  77. package/lib/tokenTypes.js +150 -0
  78. package/lib/utilities/childNodes.js +67 -0
  79. package/lib/utilities/content.js +52 -0
  80. package/lib/utilities/link.js +37 -0
  81. package/lib/utilities/node.js +32 -0
  82. package/lib/utilities/query.js +55 -0
  83. package/license.txt +48 -0
  84. package/package.json +43 -0
  85. package/src/attributeNames.js +6 -0
  86. package/src/constants.js +4 -0
  87. package/src/example/constants.js +4 -0
  88. package/src/example/view/div/previewPane.js +82 -0
  89. package/src/example/view/div/sizeable/left.js +19 -0
  90. package/src/example/view/div/sizeable/right.js +19 -0
  91. package/src/example/view/heading.js +14 -0
  92. package/src/example/view/subHeading.js +16 -0
  93. package/src/example/view/textarea/bnf.js +41 -0
  94. package/src/example/view/textarea/lexicalEntries.js +52 -0
  95. package/src/example/view/textarea/markdown.js +41 -0
  96. package/src/example/view/textarea/parseTree.js +50 -0
  97. package/src/example/view/textarea.js +17 -0
  98. package/src/example/view.js +139 -0
  99. package/src/example.js +21 -0
  100. package/src/index.js +13 -0
  101. package/src/markdown/bnf.js +143 -0
  102. package/src/markdown/entries.js +84 -0
  103. package/src/markdown/lexer.js +36 -0
  104. package/src/markdown/parser.js +36 -0
  105. package/src/mixins/content.js +19 -0
  106. package/src/mixins/element.js +47 -0
  107. package/src/mixins/node.js +27 -0
  108. package/src/node/markdown/anchor.js +37 -0
  109. package/src/node/markdown/blockListing.js +29 -0
  110. package/src/node/markdown/blockListingEnd.js +7 -0
  111. package/src/node/markdown/blockListingStart.js +28 -0
  112. package/src/node/markdown/blockText.js +22 -0
  113. package/src/node/markdown/className.js +21 -0
  114. package/src/node/markdown/document.js +26 -0
  115. package/src/node/markdown/emphasisedText.js +13 -0
  116. package/src/node/markdown/endOfLine.js +24 -0
  117. package/src/node/markdown/error.js +36 -0
  118. package/src/node/markdown/footnote.js +21 -0
  119. package/src/node/markdown/footnoteItem.js +37 -0
  120. package/src/node/markdown/footnotesList.js +64 -0
  121. package/src/node/markdown/hyperlink.js +47 -0
  122. package/src/node/markdown/image.js +47 -0
  123. package/src/node/markdown/inlineListing.js +20 -0
  124. package/src/node/markdown/inlineText.js +22 -0
  125. package/src/node/markdown/line.js +21 -0
  126. package/src/node/markdown/lineBreak.js +7 -0
  127. package/src/node/markdown/link.js +54 -0
  128. package/src/node/markdown/orderedList.js +33 -0
  129. package/src/node/markdown/orderedListItem.js +21 -0
  130. package/src/node/markdown/paragraph.js +7 -0
  131. package/src/node/markdown/primaryHeading.js +7 -0
  132. package/src/node/markdown/quaternaryHeading.js +7 -0
  133. package/src/node/markdown/reference.js +21 -0
  134. package/src/node/markdown/secondaryHeading.js +7 -0
  135. package/src/node/markdown/strongText.js +13 -0
  136. package/src/node/markdown/stronglyEmphasisedText.js +39 -0
  137. package/src/node/markdown/table.js +7 -0
  138. package/src/node/markdown/tableBody.js +7 -0
  139. package/src/node/markdown/tableBodyCell.js +20 -0
  140. package/src/node/markdown/tableBodyRow.js +7 -0
  141. package/src/node/markdown/tableCell.js +42 -0
  142. package/src/node/markdown/tableHead.js +7 -0
  143. package/src/node/markdown/tableHeadCell.js +20 -0
  144. package/src/node/markdown/tableHeadRow.js +7 -0
  145. package/src/node/markdown/tableSeparator.js +7 -0
  146. package/src/node/markdown/tertiaryHeading.js +7 -0
  147. package/src/node/markdown/text.js +20 -0
  148. package/src/node/markdown/unorderedList.js +7 -0
  149. package/src/node/markdown/unorderedListItem.js +7 -0
  150. package/src/node/markdown/url.js +10 -0
  151. package/src/node/markdown/verticalSpace.js +22 -0
  152. package/src/node/markdown.js +100 -0
  153. package/src/nodeMap.js +140 -0
  154. package/src/ruleNameToHTMLMap.js +227 -0
  155. package/src/ruleNames.js +95 -0
  156. package/src/tokenTypes.js +59 -0
  157. package/src/utilities/childNodes.js +70 -0
  158. package/src/utilities/content.js +77 -0
  159. package/src/utilities/link.js +27 -0
  160. package/src/utilities/node.js +23 -0
  161. package/src/utilities/query.js +42 -0
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ default: function() {
13
+ return _default;
14
+ },
15
+ footnoteMarkdownNodesFromNode: function() {
16
+ return footnoteMarkdownNodesFromNode;
17
+ },
18
+ linkMarkdownNodesFromNode: function() {
19
+ return linkMarkdownNodesFromNode;
20
+ },
21
+ referenceMarkdownNodesFromNode: function() {
22
+ return referenceMarkdownNodesFromNode;
23
+ }
24
+ });
25
+ var _occamquery = require("occam-query");
26
+ var _necessary = require("necessary");
27
+ var push = _necessary.arrayUtilities.push;
28
+ var linkMarkdownNodesQuery = _occamquery.Query.fromExpression("//link"), footnoteMarkdownNodesQuery = _occamquery.Query.fromExpression("//footnote"), referenceMarkdownNodesQuery = _occamquery.Query.fromExpression("//reference");
29
+ function linkMarkdownNodesFromNode(node) {
30
+ var linkMarkdownNodes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
31
+ nodesFromNodeAndQuery(node, linkMarkdownNodesQuery, linkMarkdownNodes);
32
+ return linkMarkdownNodes;
33
+ }
34
+ function footnoteMarkdownNodesFromNode(node) {
35
+ var footnoteMarkdownNodes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
36
+ nodesFromNodeAndQuery(node, footnoteMarkdownNodesQuery, footnoteMarkdownNodes);
37
+ return footnoteMarkdownNodes;
38
+ }
39
+ function referenceMarkdownNodesFromNode(node) {
40
+ var referenceMarkdownNodes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
41
+ nodesFromNodeAndQuery(node, referenceMarkdownNodesQuery, referenceMarkdownNodes);
42
+ return referenceMarkdownNodes;
43
+ }
44
+ var _default = {
45
+ linkMarkdownNodesFromNode: linkMarkdownNodesFromNode,
46
+ footnoteMarkdownNodesFromNode: footnoteMarkdownNodesFromNode,
47
+ referenceMarkdownNodesFromNode: referenceMarkdownNodesFromNode
48
+ };
49
+ function nodesFromNodeAndQuery(node, query, nodes) {
50
+ var queryNodes = query.execute(node);
51
+ push(nodes, queryNodes);
52
+ return nodes;
53
+ }
54
+
55
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hQUFhRixNQUFNRyxPQUFPLENBQUNSO0lBRWpDUCxLQUFLYSxPQUFPQztJQUVaLE9BQU9EO0FBQ1QifQ==
package/license.txt ADDED
@@ -0,0 +1,48 @@
1
+ MIT And Anti-996 Licenses
2
+
3
+ Copyright (c) 2023 James Smith
4
+
5
+ These licenses shall be included in all copies or substantial portions of
6
+ this software and associated documentation files (the "Software").
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this Software, to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to permit
12
+ persons to whom the Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ 1. The individual or the legal entity must conspicuously display,
16
+ without modification, this License and the notice on each redistributed
17
+ or derivative copy of the Licensed Work.
18
+
19
+ 2. The individual or the legal entity must strictly comply with all
20
+ applicable laws, regulations, rules and standards of the jurisdiction
21
+ relating to labor and employment where the individual is physically
22
+ located or where the individual was born or naturalized; or where the
23
+ legal entity is registered or is operating (whichever is stricter). In
24
+ case that the jurisdiction has no such laws, regulations, rules and
25
+ standards or its laws, regulations, rules and standards are
26
+ unenforceable, the individual or the legal entity are required to
27
+ comply with Core International Labor Standards.
28
+
29
+ 3. The individual or the legal entity shall not induce, suggest or force
30
+ its employee(s), whether full-time or part-time, or its independent
31
+ contractor(s), in any methods, to agree in oral or written form, to
32
+ directly or indirectly restrict, weaken or relinquish his or her
33
+ rights or remedies under such laws, regulations, rules and standards
34
+ relating to labor and employment as mentioned above, no matter whether
35
+ such written or oral agreements are enforceable under the laws of the
36
+ said jurisdiction, nor shall such individual or the legal entity
37
+ limit, in any methods, the rights of its employee(s) or independent
38
+ contractor(s) from reporting or complaining to the copyright holder or
39
+ relevant authorities monitoring the compliance of the license about
40
+ its violation(s) of the said license.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "highmark-markdown",
3
+ "author": "James Smith",
4
+ "version": "0.0.1",
5
+ "license": "MIT, Anti-996",
6
+ "homepage": "https://github.com/djalbat/highmark-markdown",
7
+ "description": "Highmark's Markdown.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/djalbat/highmark-markdown"
11
+ },
12
+ "dependencies": {
13
+ "occam-lexers": "^20.0.13",
14
+ "occam-parsers": "^20.0.29",
15
+ "occam-query": "^3.1.133"
16
+ },
17
+ "devDependencies": {
18
+ "@swc/core": "^1.2.50",
19
+ "easy": "^16.0.19",
20
+ "easy-layout": "^6.0.124",
21
+ "easy-with-style": "^3.0.317",
22
+ "esbuild": "^0.9.2",
23
+ "express": "^4.17.1",
24
+ "highmark-fonts": "^1.0.2",
25
+ "juxtapose": "^4.0.80",
26
+ "lively-cli": "^2.0.52",
27
+ "watchful-cli": "^1.7.44"
28
+ },
29
+ "scripts": {
30
+ "start": "node ./bin/main.js",
31
+ "clean": "rm -rf ./lib",
32
+ "watchful": "watchful -m --transpiler=swc --bundler=esbuild --source-directory=./src --lib-directory=./lib --entry-file=example.js --bundle-file=./example.js --wait=100",
33
+ "batch": "npm run watchful batch --",
34
+ "batch-debug": "npm run watchful batch -- --debug",
35
+ "incremental": "npm run watchful incremental --",
36
+ "incremental-debug": "npm run watchful incremental -- --debug",
37
+ "build": "npm run clean && npm run batch",
38
+ "build-debug": "npm run clean && npm run batch-debug",
39
+ "watch": "npm run clean && npm run batch && npm run incremental",
40
+ "watch-debug": "npm run clean && npm run batch-debug && npm run incremental-debug"
41
+ },
42
+ "main": "./lib/index"
43
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ export const ID_ATTRIBUTE_NAME = "id";
4
+ export const SRC_ATTRIBUTE_NAME = "src";
5
+ export const HREF_ATTRIBUTE_NAME = "href";
6
+ export const START_ATTRIBUTE_NAME = "start";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export const PERIOD = '.';
4
+ export const EMPTY_STRING = "";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export const EMPTY_STRING = "";
4
+ export const DOUBLE_SPACE = " ";
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style";
4
+
5
+ import { Element } from "easy";
6
+
7
+ class PreviewPaneDiv extends Element {
8
+ update(node, tokens) {
9
+ let previousNode;
10
+
11
+ previousNode = this.getPreviousNode();
12
+
13
+ if (previousNode !== null) {
14
+ this.unmount(previousNode);
15
+ }
16
+
17
+ if (node !== null) {
18
+ const context = {
19
+ tokens
20
+ };
21
+
22
+ node.createDOMElement(context);
23
+
24
+ this.mount(node);
25
+ }
26
+
27
+ previousNode = node; ///
28
+
29
+ this.setPreviousNode(previousNode);
30
+ }
31
+
32
+ getPreviousNode() {
33
+ const { previousNode } = this.getState();
34
+
35
+ return previousNode;
36
+ }
37
+
38
+ setPreviousNode(previousNode) {
39
+ this.updateState({
40
+ previousNode
41
+ });
42
+ }
43
+
44
+ setInitialState() {
45
+ const previousNode = null;
46
+
47
+ this.setState({
48
+ previousNode
49
+ });
50
+ }
51
+
52
+ parentContext() {
53
+ const updatePreviewPaneDiv = this.update.bind(this);
54
+
55
+ return ({
56
+ updatePreviewPaneDiv
57
+ });
58
+ }
59
+
60
+ initialise() {
61
+ this.setInitialState();
62
+ }
63
+
64
+ static tagName = "div";
65
+
66
+ static defaultProperties = {
67
+ className: "preview-pane"
68
+ };
69
+ }
70
+
71
+ export default withStyle(PreviewPaneDiv)`
72
+
73
+ top: 0;
74
+ left: 0;
75
+ width: 100%;
76
+ height: 100%;
77
+ border: 1px solid darkgrey;
78
+ overflow: scroll;
79
+ position: absolute;
80
+ font-size: 16pt;
81
+
82
+ `;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import { SizeableDiv } from "easy-layout";
6
+
7
+ class LeftSizeableDiv extends SizeableDiv {
8
+ static defaultProperties = {
9
+ className: "left"
10
+ };
11
+ }
12
+
13
+ export default withStyle(LeftSizeableDiv)`
14
+
15
+ width: 90rem;
16
+ min-width: 12rem;
17
+ flex-direction: column;
18
+
19
+ `;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import { SizeableDiv } from "easy-layout";
6
+
7
+ class RightSizeableDiv extends SizeableDiv {
8
+ static defaultProperties = {
9
+ className: "right"
10
+ };
11
+ }
12
+
13
+ export default withStyle(RightSizeableDiv)`
14
+
15
+ height: 48rem;
16
+ position: relative;
17
+ min-height: 12rem;
18
+
19
+ `;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ const Heading = withStyle.h1`
6
+
7
+ font-size: 3rem;
8
+ text-align: center;
9
+ margin-top: 1rem;
10
+ margin-bottom: 1rem;
11
+
12
+ `;
13
+
14
+ export default Heading;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ const SubHeading = withStyle.h2`
6
+
7
+ margin: 1rem 0 0.5rem 0;
8
+ font-size: 2rem;
9
+
10
+ :first-of-type {
11
+ margin-top: 0;
12
+ }
13
+
14
+ `;
15
+
16
+ export default SubHeading;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import Textarea from "../textarea";
6
+
7
+ class BNFTextarea extends Textarea {
8
+ getBNF() {
9
+ const value = this.getValue(),
10
+ bnf = value; ///
11
+
12
+ return bnf;
13
+ }
14
+
15
+ setBNF(bnf) {
16
+ const value = bnf;
17
+
18
+ this.setValue(value);
19
+ }
20
+
21
+ parentContext() {
22
+ const getBNF = this.getBNF.bind(this),
23
+ setBNF = this.setBNF.bind(this);
24
+
25
+ return ({
26
+ getBNF,
27
+ setBNF
28
+ });
29
+ }
30
+
31
+ static defaultProperties = {
32
+ className: "bnf",
33
+ spellCheck: "false"
34
+ };
35
+ }
36
+
37
+ export default withStyle(BNFTextarea)`
38
+
39
+ height: 16rem;
40
+
41
+ `;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import Textarea from "../textarea";
6
+
7
+ import { DOUBLE_SPACE } from "../../constants";
8
+
9
+ class LexicalEntriesTextarea extends Textarea {
10
+ getLexicalEntries() {
11
+ let lexicalEntries = {};
12
+
13
+ try {
14
+ const value = this.getValue(),
15
+ lexicalEntriesString = value; ///
16
+
17
+ lexicalEntries = JSON.parse(lexicalEntriesString);
18
+ } catch (error) {
19
+ ///
20
+ }
21
+
22
+ return lexicalEntries;
23
+ }
24
+
25
+ setLexicalEntries(lexicalEntries) {
26
+ const lexicalEntriesString = JSON.stringify(lexicalEntries, null, DOUBLE_SPACE),
27
+ value = lexicalEntriesString; ///
28
+
29
+ this.setValue(value);
30
+ }
31
+
32
+ parentContext() {
33
+ const getLexicalEntries = this.getLexicalEntries.bind(this),
34
+ setLexicalEntries = this.setLexicalEntries.bind(this);
35
+
36
+ return ({
37
+ getLexicalEntries,
38
+ setLexicalEntries
39
+ });
40
+ }
41
+
42
+ static defaultProperties = {
43
+ className: "lexical-entries",
44
+ spellCheck: "false"
45
+ };
46
+ }
47
+
48
+ export default withStyle(LexicalEntriesTextarea)`
49
+
50
+ height: 12rem;
51
+
52
+ `;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import Textarea from "../textarea";
6
+
7
+ class MarkdownTextarea extends Textarea {
8
+ getMarkdown() {
9
+ const value = this.getValue(),
10
+ markdown = value; ///
11
+
12
+ return markdown;
13
+ }
14
+
15
+ setMarkdown(markdown) {
16
+ const value = markdown; ///
17
+
18
+ this.setValue(value);
19
+ }
20
+
21
+ parentContext() {
22
+ const getMarkdown = this.getMarkdown.bind(this),
23
+ setMarkdown = this.setMarkdown.bind(this);
24
+
25
+ return ({
26
+ getMarkdown,
27
+ setMarkdown
28
+ });
29
+ }
30
+
31
+ static defaultProperties = {
32
+ className: "markdown",
33
+ spellCheck: "false"
34
+ };
35
+ }
36
+
37
+ export default withStyle(MarkdownTextarea)`
38
+
39
+ height: 24rem;
40
+
41
+ `;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import Textarea from "../textarea";
6
+
7
+ import { EMPTY_STRING } from "../../constants";
8
+
9
+ class ParseTreeTextarea extends Textarea {
10
+ setParseTree(parseTree) {
11
+ if (parseTree !== null) {
12
+ parseTree.shiftLine(); //
13
+
14
+ const parseTreeString = parseTree.asString(),
15
+ value = parseTreeString; ///
16
+
17
+ this.setValue(value);
18
+ } else {
19
+ this.clearParseTree();
20
+ }
21
+ }
22
+
23
+ clearParseTree() {
24
+ const value = EMPTY_STRING;
25
+
26
+ this.setValue(value);
27
+ }
28
+
29
+ parentContext() {
30
+ const setParseTree = this.setParseTree.bind(this),
31
+ clearParseTree = this.clearParseTree.bind(this);
32
+
33
+ return ({
34
+ setParseTree,
35
+ clearParseTree
36
+ });
37
+ }
38
+
39
+ static defaultProperties = {
40
+ className: "parse-tree",
41
+ spellCheck: "false",
42
+ readOnly: true
43
+ };
44
+ }
45
+
46
+ export default withStyle(ParseTreeTextarea)`
47
+
48
+ height: 36rem;
49
+
50
+ `;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import { Textarea } from "easy";
6
+
7
+ export default withStyle(Textarea)`
8
+
9
+ border: 1px solid darkgrey;
10
+ resize: vertical;
11
+ padding: 0.25rem;
12
+ font-size: 1.2rem;
13
+ line-height: 1.5rem;
14
+ white-space: pre;
15
+ font-family: monospace;
16
+
17
+ `;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ import withStyle from "easy-with-style"; ///
4
+
5
+ import { Element } from "easy";
6
+ import { parserUtilities } from "occam-parsers";
7
+ import { RowDiv, RowsDiv, ColumnDiv, ColumnsDiv, VerticalSplitterDiv, HorizontalSplitterDiv } from "easy-layout";
8
+
9
+ import SubHeading from "./view/subHeading";
10
+ import BNFTextarea from "./view/textarea/bnf";
11
+ import PreviewPaneDiv from "./view/div/previewPane";
12
+ import LeftSizeableDiv from "./view/div/sizeable/left";
13
+ import RightSizeableDiv from "./view/div/sizeable/right";
14
+ import MarkdownTextarea from "./view/textarea/markdown";
15
+ import ParseTreeTextarea from "./view/textarea/parseTree";
16
+ import LexicalEntriesTextarea from "./view/textarea/lexicalEntries";
17
+
18
+ import { nodeMap, MarkdownLexer, MarkdownParser, nodeUtilities } from "../index";
19
+
20
+ const { bnf } = MarkdownParser,
21
+ { entries } = MarkdownLexer,
22
+ { rulesFromBNF } = parserUtilities,
23
+ { setNonTerminalNodes } = nodeUtilities;
24
+
25
+ class View extends Element {
26
+ keyUpHandler = (event, element) => {
27
+ this.update();
28
+ }
29
+
30
+ update() {
31
+ const bnf = this.getBNF(),
32
+ markdown = this.getMarkdown(),
33
+ lexicalEntries = this.getLexicalEntries();
34
+
35
+ const rules = rulesFromBNF(bnf),
36
+ lexer = lexerFromLexicalEntries(lexicalEntries),
37
+ parser = parserFromRules(rules),
38
+ content = markdown; ///
39
+
40
+ const tokens = lexer.tokenise(content),
41
+ node = parser.parse(tokens);
42
+
43
+ this.updatePreviewPaneDiv(node, tokens);
44
+
45
+ let parseTree = null;
46
+
47
+ if (node !== null) {
48
+ parseTree = node.asParseTree(tokens);
49
+ }
50
+
51
+ this.setParseTree(parseTree);
52
+ }
53
+
54
+ childElements() {
55
+ return (
56
+
57
+ <ColumnsDiv>
58
+ <LeftSizeableDiv>
59
+ <SubHeading>
60
+ Lexical entries
61
+ </SubHeading>
62
+ <LexicalEntriesTextarea onKeyUp={this.keyUpHandler} />
63
+ <SubHeading>
64
+ BNF
65
+ </SubHeading>
66
+ <BNFTextarea onKeyUp={this.keyUpHandler} />
67
+ <SubHeading>
68
+ Parse tree
69
+ </SubHeading>
70
+ <ParseTreeTextarea/>
71
+ </LeftSizeableDiv>
72
+ <VerticalSplitterDiv/>
73
+ <ColumnDiv>
74
+ <RowsDiv>
75
+ <RightSizeableDiv>
76
+ <PreviewPaneDiv/>
77
+ </RightSizeableDiv>
78
+ <HorizontalSplitterDiv/>
79
+ <RowDiv>
80
+ <RowsDiv>
81
+ <SubHeading>
82
+ Markdown
83
+ </SubHeading>
84
+ <MarkdownTextarea onKeyUp={this.keyUpHandler} />
85
+ </RowsDiv>
86
+ </RowDiv>
87
+ </RowsDiv>
88
+ </ColumnDiv>
89
+ </ColumnsDiv>
90
+
91
+ );
92
+ }
93
+
94
+ initialise() {
95
+ this.assignContext();
96
+
97
+ const { initialMarkdown } = this.constructor,
98
+ markdown = initialMarkdown, ///
99
+ lexicalEntries = entries; ///
100
+
101
+ this.setBNF(bnf);
102
+
103
+ this.setMarkdown(markdown);
104
+
105
+ this.setLexicalEntries(lexicalEntries);
106
+
107
+ this.update();
108
+ }
109
+
110
+ static initialMarkdown = `This is a paragraph.
111
+ `;
112
+
113
+ static tagName = "div";
114
+
115
+ static defaultProperties = {
116
+ className: "view"
117
+ };
118
+ }
119
+
120
+ export default withStyle(View)`
121
+
122
+ padding: 1rem;
123
+
124
+ `;
125
+
126
+ function lexerFromLexicalEntries(lexicalEntries) {
127
+ const entries = lexicalEntries, ///
128
+ lexer = MarkdownLexer.fromEntries(entries); ///
129
+
130
+ return lexer;
131
+ }
132
+
133
+ function parserFromRules(rules) {
134
+ const parser = MarkdownParser.fromRules(rules); ///
135
+
136
+ setNonTerminalNodes(parser, nodeMap);
137
+
138
+ return parser;
139
+ }
package/src/example.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ import "juxtapose";
4
+
5
+ import withStyle from "easy-with-style"; ///
6
+
7
+ import { Body } from "easy";
8
+
9
+ import View from "./example/view";
10
+
11
+ const { renderStyles } = withStyle;
12
+
13
+ renderStyles();
14
+
15
+ const body = new Body();
16
+
17
+ body.mount(
18
+
19
+ <View/>
20
+
21
+ );