- From: Lars Wallin <lars@colibrio.com>
- Date: Thu, 17 Feb 2022 07:33:51 +0100
- To: "Xu Zheng (gardenia)" <zxu@gardenia-corp.com>
- Cc: W3C Publishing Community Group <public-publishingcg@w3.org>
- Message-ID: <CAN9weQwV4VbqCecTacsynTFbeOgSNy4paQ-ZQJbr=6O-xC3OWw@mail.gmail.com>
Hey Xu Zheng 👋 There is actually already a standard for this. Have a look at the Web Annotation Selectors and States document https://www.w3.org/TR/selectors-states/#CssSelector_def https://www.w3.org/TR/selectors-states/#serializing-iri-to-url Let's show the Web Annotations spec the love it deserves 🙂 As EPUBCFI supports "extensions" which would let you tag these selectors on to the CFI, making it EPUB compatible 👌 http://idpf.org/epub/linking/cfi/epub-cfi.html#sec-extensions Cheers, Lars On Thu, 17 Feb 2022, 03:37 Xu Zheng (gardenia), <zxu@gardenia-corp.com> wrote: > Hi folks > > This week POC ( > https://wysebee.com/?startSelector=%23home-header%3A0%3A8&endSelector=%23home-header%3A0%3A15) > to select a random string in web browser bring me back to one question > again. > > "Can we change CFI spec a bit to support CSS Selector"? > > > As a reading system programmer the most difficult part to implement CFI > for highlight are: > 1. need to go through all element to identify element for CFI such as > following > > /6/4!/4/10/2/1 > > 2. when we have this CFI generated for highlight then it's still difficult > to go through DOM to locate this element when rendering highlight. > > > I went through CSS selector again as well it is possible to use CSS > selector to locate every element (for example implementation like this > https://www.npmjs.com/package/css-selector-generator). > > And actually I remember when someone had brought up CFI to CSS WG and Web > browser vendor a few years ago mostly two questions raised from them: > > 1. why don't use CSS selector > > 2. should avoid inventing new way attaching to URI such as following > > #epubcfi(/6/4!/4/10/2/1:3[%d0%a4-%22spa%20ce%22-99%25-aa^[bb^]^^]) > > > The rest of CFI I think are very useful by defining charOffset of each > text node and the node index of the target node which are not covered by > CSS Selector (you might want to ask - can we ask CSS Selector to support > selecting charOffset? I am not sure since CSS Selector seems only select > element (https://www.w3.org/TR/selectors-4/#context) ). > > > So I wonder, maybe we still can find a unified way to define annotation > but with slightly changed CFI. > > > In the POC I tried format like > > ?startSelector=<CSS Selector>:<node index>:<charOffset>&endSelector=<CSS > Selector>:<node index>:<charOffset> > > But if make it more closer to "CFI" we might have something like this? So > even if web browser might not support it natively but as long as epub could > support then we can have something unified that end user could share > highlight in the same book but different reading app. > > ?epubcfi=<CSS Selector>:<node index>:<charOffset>,<CSS Selector>:<node > index>:<charOffset> > > > And this format can satisfy "path-relative-scheme-less-URL string > <https://url.spec.whatwg.org/#path-relative-scheme-less-url-string>" > > > Cheers, > > -- > Zheng Xu > > Chief Executive Officer > Gardenia Corphttps://gardenia-corp.com/ > >
Received on Thursday, 17 February 2022 06:35:14 UTC