Skip to content

WP_HTML_Tag_Processor: Support tag closer bookmarks#4115

Closed
adamziel wants to merge 2 commits intoWordPress:trunkfrom
adamziel:html-api-start-bookmarks-before-tag-opener-also-in-tag-closers
Closed

WP_HTML_Tag_Processor: Support tag closer bookmarks#4115
adamziel wants to merge 2 commits intoWordPress:trunkfrom
adamziel:html-api-start-bookmarks-before-tag-opener-also-in-tag-closers

Conversation

@adamziel
Copy link
Copy Markdown
Contributor

@adamziel adamziel commented Feb 22, 2023

Description

With this PR seek() correctly finds bookmarks set on tag closers. It:

  • Uses the correct starting index for tag closer bookmarks
  • Adds array( 'tag_closers' => 'visit' ) in seek()

About bookmark start indices:

Setting a bookmark on a tag should set its "start" position before the opening "<", e.g.:

<div> Testing a <b>Bookmark</b>
----------------^

The current calculation assumes this is always one byte to the left from $tag_name_starts_at.

However, in tag closers that index points to a solidus symbol "/":

<div> Testing a <b>Bookmark</b>
----------------------------^

The bookmark should therefore start two bytes before the tag name:

<div> Testing a <b>Bookmark</b>
---------------------------^

Trac ticket: https://core.trac.wordpress.org/ticket/57787

cc @ockham @dmsnell @gziolo

…king a tag closer

This commit marks the start of a bookmark one byte before
the tag name start for tag openers, and two bytes before
the tag name for tag closers.

Setting a bookmark on a tag should set its "start" position
before the opening "<", e.g.:

```
<div> Testing a <b>Bookmark</b>
----------------^
```

The current calculation assumes this is always one byte
to the left from $tag_name_starts_at.

However, in tag closers that index points to a solidus
symbol "/":

```
<div> Testing a <b>Bookmark</b>
----------------------------^
```

The bookmark should therefore start two bytes before the tag name:

```
<div> Testing a <b>Bookmark</b>
---------------------------^
```
@hellofromtonya hellofromtonya self-requested a review February 22, 2023 14:36
Copy link
Copy Markdown
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Before applying WP_HTML_Tag_Processor changes, the test fails 🔴
  • After applying the WP_HTML_Tag_Processor changes, the test passes 🟢

The changes work as described ✅ Ready for commit 👍

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamziel LGTM as well!

Copy link
Copy Markdown
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound. Thanks @adamziel

@hellofromtonya
Copy link
Copy Markdown
Contributor

Committed via https://core.trac.wordpress.org/changeset/55407.

ockham added a commit to WordPress/gutenberg that referenced this pull request Mar 2, 2023
In the 6.2 compat layer, support bookmarks pointing to closing tags.

This is for parity with Core in WP 6.2, see WordPress/wordpress-develop#4115 and [r55407](https://core.trac.wordpress.org/changeset/55407).

Note that these changes have already been backported to GB's 6.**3** compat layer in #48378. However, since the change will be in WP 6.2, we also have to apply it to GB's 6.2 compat layer.
ockham added a commit to WordPress/gutenberg that referenced this pull request Mar 2, 2023
In the 6.2 compat layer, support bookmarks pointing to closing tags.

This is for parity with Core in WP 6.2, see WordPress/wordpress-develop#4115 and [r55407](https://core.trac.wordpress.org/changeset/55407).

Note that these changes have already been backported to GB's 6.**3** compat layer in #48378. However, since the change will be in WP 6.2, we also have to apply it to GB's 6.2 compat layer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants