<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>writeas &amp;mdash; Kevin Sandy</title>
    <link>https://kevinsandy.com/tag:writeas</link>
    <description>Thoughts, musings, ramblings, and rants</description>
    <pubDate>Fri, 17 Apr 2026 07:51:56 +0000</pubDate>
    <image>
      <url>https://i.snap.as/IC0yYUyI.png</url>
      <title>writeas &amp;mdash; Kevin Sandy</title>
      <link>https://kevinsandy.com/tag:writeas</link>
    </image>
    <item>
      <title>Customizing Code Blocks on Write.as</title>
      <link>https://kevinsandy.com/customizing-code-blocks-on-write-as?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[I&#39;m loving the experience on Write.as so far. But, there was one thing bothering me - I wanted to make a couple adjustments to the code blocks on my posts. Specifically, I wanted to enable horizontal scrolling and add a copy button.&#xA;&#xA;!--more--&#xA;&#xA;Luckily, Write.as provides the option to enter custom CSS and JavaScript to add to your blog. I wouldn&#39;t want to make an entirely different theme this way (though several people have), but it&#39;s perfect for making small modifications like these.&#xA;&#xA;The relevant CSS customizations are below. These enable horizontal scrolling of the code block, and modify the layout and styling of the copy button that will get dynamically added.&#xA;&#xA;#post #post-body pre {&#xA;  overflow-x: auto;&#xA;  position: relative;&#xA;}&#xA;#post #post-body pre code {&#xA;  white-space: pre;&#xA;}&#xA;pre button {&#xA;  position: absolute;&#xA;  top: 4px;&#xA;  right: 4px;&#xA;  opacity: 0.5;&#xA;  border: none;&#xA;  font-family: monospace;&#xA;}&#xA;pre button:hover {&#xA;    opacity: 1.0;&#xA;}&#xA;&#xA;Here&#39;s the JavaScript code to dynamically add a copy button to the code blocks.&#xA;&#xA;if ( navigator.clipboard ) {&#xA;  let preBlocks = document.querySelectorAll(&#34;pre&#34;);&#xA;  for ( const preBlock of preBlocks ) {&#xA;    let codeBlock = preBlock.querySelector(&#34;code&#34;);&#xA;    if ( ! codeBlock ) { continue }&#xA;    let button = document.createElement(&#34;button&#34;);&#xA;    button.innerText = &#34;Copy&#34;;&#xA;    preBlock.appendChild(button);&#xA;    button.addEventListener(&#34;click&#34;, async () =  {&#xA;      await navigator.clipboard.writeText(codeBlock.innerText);&#xA;      button.innerText = &#34;Copied&#34;;&#xA;      setTimeout(() =  {button.innerText=&#34;Copy&#34;;}, 3000);&#xA;    });&#xA;  }&#xA;}&#xA;&#xA;Part of what I really like about Write.as is that the limited customization is just enough to let me tweak things as needed. With Jekyll and similar options, I feel compelled to try customizing everything instead of just writing.&#xA;&#xA;writeas]]&gt;</description>
      <content:encoded><![CDATA[<p>I&#39;m loving the experience on Write.as so far. But, there was one thing bothering me – I wanted to make a couple adjustments to the code blocks on my posts. Specifically, I wanted to enable horizontal scrolling and add a copy button.</p>



<p>Luckily, Write.as provides the option to enter custom CSS and JavaScript to add to your blog. I wouldn&#39;t want to make an entirely different theme this way (though several people have), but it&#39;s perfect for making small modifications like these.</p>

<p>The relevant CSS customizations are below. These enable horizontal scrolling of the code block, and modify the layout and styling of the copy button that will get dynamically added.</p>

<pre><code class="language-css">#post #post-body pre {
  overflow-x: auto;
  position: relative;
}
#post #post-body pre code {
  white-space: pre;
}
pre button {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0.5;
  border: none;
  font-family: monospace;
}
pre button:hover {
    opacity: 1.0;
}
</code></pre>

<p>Here&#39;s the JavaScript code to dynamically add a copy button to the code blocks.</p>

<pre><code class="language-javascript">if ( navigator.clipboard ) {
  let preBlocks = document.querySelectorAll(&#34;pre&#34;);
  for ( const preBlock of preBlocks ) {
    let codeBlock = preBlock.querySelector(&#34;code&#34;);
    if ( ! codeBlock ) { continue }
    let button = document.createElement(&#34;button&#34;);
    button.innerText = &#34;Copy&#34;;
    preBlock.appendChild(button);
    button.addEventListener(&#34;click&#34;, async () =&gt; {
      await navigator.clipboard.writeText(codeBlock.innerText);
      button.innerText = &#34;Copied&#34;;
      setTimeout(() =&gt; {button.innerText=&#34;Copy&#34;;}, 3000);
    });
  }
}
</code></pre>

<p>Part of what I really like about Write.as is that the limited customization is just enough to let me tweak things as needed. With Jekyll and similar options, I feel compelled to try customizing everything instead of just writing.</p>

<p><a href="https://kevinsandy.com/tag:writeas" class="hashtag"><span>#</span><span class="p-category">writeas</span></a></p>
]]></content:encoded>
      <guid>https://kevinsandy.com/customizing-code-blocks-on-write-as</guid>
      <pubDate>Wed, 09 Nov 2022 15:10:19 +0000</pubDate>
    </item>
  </channel>
</rss>