-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdparser.stub.php
More file actions
147 lines (130 loc) · 5.16 KB
/
mdparser.stub.php
File metadata and controls
147 lines (130 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/** @generate-class-entries */
namespace MdParser;
final class Exception extends \RuntimeException
{
}
/**
* IMPORTANT: default values below MUST agree with the `default_value`
* column in `mdparser_options_fields[]` inside `mdparser_options.c`.
* ZPP does not auto-apply arginfo defaults to internal methods, so
* the C constructor seeds values[] from the C table and this stub is
* only used for reflection / IDE signatures. If you change a default,
* change it in both places.
*/
final readonly class Options
{
public bool $sourcepos;
public bool $hardbreaks;
public bool $nobreaks;
public bool $smart;
public bool $unsafe;
public bool $validateUtf8;
public bool $githubPreLang;
public bool $liberalHtmlTag;
public bool $footnotes;
public bool $strikethroughDoubleTilde;
public bool $tablePreferStyleAttributes;
public bool $fullInfoString;
public bool $tables;
public bool $strikethrough;
public bool $tasklist;
public bool $autolink;
public bool $tagfilter;
public bool $headingAnchors;
public bool $nofollowLinks;
public function __construct(
bool $sourcepos = false,
bool $hardbreaks = false,
bool $nobreaks = false,
bool $smart = false,
bool $unsafe = false,
bool $validateUtf8 = true,
bool $githubPreLang = true,
bool $liberalHtmlTag = false,
bool $footnotes = false,
bool $strikethroughDoubleTilde = false,
bool $tablePreferStyleAttributes = false,
bool $fullInfoString = false,
bool $tables = true,
bool $strikethrough = true,
bool $tasklist = true,
bool $autolink = true,
bool $tagfilter = true,
bool $headingAnchors = false,
bool $nofollowLinks = false,
) {}
/**
* Maximum-safety preset: the standard defaults plus autolink off,
* so bare URLs in untrusted input do not get wrapped in live <a>
* tags. Use for forum comments, email rendering, or any rendering
* path where the source is untrusted and link creation should be
* explicit.
*/
public static function strict(): Options {}
/**
* GitHub-flavored preset: standard defaults plus footnotes on, to
* match the feature set github.com renders for README files and
* issue comments. Everything else (tables, strikethrough,
* tasklist, autolink, tagfilter) is already on in the default
* constructor.
*/
public static function github(): Options {}
/**
* Trusted-input preset: raw HTML passthrough (unsafe: true),
* tagfilter disabled, and liberal HTML tag parsing. Use only when
* the markdown source is authored by you or comes from a trusted
* pipeline; this preset explicitly disables the XSS safety net.
*/
public static function permissive(): Options {}
}
final class Parser
{
public readonly Options $options;
public function __construct(?Options $options = null) {}
public function toHtml(string $source): string {}
public function toXml(string $source): string {}
/**
* Returns a structural representation of the markdown source as
* a nested array. Link URLs and raw HTML literals are preserved
* verbatim -- the `unsafe`, `tagfilter`, and URL-scheme defenses
* apply to the rendering paths (`toHtml` / `toXml` / `toInlineHtml`),
* NOT to `toAst`. Consumers that emit HTML from the AST must
* apply their own URL scheme allowlist and HTML sanitization.
*/
public function toAst(string $source): array {}
/**
* Render `$source` as inline-only HTML: no `<p>` wrapper and no
* block-level constructs. Block markers like `#`, `-`, `>`, `1.`
* are emitted as literal text instead of being parsed as
* headings / lists / blockquotes. Matches the semantics of
* Parsedown::line() and cebe/markdown::parseParagraph() so users
* migrating from those libraries have a drop-in path for
* rendering short strings (chat messages, table cell contents,
* user display names) without the surrounding paragraph tags.
*
* `headingAnchors` is silently a no-op for this method (no headings
* are ever emitted in inline mode); `nofollowLinks` still applies.
* On empty or whitespace-only input the return value is the empty
* string. Literal U+200B (zero-width space) bytes in the source
* are stripped as collateral of the per-line sentinel mechanism.
*/
public function toInlineHtml(string $source): string {}
/**
* Static shortcut: parse `$source` with the default Options and
* return HTML. Equivalent to `(new Parser)->toHtml($source)` but
* without the object boilerplate for one-off conversions. Mirrors
* `Markdown::defaultTransform()` from michelf/php-markdown.
*/
public static function html(string $source): string {}
/**
* Static shortcut: parse `$source` with the default Options and
* return CommonMark XML.
*/
public static function xml(string $source): string {}
/**
* Static shortcut: parse `$source` with the default Options and
* return the nested-array AST.
*/
public static function ast(string $source): array {}
}