Hii all,
Lately I was asking myself: Is there a way of activating word-wrap in falkon browser?
The background of my question is:
On occasions there are sites where some code is published. Sometimes this code is very long but āprintedā in just one line.
So I have to scroll horizontally for quite a while to see it all. ItĀ“s quite confusing that way.
In (some) text editors thereĀ“s a way of tweaking the settings in a way that word-wrap is activated. Is something like that possible in the falkon
browser too?
I had a lengthy discussion with ChatGPT about it and we went through different scenarios.
It turned out doing this for falkon
poses some difficulties but it could be done more easily with google-chrome
.
I know thereĀ“s discussion here for firefox
using the
about.config
settings.
But I needed a solution which helped me to do it more āprogrammaticallyā.
After putting quite some time and effort into the discussion we finally succeeded.
Just another note about the background of my query:
Every now and then I order I download link from ChatGPT, which provides a summary of all the conversations IĀ“ve ever had with the chatbot.
A zip-file is then provided and the file chat.html
is the crucial part. So all conversations are neatly displayed in an html file.
Recently I entered a code to be reviewed by ChatGPT and this code contained a very long line:
pattern_encoded_strings='0400100803000000030000000300000004007806030000000300000030000c00030000000400d800030000000300000003000000030000000300000043000000320000000300000003000000130100009200000012000000420000009300000062000000b3000000b200000003000000030000009300000042000000c3000000b20000000300000012000000040008070400080112000000630000000300000013000000f200000003000000a30000009200000033010000f200000043010000220000002201000004007008220000002300000072010000b30100009200000083000000230000008201000063010000130000000400a001220000002300000072010000b3010000b20100000300000003000000030000002301000043000000c20000009001300072000000210104000301000092000000220100003200000033010000d200000012000000'
In fact it was much longer; I abbreviated it here. But you get the point.
The html file would print it in one line and I had to scroll āendlesslyā to view it all (see above).
Now to the solution:
HereĀ“s a script we wrote (mainly ChatGPT), which automates the process of adding the
overflow-wrap: break-word;
style rule to the HTML file:
#!/bin/bash
# Define the CSS style to be added
CSS_STYLE="overflow-wrap: break-word;"
# Path to the HTML file (assuming it's always named "chat.html" and located in the same directory as the script)
HTML_FILE="chat.html"
# Check if the HTML file exists
if [ -f "$HTML_FILE" ]; then
# Add the CSS style to the HTML file
sed -i "s#<style>#&\n body {\n $CSS_STYLE\n }#" "$HTML_FILE"
echo "CSS style added to $HTML_FILE"
else
echo "Error: HTML file not found"
fi
Hereās how the script works:
- It defines the CSS style rule (
overflow-wrap: break-word;
) to be added to the HTML file. - It specifies the path to the HTML file (
chat.html
). - It checks if the HTML file exists.
- If the HTML file exists, it uses
sed
(a stream editor) to insert the CSS style rule into the existing<style>
section of the HTML file. - If the HTML file doesnāt exist, it displays an error message.
To use the script:
- Open a text editor and paste the script into a new file.
- Save the file with a
.sh
extension (e.g.,add_word_wrap.sh
). - Open a terminal and navigate to the directory where the script is saved.
- Run the script using the command
bash add_word_wrap.sh
.
This script will automatically add the overflow-wrap: break-word;
style rule to the <style>
section of the chat.html
file whenever you run it.
You can run the script each time you update the HTML file to ensure that the word-wrap style is always applied.
And it works splendidly.
I tried in with google-chrome
and with falkon
as well.
HereĀ“s how the relevant part looks in falkon
:
I donĀ“t know whether all of this is of any interest to anyone.
For me, however, it solved a āproblemā.
Therefore I wanted to publish the solution here.
Many greetings from Rosika