<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"><generator uri="https://gohugo.io/" version="0.101.0">Hugo</generator><title type="html">html on A Scripter's Notes</title><subtitle type="html">Emacs, scripting and anything text oriented.</subtitle><link href="https://scripter.co/tags/html/" rel="alternate" type="text/html" title="HTML"/><link href="https://scripter.co/tags/html/index.xml" rel="alternate" type="application/rss+xml" title="RSS"/><link href="https://scripter.co/tags/html/atom.xml" rel="self" type="application/atom+xml" title="Atom"/><link href="https://scripter.co/tags/html/jf2feed.json" rel="alternate" type="application/jf2feed+json" title="jf2feed"/><updated>2026-04-22T08:24:58-04:00</updated><author><name>Kaushal Modi</name><email>kaushal.modi@gmail.com</email></author><id>https://scripter.co/tags/html/</id><entry><title type="html">Saving Python pip dependencies</title><link href="https://scripter.co/saving-python-pip-dependencies/?utm_source=atom_feed" rel="alternate" type="text/html"/><link href="https://scripter.co/zero-html-validation-errors/?utm_source=atom_feed" rel="related" type="text/html" title="Zero HTML Validation Errors!"/><link href="https://scripter.co/offline-html5-validator/?utm_source=atom_feed" rel="related" type="text/html" title="Offline HTML5 Validator"/><link href="https://scripter.co/disarming-the-tar-bomb-in-10-seconds/?utm_source=atom_feed" rel="related" type="text/html" title="Disarming the 'tar' bomb in 10 seconds"/><link href="https://scripter.co/unclutter-a-better-reader-view-for-browsers/?utm_source=atom_feed" rel="related" type="text/html" title="Unclutter: A better Reader View for browsers"/><link href="https://scripter.co/hugo-modules-importing-a-theme/?utm_source=atom_feed" rel="related" type="text/html" title="Hugo Modules: Importing a Theme"/><id>https://scripter.co/saving-python-pip-dependencies/</id><author><name>Kaushal Modi</name></author><published>2022-06-14T00:38:00-04:00</published><updated>2022-06-14T00:38:00-04:00</updated><content type="html"><![CDATA[<blockquote>How I generated the Python dependencies file <code>requirements.txt</code> so
that Netlify can install and run the HTML5 Validator before deploying
this site.</blockquote><div class="ox-hugo-toc toc">
<div class="heading">Table of Contents</div>
<ul>
<li><a href="#create-a-virtual-environment"><span class="section-num">1</span> Create a <em>virtual environment</em></a></li>
<li><a href="#activate-the-virtual-environment"><span class="section-num">2</span> Activate the <em>virtual environment</em></a></li>
<li><a href="#install-the-packages-using-pip"><span class="section-num">3</span> Install the packages using <code>pip</code></a></li>
<li><a href="#generate-requirements-dot-txt"><span class="section-num">4</span> Generate <code>requirements.txt</code></a></li>
<li><a href="#netlify-deployment">Netlify deployment</a></li>
<li><a href="#summary">Summary</a></li>
</ul>
</div>
<!--endtoc-->
<p>Recently I learned about the Python tool <code>html5validator</code> tool and
used it to run HTML5 validation on local HTML files. You can read more
about that in the <a href="/offline-html5-validator/">Offline HTML5 Validator</a> post.</p>
<p>But then I wondered .. &ldquo;Wouldn&rsquo;t it be awesome if I run this
validation step <strong>each time</strong> after Hugo generates this site on <a href="https://netlify.com">Netlify</a>,
but <span class="underline">before</span> it gets deployed?&rdquo;. That curiosity led me to <a href="https://docs.netlify.com/configure-builds/manage-dependencies/#python-dependencies">Netlify&rsquo;s
documentation on Python dependencies</a>, and I learned that Netlify will
run <code>pip install</code> to install the dependencies in <code>requirements.txt</code>
present in the repository&rsquo;s base directory.</p>
<p><span class="org-target" id="netlify-pip-freeze"></span> I followed the <code>pip freeze &gt; requirements.txt</code>
step in that documentation but that ended up listing <strong>all</strong> my <code>pip</code>
installed packages in that file! I needed the <code>requirements.txt</code> to
include the dependencies only for <code>html5validator</code>. This post was born
in my quest to achieve that.</p>
<p>The solution to this problem was to first create a Python <em>virtual
environment</em> in my site directory, and <em>then</em> do all the <code>pip</code>
operations in there. I learned about this <em>virtual environment</em> step
from <a href="https://medium.com/python-pandemonium/better-python-dependency-and-package-management-b5d8ea29dff1">this Python Pandemonium post</a>.</p>
<p>The <a href="https://docs.python.org/3/library/venv.html"><strong>venv</strong> documentation</a> has a lot of details &mdash; I&rsquo;ll just list the
key steps in this post.</p>

<h2 id="create-a-virtual-environment"><span class="section-num">1</span> Create a <em>virtual environment</em>&nbsp;<a class="headline-hash no-text-decoration" href="#create-a-virtual-environment">#</a></h2>


<p><em>cd</em> to your site directory and run the below command create a
virtualenv directory named <code>pyenv</code> in there.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">python3 -m venv pyenv
</span></span></code></pre></div><div class="note">
<p>As we are creating this <em>virtual environment</em> just for the sake of
creating a <code>requirements.txt</code>, we don&rsquo;t need to commit this
directory to <em>git</em>.</p>
</div>

<h2 id="activate-the-virtual-environment"><span class="section-num">2</span> Activate the <em>virtual environment</em>&nbsp;<a class="headline-hash no-text-decoration" href="#activate-the-virtual-environment">#</a></h2>


<p>The virtualenv directory <code>pyenv/bin/</code> will have multiple flavors of
shell scripts to activate your virtualenv. I am using
<code>activate.csh</code> here as my shell is <em>tcsh</em> 🙄.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="nb">source</span> pyenv/bin/activate.csh
</span></span></code></pre></div><p>Just to emphasize, it is important to use the <strong><code>source</code></strong> command here,
and not just call the shell script directly.</p>
<p>Once you activate this virtualenv, you should see something like
<em>[pyenv]</em> in the shell prompt.</p>

<h2 id="install-the-packages-using-pip"><span class="section-num">3</span> Install the packages using <code>pip</code>&nbsp;<a class="headline-hash no-text-decoration" href="#install-the-packages-using-pip">#</a></h2>


