[liblouis-liblouisxml] Re: Here's the Python formatter

  • From: Lars Bjørndal <lars@xxxxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Sat, 19 Dec 2020 13:50:50 +0100

Hi!

You may try out file2brl from liblouisutdml, found here: 
https://github.com/liblouis/liblouisutdml

File2brl can convert from XML/HTML to formatted braille.

Lars

On Sat, Dec 19, 2020 at 12:08:31AM -0600, Devin Prater wrote:

One problem I had with this, is that it seems to only convert plain text. I
tried it with an HTML file, and it just converted the HTML code into
braille, not converting the HTML formatting into formatted braille. I
planned to use this to emboss stuff from Linux, as the translator that
cups-filters is trying to use doesn't seem to be working.

On 12/18/20 2:27 AM, John J. Boyer wrote:
Hello Michael,

Thanks for the list example. I'll probably do something like that. I still 
have to study comprehension.

John

On Fri, Dec 18, 2020 at 07:46:19AM +0000, Michael Whapples wrote:
Hello,

I left out the docstring to keep the email short and as it has little to 
do
with the functioning of the code. Of course you can add it back in and 
that
may be a good plan.


The "with" statements are much clearer than the associated
try/except/finally blocks would be for similar reliability of closing the
files. The for iteration of the lines I think is clearer than a while loop
with an if and break. However its your code so do what you think you
understand more.


As for joining many strings, I think using a list and then the str.join
method is the way to go.


str_list = []

str_list.append("First line")

str_list.append("Second line")

long_string = "\n".join(str_list)


I believe this may be even quicker if it can be done with a list
comprehension.


Michael Whapples

On 18/12/2020 03:30, John J. Boyer wrote:
Hello Michael,

Thanks for the suggestions. However, I felt the program was much easier 
to understand as I wrote it, without so many Pyth-y features.
I also wanted to make it self-contained with a doc string at the 
beginning.

Now I'm trying to find a way to combine many short strings which are 
lines from the input file into a long string that approximates a 
paragraph.
This would be passed to translateString to produce a more readable 
outpout. The hard part is to do this efficiently, without a lot of 
garbage collection.

John

For a description of the software, to download it and links to
project pages go to http://liblouis.org
Donate: http://liblouis.org/sponsoring
For a description of the software, to download it and links to
project pages go to http://liblouis.org
Donate: http://liblouis.org/sponsoring
For a description of the software, to download it and links to
project pages go to http://liblouis.org
Donate: http://liblouis.org/sponsoring

Other related posts: