Giter VIP home page Giter VIP logo

Comments (10)

5e-Cleric avatar 5e-Cleric commented on May 26, 2024

If every author came to a standard, we could have a simple input on the properties tab, and use that to know where to insert the auto page number snippet.

Ideally, we could have that, and people could still opt to use the manual snippet.

from homebrewery.

G-Ambatte avatar G-Ambatte commented on May 26, 2024

Possible solutions:

  • Use .page:before to create an automatic page number element. I would expect this approach to be CSS only, if so, it could be a Style Editor snippet.
  • Modify the footer bar in .page:after to include the page number (although using transform: scaleX(-1); to flip the footer would then require that the text content be flipped again to return it to the correct orientation).

from homebrewery.

G-Ambatte avatar G-Ambatte commented on May 26, 2024

CSS for auto page numbers without having to {{pageNumber,auto}} every page using .page:before:

.page:before {
  content: counter(phb-page-numbers);
  position: absolute;
  right: 2px;
  bottom: 22px;
  width: 50px;
  font-size: .9em;
  color: var(--HB_Color_Footnotes);
  text-align: center;
  text-indent: 0;
}
.page:nth-child(even):before {
  left: 2px;
}

EDIT: Putting this in as a Style Editor snippet would have the widest possible compatibility.

from homebrewery.

G-Ambatte avatar G-Ambatte commented on May 26, 2024

Now that :has() is functional in Chrome, we could theoretically do things like this:

.pages:has(.autoNumberOn) .page:before {
  content: counter(phb-page-numbers);
  position: absolute;
  right: 2px;
  bottom: 22px;
  width: 50px;
  font-size: .9em;
  color: var(--HB_Color_Footnotes);
  text-align: center;
  text-indent: 0;
}
.pages:has(.autoNumberOn) .page:nth-child(even):before {
  left: 2px;
}

As long as there is an element within the .pages element somewhere that has the class autoNumberOn, then the automatic page numbering is applied.

Throwing CSS nesting into the mix:

.pages:has(.autoNumberOn) {
  .page {
    &:before {
      content: counter(phb-page-numbers);
      position: absolute;
      right: 2px;
      bottom: 22px;
      width: 50px;
      font-size: .9em;
      color: var(--HB_Color_Footnotes);
      text-align: center;
      text-indent: 0;
    }
    &:nth-child(even):before {
      left: 2px;
    }
  }
}

EDIT: These solutions have much narrower compatibility profiles.

from homebrewery.

ericscheid avatar ericscheid commented on May 26, 2024

Almost didn't notice you wrote .pages and not .page.

You'd still need a mechanism to turn off the page number for specific pages, such as any cover pages or section breaks, or any page set aside for full bleed images, etc.

So, maybe this?

.pages:has(.autoNumberOn) {
  .page:has(not.autoNumberOff) {
  ...

from homebrewery.

G-Ambatte avatar G-Ambatte commented on May 26, 2024
.page:has(.autoNumberOff):before {
   display: none;
}

from homebrewery.

G-Ambatte avatar G-Ambatte commented on May 26, 2024

Almost didn't notice you wrote .pages and not .page.

The nested CSS makes that kind of change a lot more obvious.

from homebrewery.

Gazook89 avatar Gazook89 commented on May 26, 2024

In my opinion, the better solution is likely to create some sort of generator/js function to add the page numbers at a point-of-time when the user decides. Rather than rely on browser-limited CSS rules.

Some indicator on each page that you want a page number on them (or don't wnat a page number) which is then organized by a function and replaced with the correct markdown at the bottom of each page in the editor when the user clicks "create page numbers".

When we were setting up v3 we reserved the space on the \page lines so nothing could be on those lines. Now, we could we add new syntax for that line, like

\page #

Which would indicate a desired page number. The syntax could even be more robust. For example, the below syntax would indicate that the page should be numbered as page "1", and the numbering should continue from 1 on subsequent pages.

\page #1

As always, you can get more complicated. More syntax options:

\page # "Introduction | Setting"

// adds a page number and fills the Fancy Footer section with the quoted text.
\page # "$PART | $H2"

// adds a page number and fills the Fancy Footer with the text of the most recent Part snippet, followed by the most recent h2 element to the end of the page.

When a user wants to clear their page numbers to re-run the generation (or some other reason), another button can run a function that just clears everything on the new page lines after the \page.

from homebrewery.

ericscheid avatar ericscheid commented on May 26, 2024

For things that occur on multiple pages, repetitively, it might be prudent to consider using variables.

#1400

from homebrewery.

5e-Cleric avatar 5e-Cleric commented on May 26, 2024

If i understand this correctly:

\page #
would insert a page with auto numbering,
\page # "Creating a character"
would insert a page with auto numbering and that text as footer,
\page #X
would insert a page with manual number set of X,
\page #X "Creating a character"
would insert a page with manual number set of X and that text as footer.

Would that be correct?

Assuming i got that right, we might want to consider using #auto instead of #, to make it easier for users
otherwise, this looks like a great idea, with no unnecesary syntax.

from homebrewery.

Related Issues (20)

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.