<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="atom.xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://arteiii.github.io/blog/</id>
    <title>Arteii Blog</title>
    <updated>2024-10-07T12:38:00.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://arteiii.github.io/blog/"/>
    <subtitle>Arteii Blog</subtitle>
    <icon>https://arteiii.github.io/img/favicon.ico</icon>
    <rights>2026 Arteii</rights>
    <entry>
        <title type="html"><![CDATA[The Boyer-Moore Algorithm]]></title>
        <id>https://arteiii.github.io/blog/boyer-moore/</id>
        <link href="https://arteiii.github.io/blog/boyer-moore/"/>
        <updated>2024-10-07T12:38:00.000Z</updated>
        <summary type="html"><![CDATA[Pattern matching is a fundamental problem in computer science with applications in text processing, search engines, DNA]]></summary>
        <content type="html"><![CDATA[<p>Pattern matching is a fundamental problem in computer science with applications in text processing, search engines, DNA
sequencing, and more.
The <a href="https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm" target="_blank" rel="noopener noreferrer" class=""><strong>Boyer-Moore algorithm</strong></a>, introduced by <a href="https://en.wikipedia.org/wiki/Robert_S._Boyer" target="_blank" rel="noopener noreferrer" class="">Robert S. Boyer</a>
and <a href="https://en.wikipedia.org/wiki/J_Strother_Moore" target="_blank" rel="noopener noreferrer" class="">J Strother Moore</a> in 1977,
remains one of the most efficient algorithms for string matching in real-world applications.
It takes advantage of information gleaned during the mismatching process to skip portions of the text,
often achieving sublinear time complexity on average.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="problem-statement">Problem Statement<a href="https://arteiii.github.io/blog/boyer-moore/#problem-statement" class="hash-link" aria-label="Direct link to Problem Statement" title="Direct link to Problem Statement" translate="no">​</a></h2>
<p>Given a text string <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi></mrow><annotation encoding="application/x-tex">T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span></span></span></span> of length <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em"></span><span class="mord mathnormal">n</span></span></span></span> and a pattern string <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span> of length <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi></mrow><annotation encoding="application/x-tex">m</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em"></span><span class="mord mathnormal">m</span></span></span></span>, the goal of pattern matching is to
find all occurrences of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span> as a substring of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi></mrow><annotation encoding="application/x-tex">T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span></span></span></span>. The brute-force approach requires checking each possible
alignment of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi></mrow><annotation encoding="application/x-tex">T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span></span></span></span>, which results in a time complexity of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>O</mi><mo stretchy="false">(</mo><mi>n</mi><mo>⋅</mo><mi>m</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">O(n \cdot m)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.0278em">O</span><span class="mopen">(</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2222em"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal">m</span><span class="mclose">)</span></span></span></span>. The Boyer-Moore algorithm
improves upon this by skipping unnecessary comparisons.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="the-boyer-moore-algorithm">The Boyer-Moore Algorithm<a href="https://arteiii.github.io/blog/boyer-moore/#the-boyer-moore-algorithm" class="hash-link" aria-label="Direct link to The Boyer-Moore Algorithm" title="Direct link to The Boyer-Moore Algorithm" translate="no">​</a></h2>
<p>The Boyer-Moore algorithm matches the pattern <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span> from right to left, starting at the end of the pattern. If a
mismatch occurs, the algorithm shifts the pattern over the text based on two preprocessed heuristics: the <strong>Bad
Character rule</strong> and the <strong>Good Suffix rule</strong>.</p>
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="bad-character-rule">Bad Character Rule<a href="https://arteiii.github.io/blog/boyer-moore/#bad-character-rule" class="hash-link" aria-label="Direct link to Bad Character Rule" title="Direct link to Bad Character Rule" translate="no">​</a></h3>
<p>The <strong>Bad Character</strong> rule works by identifying mismatches and using the information to shift the pattern efficiently.
Given a mismatch between the text character <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[i]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]</span></span></span></span> and the corresponding pattern character <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo stretchy="false">[</mo><mi>j</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">P[j]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.0572em">j</span><span class="mclose">]</span></span></span></span>, we look for the
rightmost occurrence of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[i]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]</span></span></span></span> in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span>.</p>
<ul>
<li class="">If <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[i]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]</span></span></span></span> exists in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span>, we shift the pattern such that this occurrence aligns with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[i]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]</span></span></span></span>.</li>
<li class="">If <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[i]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]</span></span></span></span> does not exist in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span>, we shift the entire pattern past the mismatched character.</li>
</ul>
<p>Mathematically, let:</p>
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mtext>shift</mtext><mtext>bad_char</mtext></msub><mo stretchy="false">(</mo><mi>i</mi><mo separator="true">,</mo><mi>j</mi><mo stretchy="false">)</mo><mo>=</mo><mi>max</mi><mo>⁡</mo><mo stretchy="false">(</mo><mn>1</mn><mo separator="true">,</mo><mi>j</mi><mo>−</mo><mtext>rightmost</mtext><mo stretchy="false">(</mo><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo><mo stretchy="false">)</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\text{shift}_{\text{bad\_char}}(i, j) = \max(1, j - \text{rightmost}(T[i]))</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.117em;vertical-align:-0.367em"></span><span class="mord"><span class="mord text"><span class="mord">shift</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em"><span style="top:-2.55em;margin-right:0.05em"><span class="pstrut" style="height:2.7em"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">bad_char</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.367em"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">i</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em"></span><span class="mord mathnormal" style="margin-right:0.0572em">j</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mop">max</span><span class="mopen">(</span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em"></span><span class="mord mathnormal" style="margin-right:0.0572em">j</span><span class="mspace" style="margin-right:0.2222em"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord text"><span class="mord">rightmost</span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]))</span></span></span></span></span>
<p>where <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>rightmost</mtext><mo stretchy="false">(</mo><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\text{rightmost}(T[i])</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord text"><span class="mord">rightmost</span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">])</span></span></span></span> is the rightmost occurrence of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[i]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord mathnormal">i</span><span class="mclose">]</span></span></span></span> in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span>, or -1 if it does not appear.</p>
<p><strong>Example:</strong></p>
<p>Consider the pattern <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mtext>ABCA</mtext></mrow><annotation encoding="application/x-tex">P = \text{ABCA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">ABCA</span></span></span></span></span> and text <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo>=</mo><mtext>CBABCA</mtext></mrow><annotation encoding="application/x-tex">T = \text{CBABCA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">CBABCA</span></span></span></span></span>. Suppose a mismatch occurs at
position <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mo>=</mo><mn>2</mn></mrow><annotation encoding="application/x-tex">i = 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6595em"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6444em"></span><span class="mord">2</span></span></span></span>, where <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mn>2</mn><mo stretchy="false">]</mo><mo>=</mo><mtext>B</mtext></mrow><annotation encoding="application/x-tex">T[2] = \text{B}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord">2</span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">B</span></span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo stretchy="false">[</mo><mn>1</mn><mo stretchy="false">]</mo><mo>=</mo><mtext>A</mtext></mrow><annotation encoding="application/x-tex">P[1] = \text{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span><span class="mopen">[</span><span class="mord">1</span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">A</span></span></span></span></span>. Since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>B</mtext></mrow><annotation encoding="application/x-tex">\text{B}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">B</span></span></span></span></span> exists in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span> at position 1,
we shift the pattern such that this occurrence aligns with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo stretchy="false">[</mo><mn>2</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">T[2]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mopen">[</span><span class="mord">2</span><span class="mclose">]</span></span></span></span>.</p>
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="good-suffix-rule">Good Suffix Rule<a href="https://arteiii.github.io/blog/boyer-moore/#good-suffix-rule" class="hash-link" aria-label="Direct link to Good Suffix Rule" title="Direct link to Good Suffix Rule" translate="no">​</a></h3>
<p>The <strong>Good Suffix</strong> rule leverages suffixes in the pattern to skip unnecessary shifts. When a mismatch occurs after a
suffix of the pattern has been matched, the algorithm shifts the pattern such that the next occurrence of this suffix
aligns with the text.</p>
<p>Mathematically, let:</p>
<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mtext>shift</mtext><mtext>good_suffix</mtext></msub><mo stretchy="false">(</mo><mi>j</mi><mo stretchy="false">)</mo><mo>=</mo><mi>m</mi><mo>−</mo><mtext>next_suffix</mtext><mo stretchy="false">(</mo><mi>j</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\text{shift}_{\text{good\_suffix}}(j) = m - \text{next\_suffix}(j)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.117em;vertical-align:-0.367em"></span><span class="mord"><span class="mord text"><span class="mord">shift</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em"><span style="top:-2.55em;margin-right:0.05em"><span class="pstrut" style="height:2.7em"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">good_suffix</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.367em"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0572em">j</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em"></span><span class="mord mathnormal">m</span><span class="mspace" style="margin-right:0.2222em"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em"></span></span><span class="base"><span class="strut" style="height:1.06em;vertical-align:-0.31em"></span><span class="mord text"><span class="mord">next_suffix</span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0572em">j</span><span class="mclose">)</span></span></span></span></span>
<p>where <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>next_suffix</mtext><mo stretchy="false">(</mo><mi>j</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\text{next\_suffix}(j)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.06em;vertical-align:-0.31em"></span><span class="mord text"><span class="mord">next_suffix</span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0572em">j</span><span class="mclose">)</span></span></span></span> is the position of the next occurrence of the matched suffix in the pattern.</p>
<p>There are two cases for shifting based on good suffixes:</p>
<ul>
<li class=""><strong>Case 1</strong>: The matched suffix appears elsewhere in the pattern. In this case, we shift the pattern to align the next
occurrence of the suffix.</li>
<li class=""><strong>Case 2</strong>: The matched suffix does not appear in the pattern, but some prefix of the pattern matches a suffix of the
text. In this case, we shift the pattern such that the prefix aligns with the suffix.</li>
</ul>
<p><strong>Example:</strong></p>
<p>For <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mtext>ABCA</mtext></mrow><annotation encoding="application/x-tex">P = \text{ABCA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">ABCA</span></span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>T</mi><mo>=</mo><mtext>CBABCA</mtext></mrow><annotation encoding="application/x-tex">T = \text{CBABCA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">T</span><span class="mspace" style="margin-right:0.2778em"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em"></span></span><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord text"><span class="mord">CBABCA</span></span></span></span></span>, if a mismatch occurs after matching the suffix "BCA", the pattern is
shifted to the next occurrence of "BCA" in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em"></span><span class="mord mathnormal" style="margin-right:0.1389em">P</span></span></span></span>.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="proof-of-efficiency">Proof of Efficiency<a href="https://arteiii.github.io/blog/boyer-moore/#proof-of-efficiency" class="hash-link" aria-label="Direct link to Proof of Efficiency" title="Direct link to Proof of Efficiency" translate="no">​</a></h2>
<p>The Boyer-Moore algorithm operates in sublinear time on average due to the efficiency of its heuristics. Let <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi></mrow><annotation encoding="application/x-tex">m</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em"></span><span class="mord mathnormal">m</span></span></span></span> be
the length of the pattern and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em"></span><span class="mord mathnormal">n</span></span></span></span> the length of the text. The algorithm's worst-case time complexity
is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>O</mi><mo stretchy="false">(</mo><mi>n</mi><mo>⋅</mo><mi>m</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">O(n \cdot m)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.0278em">O</span><span class="mopen">(</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2222em"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal">m</span><span class="mclose">)</span></span></span></span>, but in practice, the average time complexity is much closer to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>O</mi><mo stretchy="false">(</mo><mi>n</mi><mi mathvariant="normal">/</mi><mi>m</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">O(n / m)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em"></span><span class="mord mathnormal" style="margin-right:0.0278em">O</span><span class="mopen">(</span><span class="mord mathnormal">n</span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mclose">)</span></span></span></span>, particularly when the
alphabet size is large.</p>
<p>This sublinear performance arises because the pattern shifts more than one character in many cases, especially when
there are frequent mismatches or when the pattern is long relative to the text.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="performance-comparison-between-bad-character-and-good-suffix-heuristics">Performance Comparison Between Bad Character and Good Suffix Heuristics<a href="https://arteiii.github.io/blog/boyer-moore/#performance-comparison-between-bad-character-and-good-suffix-heuristics" class="hash-link" aria-label="Direct link to Performance Comparison Between Bad Character and Good Suffix Heuristics" title="Direct link to Performance Comparison Between Bad Character and Good Suffix Heuristics" translate="no">​</a></h2>
<p>The <a href="https://arteiii.github.io/blog/boyer-moore/#bad-character-rule" class=""><strong>Bad Character</strong></a> rule tends
to perform well when the alphabet is large and when mismatches are common because it
leverages the presence of mismatched characters to skip unnecessary comparisons.
The <a href="https://arteiii.github.io/blog/boyer-moore/#good-suffix-rule" class=""><strong>Good Suffix</strong></a> rule is more
effective when the pattern has repeated structures or when mismatches occur near the end of the pattern, allowing it to
skip larger sections of the text.</p>
<p>In practical applications, the combination of these two heuristics provides superior performance over either heuristic
used in isolation.</p>
<ol>
<li class=""><strong>Bad Character</strong>: More efficient with larger alphabets and random text.</li>
<li class=""><strong>Good Suffix</strong>: More efficient with repetitive patterns and long suffix matches.</li>
</ol>
<p>In most cases, the Boyer-Moore algorithm uses both heuristics together, allowing the pattern to shift as far as the
larger of the two heuristics suggests.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="conclusion">Conclusion<a href="https://arteiii.github.io/blog/boyer-moore/#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion" translate="no">​</a></h2>
<p>The Boyer-Moore algorithm is one of the most efficient string-matching algorithms for practical use due to its ability
to skip portions of the text rather than performing a brute-force search.
By employing both the <a href="https://arteiii.github.io/blog/boyer-moore/#bad-character-rule" class=""><strong>Bad Character</strong></a> and <a href="https://arteiii.github.io/blog/boyer-moore/#good-suffix-rule" class=""><strong>Good Suffix</strong></a> heuristics,
the algorithm achieves sublinear time complexity on average.
Its efficiency is particularly notable in scenarios where patterns are long or mismatches occur frequently.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="references">References<a href="https://arteiii.github.io/blog/boyer-moore/#references" class="hash-link" aria-label="Direct link to References" title="Direct link to References" translate="no">​</a></h2>
<ul>
<li class="">Robert S. Boyer - <a href="https://en.wikipedia.org/wiki/Robert_S._Boyer" target="_blank" rel="noopener noreferrer" class="">Wikipedia</a></li>
<li class="">J Strother Moore - <a href="https://en.wikipedia.org/wiki/J_Strother_Moore" target="_blank" rel="noopener noreferrer" class="">Wikipedia</a></li>
<li class="">Boyer–Moore string-search algorithm - <a href="https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm" target="_blank" rel="noopener noreferrer" class="">Wikipedia</a></li>
<li class="">Boyer-Moore Algorithm - <a href="https://www.geeksforgeeks.org/boyer-moore-algorithm-for-pattern-searching/" target="_blank" rel="noopener noreferrer" class="">GeeksforGeeks</a></li>
<li class="">A. V. Aho, and M. J. Corasick, "Efficient String Matching: An Aid to Bibliographic Search," <em>Communications of the
ACM</em>, 1975.</li>
<li class="">T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, <em>Introduction to Algorithms</em>, MIT Press, 2009.</li>
</ul>]]></content>
        <author>
            <name>Arteii / Ben</name>
            <uri>https://github.com/arteiii</uri>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[Django101 Hello World!]]></title>
        <id>https://arteiii.github.io/blog/django101/</id>
        <link href="https://arteiii.github.io/blog/django101/"/>
        <updated>2023-07-09T22:00:00.000Z</updated>
        <summary type="html"><![CDATA[The world of web development is full of tools and frameworks, but when it comes to developing powerful and scalable web applications,]]></summary>
        <content type="html"><![CDATA[<p>The world of web development is full of tools and frameworks, but when it comes to developing powerful and scalable web applications,
Django is without a doubt one of the best options.
Django provides developers with an elegant and efficient way to build web applications using Python.
Django follows the "battery included" principle,
which means it comes with a lot of built-in features and tools to make your development easier.
With Django, you can manage databases, forms, implement user authentication, and much more.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="setup">Setup<a href="https://arteiii.github.io/blog/django101/#setup" class="hash-link" aria-label="Direct link to Setup" title="Direct link to Setup" translate="no">​</a></h2>
<hr>
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="install-python3">Install Python3<a href="https://arteiii.github.io/blog/django101/#install-python3" class="hash-link" aria-label="Direct link to Install Python3" title="Direct link to Install Python3" translate="no">​</a></h3>
<p>Before we can get started with Django, we need to install Python.
(you can skip this part if you have already done so)</p>
<p><a href="https://www.python.org/downloads/" target="_blank" rel="noopener noreferrer" class="">Download Site</a></p>
<img src="https://arteiii.github.io/assets/images/python_download_site-4c243a78d9659e4240773c614d204636.png" width="450" alt="python download site image">
<p>After the download is complete, run the installer. Make sure you check "add python.exe to PATH".</p>
<img src="https://arteiii.github.io/assets/images/python_installer_add_to_path-907e0bd1ca8e50fcccbcfcf5b4516fd1.png" width="450" alt="python download site iamge">
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="install-django-in-pipenv">Install Django In pipenv<a href="https://arteiii.github.io/blog/django101/#install-django-in-pipenv" class="hash-link" aria-label="Direct link to Install Django In pipenv" title="Direct link to Install Django In pipenv" translate="no">​</a></h3>
<p>First we are going to install pipenv using pip, we do this with the following command</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">pip3 install pipenv</span><br></div></code></pre></div></div>
<p>Then we install Django in a virtual environment.
to avoid possible compatibility issues with other projects.</p>
<p>So each project has its own Python and Django installation.</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">pipenv install django</span><br></div></code></pre></div></div>
<p>activate the environment with:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">pipenv shell</span><br></div></code></pre></div></div>
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="start-django">Start Django<a href="https://arteiii.github.io/blog/django101/#start-django" class="hash-link" aria-label="Direct link to Start Django" title="Direct link to Start Django" translate="no">​</a></h3>
<p>Now we start a new Django project named "blog_arteii_example".</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">django-admin startproject blog_arteii_example</span><br></div></code></pre></div></div>
<p>This will create a new folder if you create the project directly in the folder you are currently in:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">django-admin startproject blog_arteii_example .</span><br></div></code></pre></div></div>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">python manage.py runserver</span><br></div></code></pre></div></div>
<p>starts a local server</p>
<p>*for now you can ignore the migration errors</p>
<p>your website is now local available on:
<a href="http://127.0.0.1:8000/" target="_blank" rel="noopener noreferrer" class="">http://127.0.0.1:8000/</a></p>
<p>you should see:</p>
<img src="https://arteiii.github.io/assets/images/django_initial_setup-39d06635518247223608fd13789851c8.png" width="550" alt="python download site iamge">
<p>stop the server
using ctrl + c</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">python manage.py migrate</span><br></div></code></pre></div></div>
<p>removes the error message that we used to get</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="hello-world">Hello World!<a href="https://arteiii.github.io/blog/django101/#hello-world" class="hash-link" aria-label="Direct link to Hello World!" title="Direct link to Hello World!" translate="no">​</a></h2>
<hr>
<p>lets start creating our first app
if you still got a server running pls stop it</p>
<p>and run:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">python manage.py startapp &lt;app_name&gt;</span><br></div></code></pre></div></div>
<p>in my case the app_name is: pages</p>
<p>add it to the project settings</p>
<p>You should add your own applications below the Django applications.
Because Django loads the applications in order.
So if you import yours on top, you won't be able to use the Django modules.</p>
<div class="language-py codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">.../blog_arteii_example/blog_arteii_example/settings.py</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-py codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token comment" style="color:rgb(106, 153, 85)"># Application definition</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">INSTALLED_APPS </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'django.contrib.admin'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'django.contrib.auth'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'django.contrib.contenttypes'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'django.contrib.sessions'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'django.contrib.messages'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'django.contrib.staticfiles'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token string" style="color:rgb(206, 145, 120)">'pages.apps.PagesConfig'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><br></div></code></pre></div></div>
<p>let's modify the views.py file
so when the user requests the homepage i.e. the domain without any directory structure
the function HelloWorld is returned</p>
<div class="language-py codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">.../blog_arteii_example/pages/views.py</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-py codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token comment" style="color:rgb(106, 153, 85)"># Create your views here.</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> django</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">http </span><span class="token keyword" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> HttpResponse</span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(220, 220, 170)">HelloWorld</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token plain">request</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">:</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain">    </span><span class="token keyword" style="color:rgb(86, 156, 214)">return</span><span class="token plain"> HttpResponse</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'Hello World!'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><br></div></code></pre></div></div>
<p>now create a new file with the name <code>urls.py</code> in pages (<code>.../blog_arteii_example/pages/urls.py</code>)
and modify, so it looks like this:</p>
<div class="language-py codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">.../blog_arteii_example/pages/urls.py</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-py codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token keyword" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> django</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">urls </span><span class="token keyword" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> path</span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">views </span><span class="token keyword" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> HelloWorld</span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain">urlpatterns </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">[</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain">    path</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">''</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> HelloWorld</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> name</span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token string" style="color:rgb(206, 145, 120)">'home'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">]</span><br></div></code></pre></div></div>
<p>Most Django projects use many different applications,
and each of these applications needs its own URL path.
So we add our app pages to the url patterns so that when a user visits the home page,
they are first redirected to the pages app and then to our HelloWorld function.</p>
<div class="language-py codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">.../blog_arteii_example/blog_arteii_example/urls.py</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-py codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token keyword" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> django</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">contrib </span><span class="token keyword" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> admin</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> django</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">urls </span><span class="token keyword" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> path</span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> django</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">urls </span><span class="token keyword" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> include</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">urlpatterns </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">[</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    path</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'admin/'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> admin</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">site</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token plain">urls</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain">    path</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">''</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"> include</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">'pages.urls'</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">,</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">]</span><br></div></code></pre></div></div>
<p>and last:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">python manage.py runserver</span><br></div></code></pre></div></div>]]></content>
        <author>
            <name>Arteii / Ben</name>
            <uri>https://github.com/arteiii</uri>
        </author>
    </entry>
    <entry>
        <title type="html"><![CDATA[MarkDown Intro]]></title>
        <id>https://arteiii.github.io/blog/MarkDown/</id>
        <link href="https://arteiii.github.io/blog/MarkDown/"/>
        <updated>2023-07-02T18:00:00.000Z</updated>
        <summary type="html"><![CDATA[just a short intro to markdown and mdx]]></summary>
        <content type="html"><![CDATA[<p>just a short intro to markdown and mdx
for docusaurus or different tools / websites</p>
<hr>
<p>You can write content using <a href="https://github.github.com/gfm/" target="_blank" rel="noopener noreferrer" class="">GitHub-flavored Markdown syntax</a>.</p>
<p>To serve as an example page when styling markdown based Docusaurus sites.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="headers">Headers<a href="https://arteiii.github.io/blog/MarkDown/#headers" class="hash-link" aria-label="Direct link to Headers" title="Direct link to Headers" translate="no">​</a></h2>
<hr>
<h1>H1 - Create the best documentation</h1>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="h2---create-the-best-documentation">H2 - Create the best documentation<a href="https://arteiii.github.io/blog/MarkDown/#h2---create-the-best-documentation" class="hash-link" aria-label="Direct link to H2 - Create the best documentation" title="Direct link to H2 - Create the best documentation" translate="no">​</a></h2>
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="h3---create-the-best-documentation">H3 - Create the best documentation<a href="https://arteiii.github.io/blog/MarkDown/#h3---create-the-best-documentation" class="hash-link" aria-label="Direct link to H3 - Create the best documentation" title="Direct link to H3 - Create the best documentation" translate="no">​</a></h3>
<h4 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="h4---create-the-best-documentation">H4 - Create the best documentation<a href="https://arteiii.github.io/blog/MarkDown/#h4---create-the-best-documentation" class="hash-link" aria-label="Direct link to H4 - Create the best documentation" title="Direct link to H4 - Create the best documentation" translate="no">​</a></h4>
<h5 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="h5---create-the-best-documentation">H5 - Create the best documentation<a href="https://arteiii.github.io/blog/MarkDown/#h5---create-the-best-documentation" class="hash-link" aria-label="Direct link to H5 - Create the best documentation" title="Direct link to H5 - Create the best documentation" translate="no">​</a></h5>
<h6 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="h6---create-the-best-documentation">H6 - Create the best documentation<a href="https://arteiii.github.io/blog/MarkDown/#h6---create-the-best-documentation" class="hash-link" aria-label="Direct link to H6 - Create the best documentation" title="Direct link to H6 - Create the best documentation" translate="no">​</a></h6>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="emphasis">Emphasis<a href="https://arteiii.github.io/blog/MarkDown/#emphasis" class="hash-link" aria-label="Direct link to Emphasis" title="Direct link to Emphasis" translate="no">​</a></h2>
<hr>
<p>Emphasis, aka italics, with <em>asterisks</em> or <em>underscores</em>.</p>
<p>Strong emphasis, aka bold, with <strong>asterisks</strong> or <strong>underscores</strong>.</p>
<p>Combined emphasis with <strong>asterisks and <em>underscores</em></strong>.</p>
<p>Strikethrough uses two tildes. <del>Scratch this.</del></p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="lists">Lists<a href="https://arteiii.github.io/blog/MarkDown/#lists" class="hash-link" aria-label="Direct link to Lists" title="Direct link to Lists" translate="no">​</a></h2>
<hr>
<ol>
<li class="">First ordered list item</li>
<li class="">Another item</li>
</ol>
<ul>
<li class="">Unordered sub-list.</li>
</ul>
<ol start="3">
<li class="">Actual numbers don't matter, just that it's a number</li>
<li class="">Ordered sub-list</li>
<li class="">And another item.</li>
</ol>
<ul>
<li class="">Unordered list can use asterisks</li>
</ul>
<ul>
<li class="">Or minuses</li>
</ul>
<ul>
<li class="">Or pluses</li>
</ul>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="links">Links<a href="https://arteiii.github.io/blog/MarkDown/#links" class="hash-link" aria-label="Direct link to Links" title="Direct link to Links" translate="no">​</a></h2>
<hr>
<p><a href="https://www.google.com/" target="_blank" rel="noopener noreferrer" class="">I'm an inline-style link</a></p>
<p><a href="https://www.google.com/" target="_blank" rel="noopener noreferrer" title="Google's Homepage" class="">I'm an inline-style link with title</a></p>
<p>[I'm a reference-style link][arbitrary case-insensitive reference text]</p>
<p>[You can use numbers for reference-style link definitions][1]</p>
<p>Or leave it empty and use the [link text itself].</p>
<p>URLs and URLs in angle brackets will automatically get turned into links. <a href="http://www.example.com/" target="_blank" rel="noopener noreferrer" class="">http://www.example.com/</a> or <a href="http://www.example.com/" target="_blank" rel="noopener noreferrer" class="">http://www.example.com/</a> and sometimes example.com (but not on GitHub, for example).</p>
<p>Some text to show that the reference links can follow later.</p>
<p>[arbitrary case-insensitive reference text]  <a href="https://www.mozilla.org/" target="_blank" rel="noopener noreferrer" class="">https://www.mozilla.org/</a>
[1]  <a href="http://slashdot.org/" target="_blank" rel="noopener noreferrer" class="">http://slashdot.org/</a>
[link text itself]  <a href="http://www.reddit.com/" target="_blank" rel="noopener noreferrer" class="">http://www.reddit.com/</a></p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="images">Images<a href="https://arteiii.github.io/blog/MarkDown/#images" class="hash-link" aria-label="Direct link to Images" title="Direct link to Images" translate="no">​</a></h2>
<hr>
<p>you can import assets and use them like this: (only if you use mdx)</p>
<div class="language-jsx codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-jsx codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token keyword module" style="color:rgb(86, 156, 214)">import</span><span class="token plain"> </span><span class="token imports">myImageUrl</span><span class="token plain"> </span><span class="token keyword module" style="color:rgb(86, 156, 214)">from</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"../../static/img/Website-Social-Card.jpeg"</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(212, 212, 212)">&lt;</span><span class="token tag" style="color:rgb(78, 201, 176)">img</span><span class="token tag" style="color:rgb(78, 201, 176)"> </span><span class="token tag attr-name" style="color:rgb(156, 220, 254)">src</span><span class="token tag script language-javascript script-punctuation punctuation" style="color:rgb(212, 212, 212)">=</span><span class="token tag script language-javascript punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token tag script language-javascript" style="color:rgb(78, 201, 176)">myImageUrl</span><span class="token tag script language-javascript punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token tag" style="color:rgb(78, 201, 176)"> </span><span class="token tag attr-name" style="color:rgb(156, 220, 254)">width</span><span class="token tag script language-javascript script-punctuation punctuation" style="color:rgb(212, 212, 212)">=</span><span class="token tag script language-javascript punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token tag script language-javascript number" style="color:rgb(181, 206, 168)">250</span><span class="token tag script language-javascript punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token tag" style="color:rgb(78, 201, 176)"> </span><span class="token tag attr-name" style="color:rgb(156, 220, 254)">height</span><span class="token tag script language-javascript script-punctuation punctuation" style="color:rgb(212, 212, 212)">=</span><span class="token tag script language-javascript punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token tag script language-javascript number" style="color:rgb(181, 206, 168)">250</span><span class="token tag script language-javascript punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token tag" style="color:rgb(78, 201, 176)"> </span><span class="token tag attr-name" style="color:rgb(156, 220, 254)">alt</span><span class="token tag attr-value punctuation attr-equals" style="color:rgb(212, 212, 212)">=</span><span class="token tag attr-value punctuation" style="color:rgb(212, 212, 212)">"</span><span class="token tag attr-value" style="color:rgb(206, 145, 120)">Example banner</span><span class="token tag attr-value punctuation" style="color:rgb(212, 212, 212)">"</span><span class="token tag" style="color:rgb(78, 201, 176)"> </span><span class="token tag punctuation" style="color:rgb(212, 212, 212)">/&gt;</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><br></div></code></pre></div></div>
<!-- -->
<img src="https://arteiii.github.io/assets/images/Website-Social-Card-b197809f9d4fc9940657c8f2c93a476a.jpeg" width="250" height="250" alt="Example banner">
<hr>
<p>Inline-style:</p>
<p><img decoding="async" loading="lazy" src="https://arteiii.github.io/img/Website-Social-Card.jpeg" alt="alt text" title="Logo Title Text 1" class="img_ev3q"></p>
<hr>
<p>Reference-style: ![alt text][logo]</p>
<p>[logo]  <a href="https://arteiii.github.io/img/Website-Social-Card.jpeg" target="_blank" rel="noopener noreferrer" class="">https://arteiii.github.io/img/Website-Social-Card.jpeg</a> "Logo Title Text 2"</p>
<p>Images from any folder can be used by providing path to file. Path should be relative to markdown file.</p>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="code">Code<a href="https://arteiii.github.io/blog/MarkDown/#code" class="hash-link" aria-label="Direct link to Code" title="Direct link to Code" translate="no">​</a></h2>
<hr>
<div class="language-javascript codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-javascript codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token keyword" style="color:rgb(86, 156, 214)">var</span><span class="token plain"> s </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"JavaScript syntax highlighting"</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token function" style="color:rgb(220, 220, 170)">alert</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token plain">s</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><br></div></code></pre></div></div>
<div class="language-python codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-python codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">s </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"Python syntax highlighting"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">print</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token plain">s</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><br></div></code></pre></div></div>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">No language indicated, so no syntax highlighting.</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">But let's throw in a &lt;b&gt;tag&lt;/b&gt;.</span><br></div></code></pre></div></div>
<div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-js codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token keyword" style="color:rgb(86, 156, 214)">var</span><span class="token plain"> </span><span class="token function-variable function" style="color:rgb(220, 220, 170)">highlightMe</span><span class="token plain"> </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(86, 156, 214)">function</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">{</span><span class="token plain"></span><br></div><div class="token-line theme-code-block-highlighted-line" style="color:#9CDCFE"><span class="token plain">  </span><span class="token console class-name" style="color:rgb(78, 201, 176)">console</span><span class="token punctuation" style="color:rgb(212, 212, 212)">.</span><span class="token method function property-access" style="color:rgb(220, 220, 170)">log</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token string" style="color:rgb(206, 145, 120)">"This line can be highlighted!"</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token punctuation" style="color:rgb(212, 212, 212)">}</span><span class="token punctuation" style="color:rgb(212, 212, 212)">;</span><br></div></code></pre></div></div>
<p>you can also set titles</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">```python title="example title"</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">s = "Python syntax highligh...</span><br></div></code></pre></div></div>
<div class="language-python codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockTitle_OeMC">example title</div><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-python codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">s </span><span class="token operator" style="color:rgb(212, 212, 212)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(206, 145, 120)">"Python syntax highlighting"</span><span class="token plain"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain"></span><span class="token keyword" style="color:rgb(86, 156, 214)">print</span><span class="token punctuation" style="color:rgb(212, 212, 212)">(</span><span class="token plain">s</span><span class="token punctuation" style="color:rgb(212, 212, 212)">)</span><br></div></code></pre></div></div>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="tables">Tables<a href="https://arteiii.github.io/blog/MarkDown/#tables" class="hash-link" aria-label="Direct link to Tables" title="Direct link to Tables" translate="no">​</a></h2>
<hr>
<p>Colons can be used to align columns.</p>
<table><thead><tr><th>Tables</th><th style="text-align:center">Are</th><th style="text-align:right">Cool</th></tr></thead><tbody><tr><td>col 3 is</td><td style="text-align:center">right-aligned</td><td style="text-align:right">$1600</td></tr><tr><td>col 2 is</td><td style="text-align:center">centered</td><td style="text-align:right">$12</td></tr><tr><td>zebra stripes</td><td style="text-align:center">are neat</td><td style="text-align:right">$1</td></tr></tbody></table>
<p>There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.</p>
<table><thead><tr><th>Markdown</th><th>Less</th><th>Pretty</th></tr></thead><tbody><tr><td><em>Still</em></td><td><code>renders</code></td><td><strong>nicely</strong></td></tr><tr><td>1</td><td>2</td><td>3</td></tr></tbody></table>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="blockquotes">Blockquotes<a href="https://arteiii.github.io/blog/MarkDown/#blockquotes" class="hash-link" aria-label="Direct link to Blockquotes" title="Direct link to Blockquotes" translate="no">​</a></h2>
<hr>
<blockquote>
<p>Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.</p>
</blockquote>
<p>Quote break.</p>
<blockquote>
<p>This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p>
</blockquote>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="inline-html">Inline HTML<a href="https://arteiii.github.io/blog/MarkDown/#inline-html" class="hash-link" aria-label="Direct link to Inline HTML" title="Direct link to Inline HTML" translate="no">​</a></h2>
<hr>
<dl><dt>Definition list</dt><dd>Is something people use sometimes.</dd><dt>Markdown in HTML</dt><dd>Does <em>not</em> work <strong>very</strong> well. Use HTML <em>tags</em>.</dd></dl>
<br>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="line-breaks">Line Breaks<a href="https://arteiii.github.io/blog/MarkDown/#line-breaks" class="hash-link" aria-label="Direct link to Line Breaks" title="Direct link to Line Breaks" translate="no">​</a></h2>
<hr>
<p>Here's a line for us to start with.</p>
<p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p>
<p>This line is also a separate paragraph, but... This line is only separated by a single newline, so it's a separate line in the <em>same paragraph</em>.</p>
<br>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="admonitions">Admonitions<a href="https://arteiii.github.io/blog/MarkDown/#admonitions" class="hash-link" aria-label="Direct link to Admonitions" title="Direct link to Admonitions" translate="no">​</a></h2>
<hr>
<div class="theme-admonition theme-admonition-note admonition_xJq3 alert alert--secondary"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_BuS1"><p>This is a note</p></div></div>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>tip</div><div class="admonitionContent_BuS1"><p>This is a tip</p></div></div>
<div class="theme-admonition theme-admonition-important admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>important</div><div class="admonitionContent_BuS1"><p>This is important</p></div></div>
<div class="theme-admonition theme-admonition-caution admonition_xJq3 alert alert--warning"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>caution</div><div class="admonitionContent_BuS1"><p>This is a caution</p></div></div>
<div class="theme-admonition theme-admonition-warning admonition_xJq3 alert alert--warning"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>warning</div><div class="admonitionContent_BuS1"><p>This is a warning</p></div></div>
<h2 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="mdx">MDX<a href="https://arteiii.github.io/blog/MarkDown/#mdx" class="hash-link" aria-label="Direct link to MDX" title="Direct link to MDX" translate="no">​</a></h2>
<hr>
<p>lets you use jsx in markdown</p>
<p><a href="https://mdxjs.com/" target="_blank" rel="noopener noreferrer" class="">read more</a></p>
<h3 class="anchor anchorTargetHideOnScrollNavbar_vjPI" id="tabs">Tabs<a href="https://arteiii.github.io/blog/MarkDown/#tabs" class="hash-link" aria-label="Direct link to Tabs" title="Direct link to Tabs" translate="no">​</a></h3>
<hr>
<p><a href="https://docusaurus.io/docs/markdown-features/tabs" target="_blank" rel="noopener noreferrer" class=""><strong>read docu</strong></a></p>
<div class="language-mdx codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#9CDCFE;--prism-background-color:#1E1E1E"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-mdx codeBlock_bY9V thin-scrollbar" style="color:#9CDCFE;background-color:#1E1E1E"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#9CDCFE"><span class="token plain">import Tabs from "@theme/Tabs";</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">import TabItem from "@theme/TabItem";</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">&lt;Tabs&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  &lt;TabItem value="apple" label="Apple" default&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    This is an apple 🍎</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  &lt;/TabItem&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  &lt;TabItem value="orange" label="Orange"&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    This is an orange 🍊</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  &lt;/TabItem&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  &lt;TabItem value="banana" label="Banana"&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">    This is a banana 🍌</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">  &lt;/TabItem&gt;</span><br></div><div class="token-line" style="color:#9CDCFE"><span class="token plain">&lt;/Tabs&gt;</span><br></div></code></pre></div></div>
<div class="theme-tabs-container tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">Apple</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Orange</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Banana</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><p>This is an apple 🍎</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>This is an orange 🍊</p></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><p>This is a banana 🍌</p></div></div></div>]]></content>
        <author>
            <name>Evan Tay</name>
            <uri>https://github.com/DigiPie</uri>
        </author>
        <author>
            <name>Arteii / Ben</name>
            <uri>https://github.com/arteiii</uri>
        </author>
    </entry>
</feed>