[WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Bernd Sitzmann
Hi, I'm building the ToC entries from Parsoid HTML content. Another part which caused some struggle is building the correct anchors for the section headings. First I thought I could just use the id attributes in the heading tags Parsoid provides[2]. Example from [1]: Template truncation But the

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Subramanya Sastry
On 10/27/2015 01:38 PM, Bernd Sitzmann wrote: Hi, I'm building the ToC entries from Parsoid HTML content. Another part which caused some struggle is building the correct anchors for the section headings. In the past, we discussed generating HTML5 ids rather than the munged ids that are curr

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Gergo Tisza
​If you care about edge cases, section anchor generation is rather complicated: anchors can be postfixed with an index when there are multiple identical titles, and HTML, templates and parser tags are handled differently for display and for anchor generation. (Yes, these can and do appear in titles

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Subramanya Sastry
On 10/27/2015 03:48 PM, Gergo Tisza wrote: ​If you care about edge cases, section anchor generation is rather complicated: anchors can be postfixed with an index when there are multiple identical titles, This would need to be handled to guarantee id uniqueness. and HTML, templates and parse

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Gabriel Wicke
Another option could be to use compact stable element IDs not based on the content. This would be less readable, but on the upside there wouldn't be any collisions, and links wouldn't break on minor heading changes. On Tue, Oct 27, 2015 at 2:04 PM, Subra

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Gergo Tisza
On Tue, Oct 27, 2015 at 2:04 PM, Subramanya Sastry wrote: > But, if we move core and Parsoid to HTML5 ids, this shouldn't matter since > the only restriction on HTML5 ids is that they shouldn't contain a space > char as per > https://html.spec.whatwg.org/multipage/dom.html#the-id-attribute You

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Bernd Sitzmann
Subbu, Gergo and Gabriel: Thank you for your comments so far. Just to be clear, ideally I want the anchor ids to be the same as used in Core. I would really like for Parsoid to provide the same anchor ids as Core does. Then that would take also care of the uniqueness issue. Is there a task for th

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Subramanya Sastry
1. Parsoid doesn't generate section ids now, but when we do, yes, we'll make sure ids are compatible with core ids and unique. Will check the phpjs library code to see what we are missing. We don't have a ticket for generating section ids yet. 2. At some point, it makes sense to switch both

Re: [WikimediaMobile] Building anchors from (Parsoid) toc line; anchorencode

2015-10-27 Thread Bernd Sitzmann
Thanks, I've created a task for this [1] and updated my patch [2]. The advantage of having this done by Parsoid or even higher upstream is that if/when the ids get generated differently we would get it for free. [1] https://phabricator.wikimedia.org/T116876 [2] https://gerrit.wikimedia.org/r/2461