Open ericscheid opened 1 year ago
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.
Possible solutions:
.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..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).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.
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.
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) {
...
.page:has(.autoNumberOff):before {
display: none;
}
Almost didn't notice you wrote
.pages
and not.page
.
The nested CSS makes that kind of change a lot more obvious.
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
.
For things that occur on multiple pages, repetitively, it might be prudent to consider using variables.
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.
Your idea:
Currently, an author needs to insert the page number snippet onto each page to have page numbers show up.
It would be cool if there was a snippet/command that would insert that snippet onto every page in one go (except any that already has it, and except any pages marked as cover pages or section pages).
A clever author could kinda do this with a find/replace for the text
\page
and a bit of manual cleanup