Posted: Sun 04 Mar 2018, 00:23
Hi guys.
Here is a script that does what greengeek was doing manually above. Basically, an
RTF file has plain text in it, not html or xml code, so it can be parsed easily with a
Bash script.
I think the script is well commented, but if you have questions please ask them.
Also, please test on various RTF you may have, to provide more validations. TIA.
An illustration of the result is attached,using Smithy's test document. Also, the
replaceit utility, in 32-bit or 64-bit version, if you do not have it.
IHTH.
~~~~~~~~~~~~~~~~~
Here is a script that does what greengeek was doing manually above. Basically, an
RTF file has plain text in it, not html or xml code, so it can be parsed easily with a
Bash script.
I think the script is well commented, but if you have questions please ask them.
Also, please test on various RTF you may have, to provide more validations. TIA.
An illustration of the result is attached,using Smithy's test document. Also, the
replaceit utility, in 32-bit or 64-bit version, if you do not have it.
IHTH.
~~~~~~~~~~~~~~~~~
Code: Select all
#!/bin/ash
# abi-highlight-correction.sh # (Store in /opt/local/bin, or
# /root/my-applications/bin, or any "/bin" directory.)
#
# Required:
# replaceit, by P.L. Daniels, at http://www.pldaniels.com/replaceit.
#
# Purpose:
# correct the highlighting bug in abiword.
#
# Usage:
# abi-highlight-correction.sh name-of-document
#
# Note:
# The user should be in the document's directory before running this script.
#
# Credits:
# PuppyLinux forum members Smithy (for the 95 Kb test document) and greengeek
# (for insight into the problem).
#
# Discussion thread:
# http://murga-linux.com/puppy/viewtopic.php?t=112434&start=15
#
# (c) musher0, 2018-03-04.
####
LC_ALL=C # For greater speed. We may need it on large documents.
A="$1"
cp -f "$A" "$A".original # We make a back-up beforehand. Remove if process successful.
n="`grep -c highlight0 "$A"`" # Gives us the number of occurrences
############################### of the expression in the document.
for i in `seq $n`;do
replaceit --input="$A" "highlight0" "highlight25"
# replaceit tends to replace one instance at a time. So, to make
# sure the expresion is entirely replaced, we do as many iterations
# as there are occurrences of the expression.
done
###############################
# Time of process up to this point: ~ 0.83 second. (YMMV)
# Test doc was abiword_bug_test.rtf provided by PuppyLinux
# forum member Smithy.
###############################
LC_ALL="" # Restores the original state of LC_ALL.
# Optional:
# exec abiword "$A"
### 30 ###