w3c / jlreq

Text Layout Requirements for Japanese
https://w3c.github.io/jlreq/
Other
101 stars 17 forks source link

How to add ID to an element? #154

Open xfq opened 4 years ago

xfq commented 4 years ago

We should probably mention how to add ID to an element in EDITING.md.

For example, if I want to add a new li after id250, what id should I use? There is already an id251 so I shouldn't use it.

/cc @r12a

himorin commented 4 years ago

In my understanding, these ids were assigned by old document generation tool based on xml/sgml used during 1st ed to 2nd ed period, and not fully used (just kept as is) for now. So, I'd propose just not to assign these ids to new element(s).

xfq commented 4 years ago

Related: https://github.com/w3c/jlreq/issues/7

himorin commented 4 years ago

(I think I might miss something on respec behavior, while checking various outputs.) Let me check what we can get, and say something, but mixing automatic assignment (e.g. section, div with special class, by respec) and manual assignment like nX or figX-X by old JLReq compilation tools seems to be harmful for me.

r12a commented 4 years ago

Here are various thoughts:

  1. let's not change any of the ids currently in the source text, otherwise links will break
  2. we shouldn't rely on any ids produced by respec, since these will change and links will break. We should try to add ids to the source text wherever they are useful for linking.
  3. i proposed a method for adding new ids at https://github.com/w3c/jlreq/issues/7#issuecomment-288099257 which i think we should adopt. Basically use the format id="f20191217000" where the first set of digits represents the date per UTC, and the last 3 digits are unique within a day, and are reset to 000 each UTC day. If we are in agreement to adopt that policy, i agree with Fuqiao that we should document it in EDITING.md.
  4. it would be useful if the reader was able to see the ids more easily. I wonder whether we can apply some javascript to display § in the margin, like respec does for headings.
xfq commented 4 years ago

it would be useful if the reader was able to see the ids more easily. I wonder whether we can apply some javascript to display § in the margin, like respec does for headings.

I made a simple demo that might be an inspiration for this feature: https://xfq.github.io/testing/jlreq-li-self-links/#id248

Relevant JavaScript code: https://github.com/xfq/testing/blob/eba3b823556d88ec2ed025a5e819cd5ea669df82/jlreq-li-self-links/script.js#L144-L152

himorin commented 4 years ago

Sorry that I've commented (in the past) with wrong understanding, that the last script block L24579-L24600 is active and some parts are assigned by that... I agree with points 1 and 2 by Richard, but not sure point 3 could work well by means of uniqueness, like two editors start working on separate PR from the same day. It may require some additional work, but how about to use github issue/PR ID for the first set?

himorin commented 4 years ago

I made a simple demo that might be an inspiration for this feature: https://xfq.github.io/testing/jlreq-li-self-links/#id248

Relevant JavaScript code: https://github.com/xfq/testing/blob/eba3b823556d88ec2ed025a5e819cd5ea669df82/jlreq-li-self-links/script.js#L144-L152

Note, this demo also works with postProcess in respec: https://himorin.github.io/w3c-memo/tools/samples/respec-basic.html

xfq commented 4 years ago

I agree with points 1 and 2 by Richard, but not sure point 3 could work well by means of uniqueness, like two editors start working on separate PR from the same day. It may require some additional work, but how about to use github issue/PR ID for the first set?

I agree that this is an issue, but this method might not work if:

  1. the commit does not have an associated issue/PR, or
  2. we decide to move from GitHub to another code hosting platform in the future (so the issue number might conflict).

We can solve #1 by requiring every commit (or every commit that adds a new ID) to have an issue/PR associated with it, but I'm not sure how to solve #2.

himorin commented 4 years ago

Running codes on console over current HEAD of jlreq (at github.io) over 'selection li' and 'selection div.note', nothing was listed. So I believe there is no unassigned item made by recent changes.

list_li = document.querySelectorAll('section li');
j = 0; list_li.forEach(function(elem) {if (! elem.id) {console.log(elem); j++}});console.log(j);

So, let me mark this as future, but not a blocker for planned release by #141.

himorin commented 4 years ago

Note: we need to modify EDITING.md also when we settle this in future.

kidayasuo commented 8 months ago

Removed label jlreq-doc:editorial. Added jlreq-doc:enhancement. Will evaluate for jlreq-d.