<p>Install all the project-specific packages. In this case it was just
this:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">pip install html5validator
</span></span></code></pre></div><p>The package (and its dependencies) will be installed in
<code>pyenv/lib/python3.7/site-packages/</code>. Here, the <code>python3.7/</code>
sub-directory name will match the version of Python you have
installed.</p>

<h2 id="generate-requirements-dot-txt"><span class="section-num">4</span> Generate <code>requirements.txt</code>&nbsp;<a class="headline-hash no-text-decoration" href="#generate-requirements-dot-txt">#</a></h2>


<p>Finally, we run the <code>pip freeze</code> command <a href="#netlify-pip-freeze">mentioned</a> in Netlify docs,
but with the <strong><code>--local</code></strong> switch:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">pip freeze --local &gt; requirements.txt
</span></span></code></pre></div><div class="note">
<p>The <code>--local</code> option ensures that globally-installed packages are not
listed even if the virtualenv has global access.</p>
</div>
<p>Here&rsquo;s the <code>requirements.txt</code> created by that command:</p>
<p><a id="code-snippet--netlify-requirements.txt"></a></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">html5validator==0.4.2
</span></span><span class="line"><span class="cl">PyYAML==6.0
</span></span></code></pre></div><div class="src-block-caption">
  <span class="src-block-number"><a href="#code-snippet--netlify-requirements.txt">Code Snippet 1</a>:</span>
  The <code>requirements.txt</code> for Netlify
</div>
<p>Now, I could have just manually typed <code>html5validator==0.4.2</code> in a
<code>requirements.txt</code> and committed that, and that would work too. But
then, I wouldn&rsquo;t have learned how to create a project-specific <em>pip
dependency file</em> 😄.</p>

<h2 id="netlify-deployment">Netlify deployment&nbsp;<a class="headline-hash no-text-decoration" href="#netlify-deployment">#</a></h2>


<p>The <code>html5validator</code> has a dependency on Java 8. Luckily the Netlify
environment already comes with that installed. So the only extra setup
needed to make this package work on Netlify was to set the
<code>PYTHON_VERSION</code> environment variable to <strong>3.8</strong>
<span class="sidenote-number"><small class="sidenote">
The version number should be one of the values listed in <a href="https://github.com/netlify/build-image/blob/focal/included_software.md">Netlify&rsquo;s
<em>included software</em> list</a>.
</small></span>
.</p>

<h2 id="summary">Summary&nbsp;<a class="headline-hash no-text-decoration" href="#summary">#</a></h2>


<p>The numbered headings in this post already summarize the steps needed
to create a project-specific <code>requirements.txt</code>.</p>
<p>With these in place:</p>
<div class="verse">
<p>✅ <code>requirements.txt</code> committed in site directory root<br />
✅ Netlify environment variable <code>PYTHON_VERSION</code> set to 3.8<br /></p>
</div>
<p>my Netlify deployment script now does HTML5 Validation along with few
other checks before this site gets deployed 🎉.</p>
<p>Here&rsquo;s the <a href="https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io/-/blob/master/build.sh">full <code>build.sh</code> script</a>.</p>
]]></content><category scheme="https://scripter.co/categories/web" term="web" label="web"/><category scheme="https://scripter.co/series/html5-validator" term="html5-validator" label="HTML5 Validator"/><category scheme="https://scripter.co/tags/html" term="html" label="html"/><category scheme="https://scripter.co/tags/validator" term="validator" label="validator"/><category scheme="https://scripter.co/tags/python" term="python" label="python"/><category scheme="https://scripter.co/tags/pip" term="pip" label="pip"/><category scheme="https://scripter.co/tags/100daystooffload" term="100daystooffload" label="100DaysToOffload"/><category scheme="https://scripter.co/tags/netlify" term="netlify" label="netlify"/></entry><entry><title type="html">Zero HTML Validation Errors!</title><link href="https://scripter.co/zero-html-validation-errors/?utm_source=atom_feed" rel="alternate" type="text/html"/><link href="https://scripter.co/offline-html5-validator/?utm_source=atom_feed" rel="related" type="text/html" title="Offline HTML5 Validator"/><link href="https://scripter.co/hugo-modules-importing-a-theme/?utm_source=atom_feed" rel="related" type="text/html" title="Hugo Modules: Importing a Theme"/><link href="https://scripter.co/looping-through-org-mode-headings/?utm_source=atom_feed" rel="related" type="text/html" title="Looping through Org mode headings"/><link href="https://scripter.co/using-org-logbook-notes-to-record-blog-post-updates/?utm_source=atom_feed" rel="related" type="text/html" title="Using Org Logbook Notes to record blog post updates"/><link href="https://scripter.co/building-org-development-version/?utm_source=atom_feed" rel="related" type="text/html" title="Building Org Development version (2022)"/><id>https://scripter.co/zero-html-validation-errors/</id><author><name>Kaushal Modi</name></author><published>2022-06-05T17:58:00-04:00</published><updated>2022-06-05T17:58:00-04:00</updated><content type="html"><![CDATA[<blockquote>How I fixed my site content and went down from 46 HTML validations
errors down to 0!</blockquote><div class="ox-hugo-toc toc">
<div class="heading">Table of Contents</div>
<ul>
<li><a href="#avoid-duplicate-heading-id-attributes"><span class="section-num">1</span> Avoid duplicate heading <code>id</code> attributes</a></li>
<li><a href="#remove-inline-style-elements"><span class="section-num">2</span> Remove inline <code>&lt;style&gt;</code> elements</a></li>
<li><a href="#ensure-that-all-images-have-captions-or-alt-attributes"><span class="section-num">3</span> Ensure that all images have captions or <code>alt</code> attributes</a></li>
<li><a href="#do-not-have-hyperlinks-in-headings"><span class="section-num">4</span> Do not have hyperlinks in headings</a></li>
<li><a href="#validation-ignores">Validation Ignores</a>
<ul>
<li><a href="#ignore-errors-due-to-hyperlinks-in-inline-svg"><span class="section-num">5</span> Ignore errors due to hyperlinks in inline SVG</a></li>
<li><a href="#ignore-files-not-expected-to-serve-html-content"><span class="section-num">6</span> Ignore files not expected to serve HTML content</a></li>
</ul>
</li>
<li><a href="#summary">Summary</a></li>
</ul>
</div>
<!--endtoc-->
<p>In my <a href="/offline-html5-validator/">previous HTML5 Validator post</a>, I mentioned:</p>
<blockquote>
<p>I was a bit disappointed to see validation errors on my site, but then
it wasn&rsquo;t too bad .. 46 errors.</p>
</blockquote>
<p>But they truly say ..</p>
<div class="org-center">
<p>Ignorance is bliss.</p>
</div>
<p>So .. once I realized that my site had 46 validation errors, I lost
that <em>bliss</em> .. and I couldn&rsquo;t rest easy &mdash; I had to fix them all
😁.</p>
<p>This post summarizes the categories of those errors and how I fixed
<span class="sidenote-number"><small class="sidenote">
The fixes mentioned in this post refer to changes in Org mode
content. But you should be able to derive equivalent fixes for
Markdown too.
</small></span>
them all.</p>

