Code Monkey home page Code Monkey logo

Comments (6)

pkra avatar pkra commented on September 28, 2024

Ugh, it seems impossible to get the computed value of a CSS counter. So we can't populate our cross-reference with e.g., "Theorem 1" when using CSS counters to generate "1".

I've asked on mastodon https://bonn.social/@pkra/111314587141501059

from laml-wc.

pkra avatar pkra commented on September 28, 2024

Maybe for the best to keep it in the main node.

from laml-wc.

pkra avatar pkra commented on September 28, 2024

For the record, this was the css I was looking at

    chapter- {
      counter-reset: thmCounter;
    }
    thm- {
      counter-increment: thmCounter;
    }
    thm- > statement-label::after {
      content: ' ' counter(thmCounter) '. ';
    }
    blame-::before{
      content: ' ('
    }
    blame-::after{
      content: ') '
    }
<thm- id="thm-cantor">
      <blame->Cantor</blame->
      The set of all real numbers is uncountable.
    </thm->

giving us something like

image

from laml-wc.

pkra avatar pkra commented on September 28, 2024

Ah, I should push the code switching from "b" to "statement-label" elements (in the statement custom element).

from laml-wc.

pkra avatar pkra commented on September 28, 2024

Right now I'm thinking all we can do is to choose either the statement-label or the blame (and the given ID as fallback if things fail). Then the elements have to do the heavy work of making those meaningful. That makes ref- simple but only by shifting.

from laml-wc.

pkra avatar pkra commented on September 28, 2024

As it turns out, counters are hard (for me). First, I had to do the bad thing and grab some code from SO to get a counter to work at all -- and not understanding enough about custom elements and their constructors to really be sure it's how I'd like it to work -- plus, what I have right now wouldn't survive re-arranging the DOM.

Second, there's the problem of counter reset. The "best" I've come up is resetting in the constructor of the sectioning element. But of course that means I need custom elements for all sectioning. Probably not a huge deal since we only have section in HTML.

But still. It all feels horrid since CSS counters give me all of this for free.

This comment should be for a new issue, I suppose.

from laml-wc.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.