|
|
1年前 | |
|---|---|---|
| js | 1年前 | |
| jstest | 1年前 | |
| lib | 1年前 | |
| php | 1年前 | |
| phptest | 1年前 | |
| .gitignore | 1年前 | |
| README.md | 1年前 | |
| custom.md | 1年前 | |
| markdown.md | 1年前 | |
| markdownphp.php | 1年前 | |
| minify.sh | 1年前 | |
| playground.html | 1年前 | |
| playgroundapi.php | 1年前 | |
| runphptests.sh | 1年前 | |
| spreadsheet.md | 1年前 | |
| testjs.html | 1年前 |
A markdown library with parallel Javascript and PHP implementations. Supports modular “readers” for customizing the flavor of markdown desired, including making custom modules. Javascript implementation is vanilla Javascript with no dependencies. PHP implementation is written for 8.3 but may work on older versions (only dependency is PHPUnit if running tests).
Copy markdown.js (or markdown.min.js)
into your project and include with a <script src="markdown.js"></script> tag
in your HTML. That’s it.
To use, create a parser with:
const myParser = new Markdown(); // defaults to standard syntax
// or with a custom set of readers
const myParser = new Markdown([
new MDParagraphReader(),
new MDStrongReader(),
new MDEmphasisReader(),
]);
// or use one of the two premade parsers
const myParser = Markdown.standardParser; // for a basic set of common syntaxes
const myParser = Markdown.completeParser; // for all supported syntaxes (except line breaks)
Then convert markdown to HTML with:
const html = myParser.toHTML("Your **markdown** here.");
As with Javascript, simply copy markdown.php into your
project and require it in your source.
To use, create a parser with:
$myParser = new Markdown(); // defaults to standard syntax
// or with a custom set of readers
$myParser = new Markdown([
new MDParagraphReader(),
new MDStrongReader(),
new MDEmphasisReader(),
]);
// or use one of the two premade parsers
$myParser = Markdown::standardParser(); // for a basic set of common syntaxes
$myParser = Markdown::completeParser(); // for all supported syntaxes (except line breaks)
Then convert markdown to HTML with:
$html = $myParser->toHTML("Your **markdown** here.");
One innovation in this markdown library is the ability to include greatly
simplified spreadsheet expressions in markdown tables. Intended for simple
formulas and sums. To use, include spreadsheet.js or
spreadsheet.php in your project along with the regular
markdown source and include MDSpreadsheetReader in your Markdown instance.
Example:
| Name | Unit Price | Qty | Discount | Subtotal |
| ----- | ---------: | --: | -------: | --------------: |
| Apple | $0.99 | 2 | | =B*C*(1-D) FILL |
| Pear | $1.09 | 1 | 10% | |
| **TOTAL** | | | | =SUM(E:E) |
can render as:
| Name | Unit Price | Qty | Discount | Subtotal |
|---|---|---|---|---|
| Apple | $0.99 | 2 | $1.98 | |
| Pear | $1.09 | 1 | 10% | $0.98 |
| TOTAL | $3.07 |