f-log

just another web log

17 Aug 2023:
edge case created to test edge case

So there is an edge case where that does not work :(

luckily it shouldn't come up too often.

17 Aug 2023:
who highlighted what when highlighting encoded entities

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.

17 Aug 2023:
testing highlight entity encoding

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.

17 Aug 2023:
testing stand clear of all html entities

This is a test, please stay calm, or at least quiet and don't fidget...

&amp;&amp;&amp;&amp;
&gt;&gt;&gt;&gt;
&lt;&lt;&lt;&lt;

&<>

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.

17 Aug 2023:
testing please stand clear of ALL html entities

This is a test, please stay calm, or at least quiet...

&amp;&amp;&amp;&amp;
&gt;&gt;&gt;&gt;
&lt;&lt;&lt;&lt;

&<>

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.

17 Aug 2023:
testing please stand clear of the html entities

This is a test, please stay calm...

&amp;&amp;&amp;&amp;
&gt;&gt;&gt;&gt;
&lt;&lt;&lt;&lt;

&<>

If you or any of your appendages have suffered serious burns during this test, then please seek medial assistance immediately.

17 Aug 2023:
right said sed duplicate and delete

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

  1. Find a line that matches "line 1" and then P rint it
  2. Find a line that matches "line 3 and D elete it
  3. Find the text "line 1" and S ubstitute it with the text "line One"

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.

loading results, please wait loading animateloading animateloading animate
[More tags]
rss feed

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!