nlbdev / pipeline

NLB branch of the super-project that aggregates all Pipeline related code. See https://github.com/daisy/pipeline for the main branch.
http://repo.nlb.no/pipeline
3 stars 1 forks source link

Improve preview #153

Closed josteinaj closed 1 year ago

josteinaj commented 6 years ago
josteinaj commented 6 years ago

I did a little experiment earlier this week. Not sure if it's the right way to approach this issue or not, but I've pushed it here for reference: 9e43bca0bbc6bbe2cbee2172cf50c4c77485e7d8

matskober commented 6 years ago

You mean to keep "generated" braille as braille in preview?

bertfrees commented 6 years ago

This is one approach, yes. I see you copied the code from NabccEightDotTableProvider.java and then changed the mapping to (x) <-> (2800 + x). I presume you have yet to change that mapping?

If I were to write such a table now myself I would probably do it with Liblouis instead of BrailleUtils. I wrote that NABCC table back when Liblouis tables were not yet supported. The same table looks like this in Liblouis: https://github.com/liblouis/liblouis/blob/master/tables/text_nabcc.dis

Here is the table that SBS uses for the preview: https://github.com/sbsdev/pipeline/blob/sbs/modules/sbs/braille-tables/src/main/resources/tables/sbs.dis

render numbers as numbers

What exactly do you mean by that? Do you mean that the number 123 in braille (⠼⠁⠃⠉) should be rendered as #123 while abc in braille (also ⠁⠃⠉) should be rendered as ABC? That would be an interesting idea. One option would be to add dot 7 or 8 to the digits (⠼⡁⡃⡉) so that they can be rendered differently in the preview, and drop dots 7 and 8 again at the time the PEF is printed. The problem with this is of course that in some cases it may not be desired to drop dots 7 and 8.

Liblouis expands on this idea with its concept of virtual dots. With virtual dots added you have 14 dots at your disposal (16384 combinations) instead of the regular 8 dots (256 combinations). At the moment this is not usable outside of Liblouis though. A PEF only allows the 256 normal braille patterns at the moment and the same is true for braille CSS. (Not sure about OBFL.)

josteinaj commented 6 years ago

I presume you have yet to change that mapping?

Yes.

Here is the table that SBS uses for the preview

Interesting, that's probably the way to go for us as well then? At least for letters like ÆØÅ? Could liblouis back-translation rules be used for rendering numbers in such a table?

Do you mean that the number 123 in braille (⠼⠁⠃⠉) should be rendered as #123 while abc in braille (also ⠁⠃⠉) should be rendered as ABC?

Yes. It would be fairly simple to implement in Java, XSLT or whatever by iterating over the characters, looking for ⠼, and replacing abcdefghij with 1234567890.

I'm pretty confident I could do this as a post-processing step by passing the preview through an XSLT, but I wanted to see if there was a "proper" way of doing it first.

bertfrees commented 6 years ago

Yes it should be possible to do in a post-processing step. The proper way is to do it in Liblouis the way I described above, but at the moment we can't. So I'm not sure what to do. A post-processing step is a bit of a hack and to do it the proper way may require considerable changes.

josteinaj commented 6 years ago

Doing it in post-processing should be pretty straight forward, so I guess that would be fine for now.

bertfrees commented 6 years ago

The following changes are required to make the system not specific to Unicode braille:

josteinaj commented 6 years ago

I've now added a post-processing XSLT for the preview so that numbers are rendered as numbers, ÆØÅ and æøå are rendered properly, and characters should have the correct upper case / lower case (words in all upper case that are hyphenated won't have their last part rendered in upper case though).

We could do the "not all braille characters needs to be translated to ascii" bullet point I mentioned at first there as well, but I think that would require some more thought as to which characters should be affected.

It's also pretty straight forward during post processing to replace characters 1:1. For instance, we could make punctuation marks and commas actually look like puncuation marks and commas if we want to.

See: 77f5b933ecd87c50c4f7740099f7e1d041ddcef4

bertfrees commented 5 years ago

I can't open the preview anymore.

In order to make it work I need to change <script type="text/javascript" src="pef-preview.js"/> to <script type="text/javascript" src="pef-preview.js"></script>.

bertfrees commented 5 years ago

And also <span class="bookmark" id="x"/> to <span class="bookmark" id="x"></span>.

josteinaj commented 5 years ago

Ah, I see. post-process-preview.xsl should have had a <xsl:output indent="no" method="xhtml"/>.