<h2 id="avoid-duplicate-heading-id-attributes"><span class="section-num">1</span> Avoid duplicate heading <code>id</code> attributes&nbsp;<a class="headline-hash no-text-decoration" href="#avoid-duplicate-heading-id-attributes">#</a></h2>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:636.34-636.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:300.34-300.52: error: Duplicate ID &#34;older-issue&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:306.20-306.33: error: Duplicate ID &#34;floats&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/page/6/index.html&#34;:29.39-29.54: error: Duplicate ID &#34;fnref:1&#34;.
</span></span></code></pre></div><p>Errors with above kind of signatures were fixed by,</p>
<ol>
<li>
<p>Converting headings to description lists</p>
<p>I had a bunch of generic headings like &ldquo;Notes&rdquo; and &ldquo;Older Issue&rdquo; in
some of my posts. After taking a second look at those, it made more
sense to convert those to description lists. So in Org mode, I
converted headings like <code class="code-inline language-org"><span class="gh">*</span><span class="gs"> Notes</span></code> to
description lists <code class="code-inline language-org"><span class="k">- </span>Notes ::</code>.</p>
</li>
<li>
<p>Setting <code>CUSTOM_ID</code> heading property</p>
<p>For the cases, where the headings needed to be left as so, their
IDs were uniquified by setting their <code>CUSTOM_ID</code> property. For
example, below fixed the <em>Duplicate ID &ldquo;floats&rdquo;</em> errors.
<a id="code-snippet--using-custom-id-to-uniquify-heading-id"></a></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"> ** Precision
</span></span><span class="line"><span class="cl"> ..
</span></span><span class="line"><span class="cl"> *** Floats
</span></span><span class="line"><span class="cl"><span class="gi">+:PROPERTIES:
</span></span></span><span class="line"><span class="cl"><span class="gi">+:CUSTOM_ID: precision-floats
</span></span></span><span class="line"><span class="cl"><span class="gi">+:END:
</span></span></span><span class="line"><span class="cl"><span class="gi"></span> ..
</span></span><span class="line"><span class="cl"> ** Type (only for numbers)
</span></span><span class="line"><span class="cl"> ..
</span></span><span class="line"><span class="cl"> *** Floats
</span></span><span class="line"><span class="cl"><span class="gi">+:PROPERTIES:
</span></span></span><span class="line"><span class="cl"><span class="gi">+:CUSTOM_ID: type-floats
</span></span></span><span class="line"><span class="cl"><span class="gi">+:END:
</span></span></span></code></pre></div><div class="src-block-caption">
  <span class="src-block-number"><a href="#code-snippet--using-custom-id-to-uniquify-heading-id">Code Snippet 1</a>:</span>
  Using <code>CUSTOM_ID</code> property to uniquify heading ID's
</div>
</li>
<li>
<p>Prevent footnote links in post summaries</p>
<p>This issue was due to me not being conscious about how the footnote
references work in a post <em>versus</em> on a page outside that post&rsquo;s
context.  The issue was caused by footnote references getting into
the post summaries parsed by Hugo, which will then show up on the
list pages.</p>
<p>The fix was simple &mdash; Edit the post summaries so that they don&rsquo;t
contain any footnote references.</p>
</li>
</ol>

