[Done] Enhancement: Images in HTML / ALT-Text

Post Reply
User avatar
Michael Uplawski
Posts: 177
Joined: Thu Dec 11, 2014 11:43 pm
Location: Canton Magny (previously Canton Carrouges), Orne, Normandy (previously Lower Normandy)

[Done] Enhancement: Images in HTML / ALT-Text

Post by Michael Uplawski »

Good evening.

This applies to SoftMaker Office in general, although I have currently only use for the feature in TextMaker.

When I copy&paste fragments of HTML-content from a browser into TextMaker, <img/> is honored in the way that the picture is included in the TextMaker version of the document. The picture appears to be embedded, it has obviously been found in the cache (I hope so) upon pasting into TextMaker.

My suggestion is the same or similar behavior upon opening a html page from hard-disk. My example is the weather-forecast on meteociel: https://www.meteociel.fr/previsions/48191/nurnberg.htm. I do not know how you can ensure the presence of a picture file, but my imagination gives me several solutions. In case of doubt, ask the user to provide a path or something... this is not a big problem and not worth discussing.

When I copy&paste the table to textmaker, the display is immaculate:
sc_meteociel_copy.png
But as I rather download the weather information with a script, the raw HTML snippet containing the <table/> is stored in a temporary HTML-file. The icons in the outer right column of the table are referenced like this:

Code: Select all

<img alt="Couvert" title="Couvert" src="//static.meteociel.fr/prevision/test/picto/nuageux.gif">
But reading this, TextMaker cannot show the icon.

Anyway, TextMaker should show the alternate-text for pictures, i.e. the value of the alt-attribute (in the example above: « Couvert »), each time that it cannot honor the <img/> tag for whichever reason. This is probably even more important than the display of images. In my example of weather data from meteociel, this concerns mainly the wind-directions which are only roughly indicated by the icons, but precise in the alt- and title-attributes.

Edits: Improved wording in an attempt to gain intelligibility.
Last edited by Michael Uplawski on Thu Oct 31, 2019 8:25 pm, edited 7 times in total.
Hindsight is in the eye of the beholder.
User avatar
Michael Uplawski
Posts: 177
Joined: Thu Dec 11, 2014 11:43 pm
Location: Canton Magny (previously Canton Carrouges), Orne, Normandy (previously Lower Normandy)

Re: Enhancement: Images in HTML / ALT-Text

Post by Michael Uplawski »

This workaround is more an additional argument for the use of the alternate text than a “solution”:

First, I scrutinize the temporary HTML-file for src attributes, i.e. URLs of images. Then I fetch each one of the referenced pictures, separately, and store it under its original file-name, but in the local temp-directory, alongside the HTML-file. In the end, I replace all the image-URLs against simple file-names:

Code: Select all

# fetch icons
for s in `xmllint --html --xpath '//@src' /tmp/file.html`
do
  PTH=`echo $s | cut -f2 -d\"`
  PTH=https:/$PTH
  FLE=`echo $PTH | cut -f8 -d\/`
  if [ ! -e $FLE ]
  then
    echo "fetching picture $FLE"
    curl "$PTH" --output /tmp/$FLE
  fi
done

# point to local icons, meaning: remove the path before the file-name.
sed -i "s/src\=\"\/\/PATH\/COMPONENT\/OF\/img-URL\//src=\"/g" /tmp/file.html
edits: Kraut2English and lots of corrections everywhere
Hindsight is in the eye of the beholder.
miguel-c
SoftMaker Team
SoftMaker Team
Posts: 1233
Joined: Wed Jun 05, 2019 12:02 pm

Re: Enhancement: Images in HTML / ALT-Text

Post by miguel-c »

Hello, Michael,
I just forwarded your message to the product manager and developers.
Thank you for your feedback!
User avatar
Michael Uplawski
Posts: 177
Joined: Thu Dec 11, 2014 11:43 pm
Location: Canton Magny (previously Canton Carrouges), Orne, Normandy (previously Lower Normandy)

Re: Enhancement: Images in HTML / ALT-Text

Post by Michael Uplawski »

As I return to the forum only today, I had not noticed that you have translated your previous response into English. My following remarks make sense only if you know this, but I prefer keeping the content intact. It goes as follows for now merely historical reasons:
------------------------------------- original post ------------------------------------------------
miguel-c wrote: Tue Jun 25, 2019 4:45 pm Hallo Michael,
Ich habe gerade Ihre Nachricht an den Produktmanager und die Entwickler weitergeleitet.
Vielen Dank für Ihr Feedback!
TY but many people here and elsewhere appreciate it if the languages in a forum do not change too often. I can ensure everybody that they have missed nothing due to missing German language skills, but remember to have been harshly criticized for using other languages than English in an officially English-speaking forum.

Folks, we have sorted that out. Do not shoot us now. TY. ;)
-------------------------------- end original post ----------------------------------

And darn! I have not even said that I appreciate that my suggestions be considered. I still do. :D
Hindsight is in the eye of the beholder.
User avatar
Michael Uplawski
Posts: 177
Joined: Thu Dec 11, 2014 11:43 pm
Location: Canton Magny (previously Canton Carrouges), Orne, Normandy (previously Lower Normandy)

Re: Enhancement: Images in HTML / ALT-Text

Post by Michael Uplawski »

Just for completion.

I notice that my above script fragment cannot be used “as is” and may lead to false results when bereft of context. As it would need too much words to talk about that, to avoid too much off-topic gibberish and for a real “proof of concept”, here is the entire script:

Code: Select all

#!/bin/bash

echo "<html><head></head><body>" > /tmp/meteo.html
curl https://www.meteociel.fr/previsions/48191/nurnberg.htm | nokogiri -e 'puts $_.at_css("table[@cellpadding='2']")' >> /tmp/meteo.html

echo "<br/>" >> /tmp/meteo.html

# curl https://www.meteociel.fr/previsions-arome/48191/nurnberg.htm | nokogiri -e 'puts $_.at_css("table[@cellpadding='2']")' >> /tmp/meteo.html

echo "<br/>" >> /tmp/meteo.html

curl https://www.meteociel.fr/tendances/48191/nurnberg.htm | nokogiri -e 'puts $_.at_css("table[@cellpadding='2']")' >> /tmp/meteo.html

CP=`pwd`
# fetch icons
cd /tmp
for s in `xmllint --html --xpath '//@src' /tmp/meteo.html`
do
  PTH=`echo $s | cut -f2 -d\"`
  PTH=https:/$PTH
  FLE=`echo $PTH | cut -f8 -d\/`
  if [ ! -e $FLE ]
  then
    echo "fetching picture $FLE"
    curl "$PTH" --output /tmp/$FLE
  fi
done

# point to local icons, meaning: remove the path before the file-name.
sed -i "s/src\=\"\/\/PATH\/COMPONENT\/OF\/img-URL\//src=\"/g" /tmp/meteo.html
cd "$CP"
echo "</body></html>" >> /tmp/meteo.html
textmaker18 /tmp/meteo.html
Ω

Edits: wrong location
Hindsight is in the eye of the beholder.
Post Reply

Return to “SoftMaker Office 2018 for Linux (General)”