speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
293 stars 36 forks source link

Unicode variation and orphaned headings #517

Closed serpent213 closed 9 months ago

serpent213 commented 10 months ago

Thank you for this amazing werkzeug, I was just evaluating tools to create a cheat sheet and stumbled upon an old StackOverflow post pointing in this direction. Couldn't find anything else coming close! (Excluding non-free offers)

So maybe these are newbie (non-)issues.

I'd like to use a zero with a slash to distinguish it from the letter "O". Had this working in xelatex using

{\addfontfeature{Numbers=SlashedZero}0}

with the Noto font and now trying to use the proper Unicode variation directly in my input. The result is a plain old zero.

Also I'm wondering how to move a heading (and table head) to the next frame in case they would be orphaned. I tried to include the heading as part of the table, but I guess that's not supported (couldn't even extract the number of columns of the upcoming table using XPath). Also tried to figure out the cursor position to go from there, but to no avail (always returns row 2 🤷🏼‍♂️).

You can find my attempts here and here, see first and last pages mainly. See here for the Unicode variation input.

Of course I'd be happy to learn about any other possible improvements to my code! 🙂👍🏻

pgundlach commented 10 months ago

Have you tried using font features?

https://doc.speedata.de/publisher/en/basics/fonts/#_opentype_features

 <LoadFontfile name="NotoSans-Regular"
      filename="NotoSans-Regular.ttf"
      mode="harfbuzz"
      features="+zero" />

?

This is just a quick guess, I will take a thorough look at your code tomorrow.

(I'll skip the other question for tomorrow as well)

serpent213 commented 10 months ago

That was fast – and enabling HarfBuzz did the trick, thanks!

pgundlach commented 10 months ago

This is very impressive! I really like the combination of CSV, ini, Lua and the XML layout.

The <Message> in the layout is slightly incorrect (not really incorrect, but not useful):

<Message select="concat('current-row: ', sd:current-row('content')), '/', sd:number-of-rows('content')" />

without the 'content' in the two functions, you get the current row of the main area, which is not used.

So you can say for example

<Switch>
  <Case test="sd:number-of-rows('content') - sd:current-row('content') &lt; 10">
    <NextFrame area="content" />
  </Case>
</Switch>

to have some kind of orphan control.

serpent213 commented 10 months ago

Thank you for the kind words! The goal is to make it approachable and easy to edit for non-developers.

Yes, the 'content' was missing, that's what I had in mind. And it somewhat works as expected, but I'm dealing with unexpected side-effects of the Message expression now. I.e. when including the Message it works fine, but surprisingly the first evaluation of the concatenation is not complete:

% sp --grid --verbose 2>&1 | grep current-row
Message: "current-row: 1"
Message: "current-row: 19/19"
Message: "current-row: 4/19"
Message: "current-row: 17/19"
Message: "current-row: 13/19"
Message: "current-row: 7/19"

With Message commented out the algorithms fails and the very first column ends up blank as can be observed in this commit. Tested with 4.14.0 and 4.15.4.

Regarding the INI file, if I read the varsfile parser correctly, my line comments only work because they don't contain a =. Might it be an option to implement real line comments?

Also maybe it is worth considering to exclude dot files and folders from the local recursive scan. I noticed various warnings resulting from duplicate files in my .git directory. Not a deal breaker, of course. 🙂

pgundlach commented 10 months ago

I believe you have hit a few bugs here...

As a workaround for the necessary <Message> command, you can say <NextRow area="content" rows="0"/> to have the same effect.

But strangely this also works:

    <SetVariable variable="rowsleft" select="sd:number-of-rows('content') - sd:current-row('content')"/>
    <Switch>
      <Case test="$rowsleft &lt; 10">
        <NextFrame area="content" />
      </Case>
    </Switch>

I will investigate what happens why this happens.

I will also open separate issues (#518, #519)

serpent213 commented 9 months ago

Using the <SetVariable> workaround for now. Looks good. 🙂