<h2 id="remove-inline-style-elements"><span class="section-num">2</span> Remove inline <code>&lt;style&gt;</code> elements&nbsp;<a class="headline-hash no-text-decoration" href="#remove-inline-style-elements">#</a></h2>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/​grep-po/index.html&#34;:51.139-51.145: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​how-do-i-write-org-mode/index.html&#34;:23.194-23.200: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span></code></pre></div><p>Errors with above kind of signatures were fixed by,</p>
<ol>
<li>
<p>Avoiding export of raw <code>&lt;style&gt;</code> elements in the Markdown content</p>
<p>I figured out which functions were responsible for injecting
<code>&lt;style&gt;</code> elements in Markdown content and then advised them to
stop that. After applying these advises, I lost the in-content
rules for CSS classes <code>.org-center</code> and <code>.csl-entry</code>. So I put
those rules directly in this website&rsquo;s CSS.
<a id="code-snippet--advices-to-prevent-style-elem-in-exports"></a></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-emacs-lisp" data-lang="emacs-lisp"><span class="line"><span class="cl"><span class="p">(</span><span class="nb">defun</span> <span class="nv">modi/org-blackfriday-center-block</span> <span class="p">(</span><span class="nv">_center-block</span> <span class="nv">contents</span> <span class="nv">info</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">  <span class="p">(</span><span class="nb">let*</span> <span class="p">((</span><span class="nv">class</span> <span class="s">&#34;org-center&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">    <span class="p">(</span><span class="nf">format</span> <span class="s">&#34;&lt;div class=\&#34;%s\&#34;&gt;%s\n\n%s\n&lt;/div&gt;&#34;</span>
</span></span><span class="line"><span class="cl">            <span class="nv">class</span> <span class="p">(</span><span class="nv">org-blackfriday--extra-div-hack</span> <span class="nv">info</span><span class="p">)</span> <span class="nv">contents</span><span class="p">)))</span>
</span></span><span class="line"><span class="cl"><span class="p">(</span><span class="nv">advice-add</span> <span class="ss">&#39;org-blackfriday-center-block</span> <span class="nb">:override</span> <span class="nf">#&#39;</span><span class="nv">modi/org-blackfriday-center-block</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">(</span><span class="nb">defun</span> <span class="nv">modi/org-cite-csl-render-bibliography</span> <span class="p">(</span><span class="nv">bib-str</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">  <span class="p">(</span><span class="nv">replace-regexp-in-string</span> <span class="s">&#34;&lt;style&gt;\\.csl-entry[^&lt;]+&lt;/style&gt;&#34;</span> <span class="s">&#34;&#34;</span> <span class="nv">bib-str</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="p">(</span><span class="nv">advice-add</span> <span class="ss">&#39;org-cite-csl-render-bibliography</span> <span class="nb">:filter-return</span> <span class="nf">#&#39;</span><span class="nv">modi/org-cite-csl-render-bibliography</span><span class="p">)</span>
</span></span></code></pre></div><div class="src-block-caption">
  <span class="src-block-number"><a href="#code-snippet--advices-to-prevent-style-elem-in-exports">Code Snippet 2</a>:</span>
  Emacs-Lisp advices to prevent <code>&lt;style&gt;</code> elements in exports
</div>
</li>
<li>
<p>Removing unnecessary micro-styling</p>
<p>I found a single case, where an inline CSS rule was defined in
content for CSS class <code>.repr-type</code> for a table. I just removed that
without affecting the looks of that rendered table too much.</p>
</li>
</ol>

<h2 id="ensure-that-all-images-have-captions-or-alt-attributes"><span class="section-num">3</span> Ensure that all images have captions or <code>alt</code> attributes&nbsp;<a class="headline-hash no-text-decoration" href="#ensure-that-all-images-have-captions-or-alt-attributes">#</a></h2>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/​hugo-use-goat-code-blocks-for-ascii-diagrams/index.html&#34;:24.130-24.255: error: An &#34;img&#34; element must have an &#34;alt&#34; attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.
</span></span></code></pre></div><p>Errors with above kind of signatures were easily fixed by ensuring
that all images had captions
<span class="sidenote-number"><small class="sidenote">
Thankfully, there were only two images that were missing captions.
</small></span>
. The Hugo <code>figure</code> shortcode adds the caption to the <code>alt</code> attribute if
the <code>alt</code> is not specified separately.</p>
<p>As an example, here&rsquo;s how I fixed the above error:</p>
<p><a id="code-snippet--adding-a-caption-to-an-image"></a></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"><span class="gi">+ #+name: fig__disproportionate_box_drawing
</span></span></span><span class="line"><span class="cl"><span class="gi">+ #+caption: Disproportionate box drawing characters
</span></span></span><span class="line"><span class="cl"><span class="gi"></span>[[file:images/​hugo-use-goat-code-blocks-for-ascii-diagrams/ascii-diagram-rendered-in-plain-text-code-block.png]]
</span></span></code></pre></div><div class="src-block-caption">
  <span class="src-block-number"><a href="#code-snippet--adding-a-caption-to-an-image">Code Snippet 3</a>:</span>
  A <code>git diff</code> showing addition of caption to an image
</div>

<h2 id="do-not-have-hyperlinks-in-headings"><span class="section-num">4</span> Do not have hyperlinks in headings&nbsp;<a class="headline-hash no-text-decoration" href="#do-not-have-hyperlinks-in-headings">#</a></h2>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/​using-emacs-advice-to-silence-messages-from-functions/index.html&#34;:151.687-151.732: error: Start tag &#34;a&#34; seen but an element of the same type was already open.
</span></span><span class="line"><span class="cl">&#34;file:/public/​using-emacs-advice-to-silence-messages-from-functions/index.html&#34;:151.748-151.751: error: Stray end tag &#34;a&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.446-114.475: error: Start tag &#34;a&#34; seen but an element of the same type was already open.
</span></span><span class="line"><span class="cl">&#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.446-114.475: error: End tag &#34;a&#34; violates nesting rules.
</span></span><span class="line"><span class="cl">&#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.526-114.529: error: Stray end tag &#34;a&#34;.
</span></span></code></pre></div><p>While the hyperlinks in headings work well, they created invalid HTML
in the Hugo-generated TOC. So while these errors were created
technically because of a bug in Hugo
<span class="sidenote-number"><small class="sidenote">
It&rsquo;s really cool when you end up finding a bug in an upstream project
while trying to fix the errors in your own thing 😎.
</small></span>
, I wanted to fix these errors on my end as soon as I can.</p>
<p>I reviewed the errors, and this is all it took to get rid of them all:</p>
<ol>
<li>
<p>Remove manually inserting hyperlinks in headings
<a id="code-snippet--removing-hyperlink-from-a-heading"></a></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"> show two methods of finding sources of any printed messages.
</span></span><span class="line"><span class="cl"><span class="gd">-***** Using plain-old /grep/ or [[https://github.com/BurntSushi/ripgrep][/rg/]]
</span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+***** Using plain-old /grep/ or /ripgrep (rg)/
</span></span></span><span class="line"><span class="cl"><span class="gi"></span> This method is pretty easy (but not robust) to use if the search
</span></span><span class="line"><span class="cl"> ..
</span></span><span class="line"><span class="cl"> Org source directory and search for the /&#34;org-babel-exp process ..&#34;/
</span></span><span class="line"><span class="cl"><span class="gd">-string ..
</span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+string using [[https://github.com/BurntSushi/ripgrep][~rg~]] ..
</span></span></span></code></pre></div><div class="src-block-caption">
  <span class="src-block-number"><a href="#code-snippet--removing-hyperlink-from-a-heading">Code Snippet 4</a>:</span>
  Removing hyperlink from a heading
</div>
</li>
<li>
<p>Remove Org Radio links that created links in headings</p>
<p>Here, a Org heading happened to contain the string &ldquo;Day count&rdquo;,
which was also an <a href="https://orgmode.org/manual/Radio-Targets.html" title="Emacs Lisp: (info &quot;(org) Radio Targets&quot;)">an Org Radio link</a> in that post. While ideally
that shouldn&rsquo;t have mattered, I removed that radio link to get
around this Hugo bug.
<a id="code-snippet--removing-an-org-radio-link"></a></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"> .. /Just may be/. But regardless, I am already enjoying writing once
</span></span><span class="line"><span class="cl"><span class="gd">-again, and it&#39;s great to see the &lt;&lt;&lt;Day count&gt;&gt;&gt; (counting up to 100)
</span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+again, and it&#39;s great to see the Day count (counting up to 100)
</span></span></span><span class="line"><span class="cl"><span class="gi"></span> increase with each new post!
</span></span></code></pre></div><div class="src-block-caption">
  <span class="src-block-number"><a href="#code-snippet--removing-an-org-radio-link">Code Snippet 5</a>:</span>
  Removing an Org Radio link
</div>
</li>
</ol>

<h2 id="validation-ignores">Validation Ignores&nbsp;<a class="headline-hash no-text-decoration" href="#validation-ignores">#</a></h2>


<p>Above fixes fixed 43 out of 46 errors, but the remaining 3 were unfixable.</p>

<h3 id="ignore-errors-due-to-hyperlinks-in-inline-svg"><span class="section-num">5</span> Ignore errors due to hyperlinks in inline SVG&nbsp;<a class="headline-hash no-text-decoration" href="#ignore-errors-due-to-hyperlinks-in-inline-svg">#</a></h3>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/notes/​plantuml/index.html&#34;:114.474-114.678: error: Attribute &#34;title&#34; not allowed on element &#34;a&#34; at this point.
</span></span></code></pre></div><p>This error was caused by hyperlinks in inline SVG elements. These SVG
elements are created by <a href="https://plantuml.com/">PlantUML</a>. The <em>hyperlinks in SVG</em> feature
works great, and as these are generated by PlantUML, I chose to just
ignore these errors.</p>
<p>I ignored this error by adding the <code>--ignore-re 'notes/plantuml.*Attribute.*title.*not allowed'</code> switch to the
<code>html5validator</code> command.</p>

<h3 id="ignore-files-not-expected-to-serve-html-content"><span class="section-num">6</span> Ignore files not expected to serve HTML content&nbsp;<a class="headline-hash no-text-decoration" href="#ignore-files-not-expected-to-serve-html-content">#</a></h3>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/googleFOO.html&#34;:1.1-1.52: error: Non-space characters found without seeing a doctype first. Expected &#34;&lt;!DOCTYPE html&gt;&#34;.
</span></span></code></pre></div><p>The <code>googleFOO.html</code> file here is not a valid HTML file. It&rsquo;s a just a
<em>cookie</em> file that was used by Google to verify that I own this
domain.</p>
<p>This error was masked by adding the <code>--ignore 'googleFOO'</code> switch to
the <code>html5validator</code> command.</p>

<h2 id="summary">Summary&nbsp;<a class="headline-hash no-text-decoration" href="#summary">#</a></h2>


<p>Once I fixed the 43 errors by tweaking the Org mode content, and added
those two ignores, I had <strong>zero validation errors</strong>! 🎉</p>
<p>If you are interested in the fix details, <a href="https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io/-/compare/a7cac5dd1293442a51fd5020a3bcef8da7f75fdc...42d6c72d533c337b5c67fa09207f68e45efe6e6c">here are the commits</a>.</p>
]]></content><category scheme="https://scripter.co/categories/emacs" term="emacs" label="emacs"/><category scheme="https://scripter.co/categories/web" term="web" label="web"/><category scheme="https://scripter.co/categories/org" term="org" label="org"/><category scheme="https://scripter.co/series/html5-validator" term="html5-validator" label="HTML5 Validator"/><category scheme="https://scripter.co/tags/html" term="html" label="html"/><category scheme="https://scripter.co/tags/validator" term="validator" label="validator"/><category scheme="https://scripter.co/tags/100daystooffload" term="100daystooffload" label="100DaysToOffload"/></entry><entry><title type="html">Offline HTML5 Validator</title><link href="https://scripter.co/offline-html5-validator/?utm_source=atom_feed" rel="alternate" type="text/html"/><link href="https://scripter.co/hugo-modules-importing-a-theme/?utm_source=atom_feed" rel="related" type="text/html" title="Hugo Modules: Importing a Theme"/><link href="https://scripter.co/looping-through-org-mode-headings/?utm_source=atom_feed" rel="related" type="text/html" title="Looping through Org mode headings"/><link href="https://scripter.co/using-org-logbook-notes-to-record-blog-post-updates/?utm_source=atom_feed" rel="related" type="text/html" title="Using Org Logbook Notes to record blog post updates"/><link href="https://scripter.co/building-org-development-version/?utm_source=atom_feed" rel="related" type="text/html" title="Building Org Development version (2022)"/><link href="https://scripter.co/downloading-nim/?utm_source=atom_feed" rel="related" type="text/html" title="Downloading Nim"/><id>https://scripter.co/offline-html5-validator/</id><author><name>Kaushal Modi</name></author><published>2022-06-01T00:11:00-04:00</published><updated>2022-06-01T00:11:00-04:00</updated><content type="html"><![CDATA[<blockquote>Validate your website offline &mdash; It&rsquo;s just one <code>curl</code> command away.</blockquote><div class="ox-hugo-toc toc">
<div class="heading">Table of Contents</div>
<ul>
<li><a href="#using-the-dot-jar">Using the <code>.jar</code></a>
<ul>
<li><a href="#using-pip-install">Using <code>pip install</code></a></li>
</ul>
</li>
<li><a href="#using-pre-compiled-binary">Using pre-compiled binary</a></li>
<li><a href="#results">Results</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</div>
<!--endtoc-->
<p>I have been using the online HTML5 Validator
<a href="https://html5.validator.nu/">https://html5.validator.nu/</a> for few years now. I have a link at the
bottom of each post to validate that page&rsquo;s HTML. For an example, see
the <em>html5 validator</em> link at the <a href="#bottom">bottom</a> of this
post.</p>
<p>But it didn&rsquo;t occur to me until now to look for a way to do the same
validation offline! Offline validation would be useful so that I can
look at any HTML generation problem before I deploy the website. So I
looked for a solution online, and of course it&rsquo;s <a href="https://stackoverflow.com/a/26505206/1219634">answered on
StackOverflow</a> 😄.</p>
<p>It turns out that same <a href="https://github.com/validator/validator">Nu HTML5 Validator</a> project that provides the
online validation service, also provides a Java application as well as
pre-compiled binaries for Linux, Windows and MacOS for offline use!</p>
<p>To use the Java <em>.jar</em> file, you need to have at least Java 8
installed on your system. But you don&rsquo;t need to have any version of
Java installed if you use the pre-compiled binary instead. See <a href="https://validator.github.io/validator/">its
documentation</a> for more details.</p>

<h2 id="using-the-dot-jar">Using the <code>.jar</code>&nbsp;<a class="headline-hash no-text-decoration" href="#using-the-dot-jar">#</a></h2>


<div class="note">
<p>Requires at least Java 8</p>
</div>
<dl>
<dt>Download</dt>
<dd>Download the latest <code>vnu.jar</code> from the project&rsquo;s <a href="https://github.com/validator/validator/releases">GitHub
Releases section</a>.
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">curl -ROLs https://github.com/validator/validator/releases/download/latest/vnu.jar
</span></span></code></pre></div></dd>
<dt>Run</dt>
<dd>Below command runs the validator only on the HTML files in
the <code>public/</code>
<span class="sidenote-number"><small class="sidenote">
If you are using <a href="https://gohugo.io">Hugo</a>, the <code>hugo</code> command will publish the HTML
files in the <code>public/</code> directory by default.
</small></span>
directory. See its <a href="https://validator.github.io/validator/#usage">Usage documentation</a> for more details.
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">java -jar vnu.jar --skip-non-html --errors-only public/
</span></span></code></pre></div><p>For my usecase, if I don&rsquo;t provide the <code>--skip-non-html --errors-only</code> switches, the output is too noisy.</p>
</dd>
</dl>

<h3 id="using-pip-install">Using <code>pip install</code>&nbsp;<a class="headline-hash no-text-decoration" href="#using-pip-install">#</a></h3>


<p>If you do not want to manually download the <code>.jar</code>, there&rsquo;s a Python
wrapper available to do the same for you: <a href="https://github.com/svenkreiss/html5validator">html5validator</a>.</p>
<dl>
<dt>Install</dt>
<dd><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">  pip install --user html5validator
</span></span></code></pre></div></dd>
<dt>Run</dt>
<dd><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">  html5validator --root public/
</span></span></code></pre></div>It seems like this Python wrapper implicitly passes <code>--skip-non-html --errors-only</code> to the Java app. So those are not needed when running
<code>html5validator</code>. But on the flip side, it needs the <code>--root</code> switch
when specifying the directory to run the script on.</dd>
</dl>
<p>Note that you still need to have at least Java 8 installed when
running this Python app too, because it downloads and run the same
<code>.jar</code> behind the scenes.</p>

<h2 id="using-pre-compiled-binary">Using pre-compiled binary&nbsp;<a class="headline-hash no-text-decoration" href="#using-pre-compiled-binary">#</a></h2>


<p>If your system doesn&rsquo;t have the required Java version, you can use the
pre-compiled binary instead.</p>
<dl>
<dt>Download &amp; Extract</dt>
<dd>Download and extract the <code>vnu.&lt;OS&gt;.zip</code> for
your <strong>OS</strong> from the same <em>Releases</em> section. Here, I am showing how
to do that on Linux:
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">curl -ROLs https://github.com/validator/validator/releases/download/latest/vnu.linux.zip
</span></span><span class="line"><span class="cl">unzip vnu.linux.zip
</span></span></code></pre></div><p>The extracted binary path will be <code>vnu-runtime-image/bin/vnu</code>.</p>
</dd>
<dt>Run</dt>
<dd>The run options will be the exact same; just that you will be
running the binary directly instead of running through <code>java</code>.
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">vnu-runtime-image/bin/vnu --skip-non-html --errors-only public/
</span></span></code></pre></div></dd>
</dl>

<h2 id="results">Results&nbsp;<a class="headline-hash no-text-decoration" href="#results">#</a></h2>

    <div class="logbook-notes">
        <dl>
            
                <dt>
                    <span class="timestamp-wrapper">
                        <span class="timestamp">
                            &lt;2022-06-05&gt;
                        </span>
                    </span>
                </dt>
                <dd>
                    This website now has zero validation errors! 🎉 All the errors
listed in the <a href="#org-target--validation-log">collapsed log below</a> are now resolved. See my <a href="/zero-html-validation-errors/">Zero HTML Validation Errors!</a> post on how I did that.
                </dd>
            
        </dl>
    </div>


<p>I was a bit disappointed to see validation errors on my site, but then
it wasn&rsquo;t too bad .. <del>52</del> 46 errors:</p>
<dl>
<dt>Some I already fixed</dt>
<dd>These 6 errors were fixed in <a href="https://gitlab.com/kaushalmodi/kaushalmodi.gitlab.io/-/commit/4288a70fa473800b597d46c77bf4021d7c0cd060">this commit</a>.
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/​getting-started-with-texlive/index.html&#34;:6.2198-6.2206: error: Element &#34;package&#34; not allowed as child of element &#34;li&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​getting-started-with-texlive/index.html&#34;:6.2256-6.2259: error: End tag &#34;li&#34; implied, but there were open elements.
</span></span><span class="line"><span class="cl">&#34;file:/public/​getting-started-with-texlive/index.html&#34;:6.2198-6.2206: error: Unclosed element &#34;package&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/​getting-started-with-texlive/index.html&#34;:6.2307-6.2315: error: Element &#34;package&#34; not allowed as child of element &#34;li&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​getting-started-with-texlive/index.html&#34;:6.2316-6.2319: error: End tag &#34;li&#34; implied, but there were open elements.
</span></span><span class="line"><span class="cl">&#34;file:/public/​getting-started-with-texlive/index.html&#34;:6.2307-6.2315: error: Unclosed element &#34;package&#34;.
</span></span></code></pre></div></dd>
<dt>Some I can probably fix</dt>
<dd><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">  &#34;file:/public/notes/​nim/index.html&#34;:472.480-472.486: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">  &#34;file:/public/notes/​nim/index.html&#34;:1359.221-1359.231: error: Duplicate ID &#34;log&#34;.
</span></span><span class="line"><span class="cl">  ..
</span></span></code></pre></div></dd>
<dt>Some need to be ignored</dt>
<dd><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">  &#34;file:/public/​google4a938eaf9bbacbcd.html&#34;:1.1-1.52: error: Non-space characters found without seeing a doctype first. Expected &#34;&lt;!DOCTYPE html&gt;&#34;.
</span></span><span class="line"><span class="cl">  &#34;file:/public/​google4a938eaf9bbacbcd.html&#34;:1.1-1.52: error: Element &#34;head&#34; is missing a required instance of child element &#34;title&#34;.
</span></span><span class="line"><span class="cl">  ..
</span></span></code></pre></div></dd>
<dt>And the rest would be out of my scope to fix</dt>
<dd><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">  &#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.446-114.475: error: Start tag &#34;a&#34; seen but an element of the same type was already open.
</span></span><span class="line"><span class="cl">  &#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.446-114.475: error: End tag &#34;a&#34; violates nesting rules.
</span></span><span class="line"><span class="cl">  &#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.526-114.529: error: Stray end tag &#34;a&#34;.
</span></span><span class="line"><span class="cl">  ..
</span></span></code></pre></div></dd>
</dl>
<p>Expand the below drawer if you&rsquo;d like to see the full log with 46
errors: <span class="org-target" id="org-target--validation-log"></span></p>
<details>
<summary>Output of running <code>html5validator --root public/</code></summary>
<div class="details">
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">&#34;file:/public/​google4a938eaf9bbacbcd.html&#34;:1.1-1.52: error: Non-space characters found without seeing a doctype first. Expected &#34;&lt;!DOCTYPE html&gt;&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/​google4a938eaf9bbacbcd.html&#34;:1.1-1.52: error: Element &#34;head&#34; is missing a required instance of child element &#34;title&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​plantuml/index.html&#34;:114.474-114.678: error: Attribute &#34;title&#34; not allowed on element &#34;a&#34; at this point.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:300.34-300.52: error: Duplicate ID &#34;older-issue&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:306.20-306.33: error: Duplicate ID &#34;floats&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:339.34-339.52: error: Duplicate ID &#34;older-issue&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:341.320-341.335: error: Duplicate ID &#34;integers&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:341.494-341.507: error: Duplicate ID &#34;floats&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim-fmt/index.html&#34;:385.34-385.48: error: Duplicate ID &#34;strings&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:134.34-134.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:239.34-239.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:269.34-269.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:336.34-336.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:513.106-513.118: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:588.106-588.118: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:636.34-636.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:731.34-731.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:797.34-797.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:846.34-846.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:894.34-894.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:920.34-920.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:942.34-942.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:1012.34-1012.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​string-fns-nim-vs-python/index.html&#34;:1074.34-1074.46: error: Duplicate ID &#34;notes&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:472.480-472.486: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:1359.221-1359.231: error: Duplicate ID &#34;log&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:2364.130-2364.149: error: Duplicate ID &#34;named-tuples&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:2403.149-2403.172: error: Duplicate ID &#34;anonymous-tuples&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:3370.284-3370.303: error: Duplicate ID &#34;installation&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:3410.354-3410.373: error: Duplicate ID &#34;installation&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:5033.34-5033.52: error: Duplicate ID &#34;older-issue&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:5376.34-5376.45: error: Duplicate ID &#34;json&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/notes/​nim/index.html&#34;:6066.64-6066.81: error: Duplicate ID &#34;references&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/bits/​plantuml-version/index.html&#34;:7.37-7.94: error: An &#34;img&#34; element must have an &#34;alt&#34; attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.
</span></span><span class="line"><span class="cl">&#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.446-114.475: error: Start tag &#34;a&#34; seen but an element of the same type was already open.
</span></span><span class="line"><span class="cl">&#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.446-114.475: error: End tag &#34;a&#34; violates nesting rules.
</span></span><span class="line"><span class="cl">&#34;file:/public/​auto-count-100daystooffload-posts/index.html&#34;:114.526-114.529: error: Stray end tag &#34;a&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/​generics-not-exactly-in-systemverilog/index.html&#34;:118.232-118.238: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​grep-po/index.html&#34;:51.139-51.145: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​how-do-i-write-org-mode/index.html&#34;:23.194-23.200: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​hugo-use-goat-code-blocks-for-ascii-diagrams/index.html&#34;:24.130-24.255: error: An &#34;img&#34; element must have an &#34;alt&#34; attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.
</span></span><span class="line"><span class="cl">&#34;file:/public/​hugo-modules-getting-started/index.html&#34;:6.865-6.871: error: Element &#34;style&#34; not allowed as child of element &#34;div&#34; in this context. (Suppressing further errors from this subtree.)
</span></span><span class="line"><span class="cl">&#34;file:/public/​using-emacs-advice-to-silence-messages-from-functions/index.html&#34;:151.687-151.732: error: Start tag &#34;a&#34; seen but an element of the same type was already open.
</span></span><span class="line"><span class="cl">&#34;file:/public/​using-emacs-advice-to-silence-messages-from-functions/index.html&#34;:151.748-151.751: error: Stray end tag &#34;a&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/page/6/index.html&#34;:29.39-29.54: error: Duplicate ID &#34;fnref:1&#34;.
</span></span><span class="line"><span class="cl">&#34;file:/public/page/6/index.html&#34;:49.169-49.184: error: Duplicate ID &#34;fnref:1&#34;.
</span></span></code></pre></div></div>
</details>

<h2 id="conclusion">Conclusion&nbsp;<a class="headline-hash no-text-decoration" href="#conclusion">#</a></h2>


<p>It was really easy to download the run the <code>vnu</code> application using
Java, the standalone Linux binary and also through the
<code>html5validator</code> Python wrapper.</p>
<p>After my quick trials, I think I will use the <code>html5validator</code>
approach more because,</p>
<ol>
<li>It works as I expect will the least number of switches.</li>
<li>I am able to redirect the output using <code>html5validator --root public/ &gt; validate.log</code>. <em>I tried the same using the <code>vnu.jar</code> and
Linux compiled <code>vnu</code> binary, but the error log redirection didn&rsquo;t
work with those.</em></li>
</ol>
]]></content><category scheme="https://scripter.co/categories/web" term="web" label="web"/><category scheme="https://scripter.co/series/html5-validator" term="html5-validator" label="HTML5 Validator"/><category scheme="https://scripter.co/tags/html" term="html" label="html"/><category scheme="https://scripter.co/tags/validator" term="validator" label="validator"/><category scheme="https://scripter.co/tags/100daystooffload" term="100daystooffload" label="100DaysToOffload"/></entry><entry><title type="html">LaTeX in HTML</title><link href="https://scripter.co/latex-in-html/?utm_source=atom_feed" rel="alternate" type="text/html"/><id>https://scripter.co/latex-in-html/</id><author><name>Kaushal Modi</name></author><published>2018-02-02T18:58:00-05:00</published><updated>2018-02-12T00:00:00-05:00</updated><content type="html"><![CDATA[<div class="ox-hugo-toc toc has-section-numbers">
<div class="heading">Table of Contents</div>
<ul>
<li><span class="section-num">1</span> <a href="#using-mathjax">Using MathJax</a></li>
<li><span class="section-num">2</span> <a href="#using-html-plus-css">Using HTML + CSS</a>
<ul>
<li><a href="#define-these-macros-in-org">Define these macros in Org</a></li>
<li><a href="#css">CSS</a></li>
<li><a href="#use-the-org-macros">Use the Org macros</a></li>
</ul>
</li>
<li><a href="#references">References</a></li>
</ul>
</div>
<!--endtoc-->
<p>Ever wondered how to show <span class="latex">L<sup>a</sup>T<sub>e</sub>X</span> in HTML or a <a href="https://ox-hugo.scripter.co">Hugo blog post</a>
exported from Org?</p>
<p>There are 2 ways to do this:</p>
<ol>
<li>Using MathJax &ndash; \(\LaTeX\).</li>
<li>Using HTML + CSS &ndash; <span class="latex">L<sup>a</sup>T<sub>e</sub>X</span>.</li>
</ol>

<h2 id="using-mathjax"><span class="section-num">1</span> Using MathJax&nbsp;<a class="headline-hash no-text-decoration" href="#using-mathjax">#</a></h2>


<p>If you don&rsquo;t mind including the <a href="https://gitlab.com/kaushalmodi/hugo-theme-refined/blob/master/layouts/partials/mathjax.html">MathJax script</a>, it&rsquo;s as simple as
typing <code>$\LaTeX$</code> in Org, which results in \(\LaTeX\).</p>
<p>Similarly \(\TeX\) (<code>$\TeX$</code>) also works, though not <code>$\XeTeX$</code>.</p>

<h2 id="using-html-plus-css"><span class="section-num">2</span> Using HTML + CSS&nbsp;<a class="headline-hash no-text-decoration" href="#using-html-plus-css">#</a></h2>


<p>And here&rsquo;s another way if you don&rsquo;t want to include MathJax.</p>

<h3 id="define-these-macros-in-org">Define these macros in Org&nbsp;<a class="headline-hash no-text-decoration" href="#define-these-macros-in-org">#</a></h3>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-org" data-lang="org"><span class="line"><span class="cl"><span class="cs">#+macro</span><span class="c">: tex @@html:&lt;span class=&#34;tex&#34;&gt;T&lt;sub&gt;e&lt;/sub&gt;X&lt;/span&gt;@@</span>
</span></span><span class="line"><span class="cl"><span class="cs">#+macro</span><span class="c">: latex @@html:&lt;span class=&#34;latex&#34;&gt;L&lt;sup&gt;a&lt;/sup&gt;T&lt;sub&gt;e&lt;/sub&gt;X&lt;/span&gt;@@</span>
</span></span><span class="line"><span class="cl"><span class="cs">#+macro</span><span class="c">: xetex @@html:&lt;span class=&#34;xetex&#34;&gt;X&lt;sub&gt;&amp;#398;&lt;/sub&gt;T&lt;sub&gt;E&lt;/sub&gt;X&lt;/span&gt;@@</span>
</span></span></code></pre></div>
<h3 id="css">CSS&nbsp;<a class="headline-hash no-text-decoration" href="#css">#</a></h3>


<p>Add this CSS directly in the page within a <code>#+begin_export html</code> /
<code>#+end_export</code> block, or add that CSS your site&rsquo;s stylesheet.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-html" data-lang="html"><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">style</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl"><span class="p">.</span><span class="nc">tex</span><span class="o">,</span> <span class="p">.</span><span class="nc">latex</span><span class="o">,</span> <span class="p">.</span><span class="nc">tex</span> <span class="nt">sub</span><span class="o">,</span> <span class="p">.</span><span class="nc">latex</span> <span class="nt">sub</span><span class="o">,</span> <span class="p">.</span><span class="nc">xetex</span> <span class="nt">sub</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="k">font-size</span><span class="p">:</span> <span class="mi">1</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">.</span><span class="nc">tex</span> <span class="nt">sub</span><span class="o">,</span> <span class="p">.</span><span class="nc">latex</span> <span class="nt">sub</span><span class="o">,</span> <span class="p">.</span><span class="nc">latex</span> <span class="nt">sup</span><span class="o">,</span> <span class="p">.</span><span class="nc">xetex</span> <span class="nt">sub</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="k">text-transform</span><span class="p">:</span> <span class="kc">uppercase</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">.</span><span class="nc">tex</span> <span class="nt">sub</span><span class="o">,</span> <span class="p">.</span><span class="nc">latex</span> <span class="nt">sub</span><span class="o">,</span> <span class="p">.</span><span class="nc">xetex</span> <span class="nt">sub</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="k">vertical-align</span><span class="p">:</span> <span class="mf">-0.5</span><span class="kt">ex</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">margin-left</span><span class="p">:</span> <span class="mf">-0.1667</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">margin-right</span><span class="p">:</span> <span class="mf">-0.125</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="p">.</span><span class="nc">latex</span> <span class="nt">sup</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="k">font-size</span><span class="p">:</span> <span class="mf">0.85</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">vertical-align</span><span class="p">:</span> <span class="mf">0.15</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">margin-left</span><span class="p">:</span> <span class="mf">-0.36</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">  <span class="k">margin-right</span><span class="p">:</span> <span class="mf">-0.15</span><span class="kt">em</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;/</span><span class="nt">style</span><span class="p">&gt;</span>
</span></span></code></pre></div>
<h3 id="use-the-org-macros">Use the Org macros&nbsp;<a class="headline-hash no-text-decoration" href="#use-the-org-macros">#</a></h3>


<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-org" data-lang="org"><span class="line"><span class="cl"><span class="k">- </span><span class="nb">{{{tex}}}</span>
</span></span><span class="line"><span class="cl"><span class="k">- </span><span class="nb">{{{latex}}}</span>
</span></span><span class="line"><span class="cl"><span class="k">- </span><span class="nb">{{{xetex}}}</span>
</span></span></code></pre></div><p>Export that from Org to HTML or Hugo, and you get:</p>
<ul>
<li><span class="tex">T<sub>e</sub>X</span></li>
<li><span class="latex">L<sup>a</sup>T<sub>e</sub>X</span></li>
<li><span class="xetex">X<sub>Ǝ</sub>T<sub>E</sub>X</span></li>
</ul>

<h2 id="references">References&nbsp;<a class="headline-hash no-text-decoration" href="#references">#</a></h2>


<ul>
<li><a href="https://stackoverflow.com/a/8160532/1219634">stackoverflow.com</a></li>
<li><a href="http://tess.oconnor.cx/2007/08/tex-poshlet">tess.oconnor.cx</a></li>
<li><a href="https://hroy.eu/tips/TeX/htmlAndCss/">hroy.eu</a></li>
</ul>]]></content><category scheme="https://scripter.co/categories/emacs" term="emacs" label="emacs"/><category scheme="https://scripter.co/categories/org" term="org" label="org"/><category scheme="https://scripter.co/tags/latex" term="latex" label="latex"/><category scheme="https://scripter.co/tags/html" term="html" label="html"/><category scheme="https://scripter.co/tags/hugo" term="hugo" label="hugo"/></entry></feed>