Rocketsoup пре 1 година
родитељ
комит
eea6f3b7a0
2 измењених фајлова са 127 додато и 3 уклоњено
  1. 96
    2
      README.md
  2. 31
    1
      spreadsheet.md

+ 96
- 2
README.md Прегледај датотеку

1
 # Markdown Library
1
 # Markdown Library
2
 
2
 
3
+A markdown library with parallel Javascript and PHP implementations. Supports
4
+modular "readers" for customizing the flavor of markdown desired, including
5
+making custom modules. Javascript implementation is vanilla Javascript with
6
+no dependencies. PHP implementation is written for 8.3 but may work on older
7
+versions (only dependency is PHPUnit if running tests).
8
+
9
+## Usage - JS
10
+
11
+Copy [markdown.js](js/markdown.js) (or [markdown.min.js](js/markdown.min.js))
12
+into your project and include with a `<script src="markdown.js"></script>` tag
13
+in your HTML. That's it.
14
+
15
+To use, create a parser with:
16
+
17
+```javascript
18
+const myParser = new Markdown(); // defaults to standard syntax
19
+
20
+// or with a custom set of readers
21
+const myParser = new Markdown([
22
+	new MDParagraphReader(),
23
+	new MDStrongReader(),
24
+	new MDEmphasisReader(),
25
+]);
26
+
27
+// or use one of the two premade parsers
28
+const myParser = Markdown.standardParser;  // for a basic set of common syntaxes
29
+const myParser = Markdown.completeParser;  // for all supported syntaxes (except line breaks)
30
+```
31
+
32
+Then convert markdown to HTML with:
33
+
34
+```javascript
35
+const html = myParser.toHTML("Your **markdown** here.");
36
+```
37
+
38
+## Usage - PHP
39
+
40
+As with Javascript, simply copy [markdown.php](php/markdown.php) into your
41
+project and `require` it in your source.
42
+
43
+To use, create a parser with:
44
+
45
+```php
46
+$myParser = new Markdown(); // defaults to standard syntax
47
+
48
+// or with a custom set of readers
49
+$myParser = new Markdown([
50
+	new MDParagraphReader(),
51
+	new MDStrongReader(),
52
+	new MDEmphasisReader(),
53
+]);
54
+
55
+// or use one of the two premade parsers
56
+$myParser = Markdown::standardParser();  // for a basic set of common syntaxes
57
+$myParser = Markdown::completeParser();  // for all supported syntaxes (except line breaks)
58
+```
59
+
60
+Then convert markdown to HTML with:
61
+
62
+```php
63
+$html = $myParser->toHTML("Your **markdown** here.");
64
+```
65
+
66
+## Spreadsheets
67
+
68
+One innovation in this markdown library is the ability to include _greatly
69
+simplified_ spreadsheet expressions in markdown tables. Intended for simple
70
+formulas and sums. To use, include [spreadsheet.js](js/spreadsheet.js) or
71
+[spreadsheet.php](php/spreadsheet.php) in your project along with the regular
72
+markdown source and include `MDSpreadsheetReader` in your `Markdown` instance.
73
+
74
+Example:
75
+
76
+```markdown
77
+| Name  | Unit Price | Qty | Discount |        Subtotal |
78
+| ----- | ---------: | --: | -------: | --------------: |
79
+| Apple |      $0.99 |   2 |          | =B*C*(1-D) FILL |
80
+| Pear  |      $1.09 |   1 |      10% |                 |
81
+| **TOTAL** |        |     |          | =SUM(E:E)       |
82
+```
83
+
84
+can render as:
85
+
86
+<table>
87
+<thead>
88
+<tr><th>Name</th><th>Unit Price</th><th>Qty</th><th>Discount</th><th>Subtotal</th></tr>
89
+</thead>
90
+<tbody>
91
+<tr><td>Apple</td><td style="text-align: right;">$0.99</td><td style="text-align: right;">2</td><td></td><td style="text-align: right;">$1.98</td></tr>
92
+<tr><td>Pear</td><td style="text-align: right;">$1.09</td><td style="text-align: right;">1</td><td style="text-align: right;">10%</td><td style="text-align: right;">$0.98</td></tr>
93
+<tr><td><strong>TOTAL</strong></td><td></td><td></td><td></td><td style="text-align: right;">$3.07</td></tr>
94
+</table>
95
+
96
+## More info
97
+
3
 * [Markdown syntax reference](markdown.md)
98
 * [Markdown syntax reference](markdown.md)
99
+* [Table spreadsheet formulas](spreadsheet.md)
4
 * [Creating custom syntax](custom.md)
100
 * [Creating custom syntax](custom.md)
5
-
6
-Minified versions of source created with `terser --compress --mangle`.

+ 31
- 1
spreadsheet.md Прегледај датотеку

1
 # Spreadsheet Expressions
1
 # Spreadsheet Expressions
2
 
2
 
3
-Spreadsheet expressions are an optional feature not enabled in the default parser configurations. To enable it, include `spreadsheet.js` / `spreadsheet.php` and create a `Markdown` instance with a `MDSpreadsheetReader`.
3
+Spreadsheet expressions are an optional feature not enabled in the default parser configurations. To enable it, include [`spreadsheet.js`](js/spreadsheet.js) / [`spreadsheet.php`](php/spreadsheet.php) and create a `Markdown` instance with a `new MDSpreadsheetReader()` included in its reader array.
4
 
4
 
5
 ## Expressions
5
 ## Expressions
6
 
6
 
27
 | `=A$1` | First column and row. If transposed, the column may change but the row will not. |
27
 | `=A$1` | First column and row. If transposed, the column may change but the row will not. |
28
 | `=$A$1` | First column and row even if transposed. |
28
 | `=$A$1` | First column and row even if transposed. |
29
 
29
 
30
+## Cell Ranges
31
+
32
+Some functions accept a range of values which can be referenced with an address range. This consists of two addresses joined with a colon (`:`) and will include all the cells in the rectangle between them.
33
+
34
+Examples.
35
+
36
+| Range | Description |
37
+| -- | -- |
38
+| `A1:C9` | All the cells in columns A, B, and C from rows 1 through 9, inclusive. |
39
+| `A:C` | All the cells in columns A, B, and C from all rows. |
40
+
41
+Cell ranges can be used in functions like `SUM`, `AVERAGE`, `MAX`, and others that operate on arbitrary numbers of values.
42
+
43
+If the cell range exceeds the number of rows or columns in a table, the out-of-bounds addresses will be skipped.
44
+
45
+Omitting the row number is a low maintenance way of referring to all the cells in a column without having to update the lower bound as rows are added.
46
+
47
+If a cell has a formula with a range that includes its own cell, the interpeter will automatically exclude it. E.g. this is valid:
48
+
49
+```markdown
50
+| Name  | Qty       |
51
+| ----- | --------- |
52
+| A     | 2         |
53
+| B     | 3         |
54
+| C     | 1         |
55
+| TOTAL | =SUM(B:B) |
56
+```
57
+
58
+The sum references column B and is also in column B but will not cause a circular reference. It will produce a result of 6.
59
+
30
 ## Operators
60
 ## Operators
31
 
61
 
32
 | Operator | Description |
62
 | Operator | Description |

Loading…
Откажи
Сачувај