PHP and Javascript implementations of a simple markdown parser
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Rocketsoup d5911e7d68 Playground sample fix 1 ano atrás
js Adding more infinite loop detection 1 ano atrás
jstest Adding partial/broken expression testing for spreadsheet 1 ano atrás
lib Adding PHPUnit.phar 1 ano atrás
php Adding tests for broken/incomplete syntax 1 ano atrás
phptest Adding partial/broken expression testing for spreadsheet 1 ano atrás
.gitignore Ignoring test result cache 1 ano atrás
README.md Documentation 1 ano atrás
custom.md Cleanup of comments, organization 1 ano atrás
markdown.md Adding partial/broken expression testing for spreadsheet 1 ano atrás
markdownphp.php PHP port WIP 1 ano atrás
minify.sh Writing first PHP unit tests. Breaking JS unit test classes into separate files 1 ano atrás
playground.html Playground sample fix 1 ano atrás
playgroundapi.php Spreadsheet PHP mostly working 1 ano atrás
runphptests.sh Adding tests for broken/incomplete syntax 1 ano atrás
spreadsheet.md Documentation 1 ano atrás
testjs.html Adding tests for broken/incomplete syntax 1 ano atrás

README.md

Markdown Library

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).

Usage - JS

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.");

Usage - PHP

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.");

Spreadsheets

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:

NameUnit PriceQtyDiscountSubtotal
Apple$0.992$1.98
Pear$1.09110%$0.98
TOTAL$3.07

More info