-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Editor: Introduce HTML Tag Processor #3920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
15863a8
Introduce HTML Tag Processor
dmsnell 40e1cb3
Move class_exists calls to wp-html
dmsnell 8b507e5
Mark helper classes `final`
dmsnell 561acff
Updates from review feedback, mostly docs
dmsnell 57550e7
WP_HTML_Tag_Processor_Test: test improvements
hellofromtonya b708c6b
Load API files directly from wp-settings.php
hellofromtonya 521a500
Tests: remove loading API files
hellofromtonya 8bdfae4
Renames test classes to coding standard
hellofromtonya bc17086
Renames test filenames to coding standard
hellofromtonya 334e415
Cleans HEADS from merge conflict from test file
hellofromtonya def4ed4
Reword explanation of lexical updates
dmsnell b924e03
docblock and consistency updates, addressing some PR feedback
dmsnell 91dc772
Move HTML processing modules into new html directory
dmsnell 1fd0d7d
Documentation wording updates.
dmsnell 361710d
Rename library to "HTML-API" instead of "HTML"
dmsnell 2d1411a
Un-finalize helper classes
dmsnell d8fdf41
Replace throwing with trigger_error( E_USER_WARNING )
dmsnell 1465218
Add test to check for bug when encounting unexpected </SCRIPT> closer
dmsnell 5c1a5d5
Update tests: fix data provider and remove Exception expectation
dmsnell c50ffee
Lint issue
dmsnell 9a5ccf0
Fix broken tests
dmsnell 13dd7d7
Remove some TODOs, most were done already
dmsnell b31cca4
Expand design and limitations discussion
dmsnell 1a9bec0
Loosen assertion on warning
dmsnell 28e9bf3
Rename some properties to clarify their purpose and expand comments.
dmsnell 1e2ef09
Linter: yoda condition
dmsnell 243dc7c
Typos in comments
dmsnell 8152988
Rework @covers attributes
dmsnell a5f2d96
Was doing it wrong w.r.t. doing_it_wrong
dmsnell 5b1d47e
Add additional type check to avoid throwing _doing_it_wrong error whe…
dmsnell 3f9b274
Lada la di
dmsnell 1b8c75c
Remove checks that _doing_it_wrong throws a notice
dmsnell aad5310
Set expected incorrect usage in tests.
dmsnell 4a43850
Docblock updates
dmsnell fbbf382
Shorten function summary
dmsnell 5b4ad8f
Ensure test assertions have a message parameter
dmsnell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| <?php | ||
| /** | ||
| * HTML Tag Processor: Attribute token structure class. | ||
| * | ||
| * @package WordPress | ||
| * @subpackage HTML | ||
| * @since 6.2.0 | ||
| */ | ||
|
|
||
| /** | ||
| * Data structure for the attribute token that allows to drastically improve performance. | ||
| * | ||
| * This class is for internal usage of the WP_HTML_Tag_Processor class. | ||
| * | ||
| * @access private | ||
| * @since 6.2.0 | ||
| * | ||
| * @see WP_HTML_Tag_Processor | ||
| */ | ||
| final class WP_HTML_Attribute_Token { | ||
| /** | ||
| * Attribute name. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var string | ||
| */ | ||
| public $name; | ||
|
|
||
| /** | ||
| * Attribute value. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var int | ||
| */ | ||
| public $value_starts_at; | ||
|
|
||
| /** | ||
| * How many bytes the value occupies in the input HTML. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var int | ||
| */ | ||
| public $value_length; | ||
|
|
||
| /** | ||
| * The string offset where the attribute name starts. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var int | ||
| */ | ||
| public $start; | ||
|
|
||
| /** | ||
| * The string offset after the attribute value or its name. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var int | ||
| */ | ||
| public $end; | ||
|
|
||
| /** | ||
| * Whether the attribute is a boolean attribute with value `true`. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var bool | ||
| */ | ||
| public $is_true; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @since 6.2.0 | ||
| * | ||
| * @param string $name Attribute name. | ||
| * @param int $value_start Attribute value. | ||
| * @param int $value_length Number of bytes attribute value spans. | ||
| * @param int $start The string offset where the attribute name starts. | ||
| * @param int $end The string offset after the attribute value or its name. | ||
| * @param bool $is_true Whether the attribute is a boolean attribute with true value. | ||
| */ | ||
| public function __construct( $name, $value_start, $value_length, $start, $end, $is_true ) { | ||
| $this->name = $name; | ||
| $this->value_starts_at = $value_start; | ||
| $this->value_length = $value_length; | ||
| $this->start = $start; | ||
| $this->end = $end; | ||
| $this->is_true = $is_true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <?php | ||
| /** | ||
| * HTML Span: Represents a textual span inside an HTML document. | ||
| * | ||
| * @package WordPress | ||
| * @subpackage HTML | ||
| * @since 6.2.0 | ||
| */ | ||
|
|
||
| /** | ||
| * Represents a textual span inside an HTML document. | ||
| * | ||
| * This is a two-tuple in disguise, used to avoid the memory | ||
| * overhead involved in using an array for the same purpose. | ||
| * | ||
| * This class is for internal usage of the WP_HTML_Tag_Processor class. | ||
| * | ||
| * @access private | ||
| * @since 6.2.0 | ||
| * | ||
| * @see WP_HTML_Tag_Processor | ||
| */ | ||
| final class WP_HTML_Span { | ||
| /** | ||
| * Byte offset into document where span begins. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var int | ||
| */ | ||
| public $start; | ||
|
|
||
| /** | ||
| * Byte offset into document where span ends. | ||
| * | ||
| * @since 6.2.0 | ||
| * @var int | ||
| */ | ||
| public $end; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @since 6.2.0 | ||
| * | ||
| * @param int $start Byte offset into document where replacement span begins. | ||
| * @param int $end Byte offset into document where replacement span ends. | ||
| */ | ||
| public function __construct( $start, $end ) { | ||
| $this->start = $start; | ||
| $this->end = $end; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.