-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<feed xmlns="http://www.w3.org/2005/Atom"><title>Daily Scrum - Pelican</title><link href="https://blog.florijnconsultancy.nl/" rel="alternate"></link><link href="https://blog.florijnconsultancy.nl/feeds/pelican.atom.xml" rel="self"></link><id>https://blog.florijnconsultancy.nl/</id><updated>2024-02-10T15:54:00+01:00</updated><subtitle>A personal blog</subtitle><entry><title>Pelican title_capitalize plugin</title><link href="https://blog.florijnconsultancy.nl/articles/pelican-title_capitalize-plugin.html" rel="alternate"></link><published>2024-02-10T15:54:00+01:00</published><updated>2024-02-10T15:54:00+01:00</updated><author><name>Peter Florijn</name></author><id>tag:blog.florijnconsultancy.nl,2024-02-10:/articles/pelican-title_capitalize-plugin.html</id><summary type="html"></summary><content type="html"><p><span class="dquo">&#8220;</span>`python</p> | ||
<p>&rdquo;&ldquo;&rdquo; | ||
Pelican plugin to replace &ldquo;-&rdquo; with a space in an article&rsquo;s title.&nbsp;&ldquo;&rdquo;&ldquo;</p> | ||
<p>from pelican import&nbsp;signals</p> | ||
<p>def title_capitalize(generator, metadata): | ||
try: | ||
metadata[&ldquo;title&rdquo;] = metadata[&ldquo;title&rdquo;].capitalize() | ||
except KeyError:&nbsp;pass</p> | ||
<div class="highlight"><pre><span></span><code>#<span class="w"> </span><span class="nv">not</span><span class="w"> </span><span class="nv">sure</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="nv">you</span><span class="w"> </span><span class="nv">have</span><span class="w"> </span><span class="nv">to</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="nv">metadata</span>,<span class="w"> </span><span class="nv">or</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="nv">it</span><span class="w"> </span><span class="nv">is</span> | ||
#<span class="w"> </span><span class="nv">globally</span><span class="w"> </span><span class="nv">updated</span><span class="w"> </span><span class="nv">as</span><span class="w"> </span><span class="nv">it</span><span class="err">&#39;s a dictionary</span> | ||
<span class="err">return metadata</span> | ||
</code></pre></div> | ||
<feed xmlns="http://www.w3.org/2005/Atom"><title>Daily Scrum - Pelican</title><link href="https://blog.florijnconsultancy.nl/" rel="alternate"></link><link href="https://blog.florijnconsultancy.nl/feeds/pelican.atom.xml" rel="self"></link><id>https://blog.florijnconsultancy.nl/</id><updated>2024-02-10T15:54:00+01:00</updated><subtitle>A personal blog</subtitle><entry><title>Pelican title_capitalize plugin</title><link href="https://blog.florijnconsultancy.nl/articles/pelican-title_capitalize-plugin.html" rel="alternate"></link><published>2024-02-10T15:54:00+01:00</published><updated>2024-02-10T15:54:00+01:00</updated><author><name>Peter Florijn</name></author><id>tag:blog.florijnconsultancy.nl,2024-02-10:/articles/pelican-title_capitalize-plugin.html</id><summary type="html"></summary><content type="html"><div class="highlight"><pre><span></span><code><span class="sd">&quot;&quot;&quot;</span> | ||
<span class="sd">Pelican plugin to replace &quot;-&quot; with a space in an article&#39;s title.</span> | ||
<span class="sd">&quot;&quot;&quot;</span> | ||
|
||
<span class="kn">from</span> <span class="nn">pelican</span> <span class="kn">import</span> <span class="n">signals</span> | ||
|
||
<span class="k">def</span> <span class="nf">title_capitalize</span><span class="p">(</span><span class="n">generator</span><span class="p">,</span> <span class="n">metadata</span><span class="p">):</span> | ||
<span class="k">try</span><span class="p">:</span> | ||
<span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">metadata</span><span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">capitalize</span><span class="p">()</span> | ||
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span> | ||
<span class="k">pass</span> | ||
|
||
<span class="c1"># not sure if you have to return metadata, or if it is</span> | ||
<span class="c1"># globally updated as it&#39;s a dictionary</span> | ||
<span class="k">return</span> <span class="n">metadata</span> | ||
|
||
|
||
<span class="k">def</span> <span class="nf">register</span><span class="p">():</span> | ||
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Register the plugin pieces with Pelican.&quot;&quot;&quot;</span> | ||
|
||
<p>def register(): | ||
&ldquo;&rdquo;&ldquo;Register the plugin pieces with&nbsp;Pelican.&rdquo;&ldquo;&rdquo;</p> | ||
<div class="highlight"><pre><span></span><code><span class="n">signals</span><span class="o">.</span><span class="n">article_generator_context</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">title_capitalize</span><span class="p">)</span> | ||
<span class="n">signals</span><span class="o">.</span><span class="n">page_generator_context</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">title_capitalize</span><span class="p">)</span> | ||
<span class="n">signals</span><span class="o">.</span><span class="n">article_generator_context</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">title_capitalize</span><span class="p">)</span> | ||
<span class="n">signals</span><span class="o">.</span><span class="n">page_generator_context</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">title_capitalize</span><span class="p">)</span> | ||
</code></pre></div> | ||
|
||
<p>&rsquo;&lsquo;&rsquo;</p> | ||
<!-- more --></content><category term="Pelican"></category></entry></feed> |