[wp-trac] [WordPress Trac] #59993: HTML API: Track spans of text with (offset, length) instead of (start, end)

WordPress Trac noreply at wordpress.org
Thu Nov 30 19:55:38 UTC 2023


#59993: HTML API: Track spans of text with (offset, length) instead of (start, end)
-------------------------+-----------------------------
 Reporter:  dmsnell      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  HTML API     |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch
  Focuses:               |
-------------------------+-----------------------------
 This patch follows-up with earlier design questions around how to
 represent spans of strings inside the class. It's relevant now as
 preparation for #5683.

 The mixture of (offset, length) and (start, end) coordinates becomes
 confusing at times and all final string operations are performed with the
 (offset, length) pair, since these feed into strlen().

 In preparation for exposing all tokens within an HTML document this
 change:

 Unifies the representation throughout the class.
 It creates token_starts_at to track the start of the current token.
 It replaces tag_ends_at with token_length for re-use with other token
 types.
 There should be no functional or behavioral changes in this patch.

 For the internal helper classes this patch introduces breaking changes,
 but those classes are marked private and should not be used outside of the
 HTML API itself.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59993>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list