So there is an edge case where that does not work :(
luckily it shouldn't come up too often.
What was all that silliness about?
The less than sign, greater than sign and ampersand symbol were showing correctly on the page as long as they were not in a
block.
When they were in
blocks the
highlight.js
was double encoding the entities.
There seems no way around this so I just added a quick regex
let result = hljs.highlightAuto(target).value;
pattern = new RegExp('&', 'sg');
result = result.replace(pattern, '&');
That fixed it.
This is a test, please stay calm, or at least quiet and don't fidget or highlight anything...
&&&&
>>>>
<<<<
&<>
If you or any one within this dimension have suffered unexplained desire for sugar during this test, then please seek chocolate immediately.
This is a test, please stay calm, or at least quiet and don't fidget...
&&&&
>>>>
<<<<
&<>
If you or any one on the planet Earth have suffered an unexpected increase in barometric pressure during this test, then please seek atmospheric assistance immediately.
This is a test, please stay calm, or at least quiet...
&&&&
>>>>
<<<<
&<>
If you or any one with a 50 mile radius have suffered a lack of gravity during this test, then please seek physical assistance immediately.
This is a test, please stay calm...
&&&&
>>>>
<<<<
&<>
If you or any of your appendages have suffered serious burns during this test, then please seek medial assistance immediately.
Been doing some scripting at work with
sed
(command line Stream EDitor.
Learned a few tricks that I want to immortalise on this flog.
Let's create a test file with three distinct lines.
echo "line 1 content A" >> /tmp/file
echo "line 2 content B" >> /tmp/file
echo "line 3 content C" >> /tmp/file
cat /tmp/file
line 1 content A
line 2 content B
line 3 content C
and then run
cat /tmp/file | sed -re '/line 1/p;/line 3/d;s/line 1/line ONE/'
to get the output of
line 1 content A
line ONE content A
line 2 content B
That sed command breaks down into
This is incredibly powerful and I have been using it to migrate one programming framework to another.
Make backups of lines that need changing and marking them as comments. Deleting unused lines completely. Reformatting syntax.
email
root
flog archives
Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk
I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk
In fact I'm not responsible for anything ever, so there!