<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lidong Wang</title>
    <description>The latest articles on DEV Community by Lidong Wang (@wldkk).</description>
    <link>https://dev.to/wldkk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4101032%2F7957f082-9bb4-4cf5-96ce-f3640a28536b.jpg</url>
      <title>DEV Community: Lidong Wang</title>
      <link>https://dev.to/wldkk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wldkk"/>
    <language>en</language>
    <item>
      <title>I built a source-to-clipboard test for documentation code blocks</title>
      <dc:creator>Lidong Wang</dc:creator>
      <pubDate>Sun, 30 Aug 2026 06:26:12 +0000</pubDate>
      <link>https://dev.to/wldkk/i-built-a-source-to-clipboard-test-for-documentation-code-blocks-43gb</link>
      <guid>https://dev.to/wldkk/i-built-a-source-to-clipboard-test-for-documentation-code-blocks-43gb</guid>
      <description>&lt;p&gt;A documentation code block can render correctly while its &lt;strong&gt;Copy code&lt;/strong&gt; button silently changes the&lt;br&gt;
text. A trailing newline, a tab converted to spaces, a zero-width character, or Unicode&lt;br&gt;
normalization may be invisible on screen but still matter to a shell command, configuration file,&lt;br&gt;
or source example.&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://github.com/WLDKK/snippet-fidelity" rel="noopener noreferrer"&gt;Snippet Fidelity&lt;/a&gt; to test that narrow boundary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;canonical snippet -&amp;gt; rendered page -&amp;gt; copy handler -&amp;gt; browser clipboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It drives Chromium, activates the intended copy control, records the&lt;br&gt;
&lt;code&gt;navigator.clipboard.writeText&lt;/code&gt; payload when available, reads the browser clipboard, and compares&lt;br&gt;
both observations at Unicode code-point precision.&lt;/p&gt;

&lt;p&gt;The repository includes a synthetic adversarial fixture with one valid control and five intentional&lt;br&gt;
regressions. A local run currently produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Snippet Fidelity: 1/6 passed, 5 failed, 0 errors.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The failures cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;terminal newline changes;&lt;/li&gt;
&lt;li&gt;indentation loss;&lt;/li&gt;
&lt;li&gt;tab/space substitution;&lt;/li&gt;
&lt;li&gt;zero-width character injection;&lt;/li&gt;
&lt;li&gt;Unicode normalization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reports contain fingerprints, lengths, categorized findings, and bounded escaped context around the&lt;br&gt;
first difference. They do not print the complete expected or copied snippet by default.&lt;/p&gt;

&lt;p&gt;This is deliberately not a Markdown linter, a generic clipboard manager, or a replacement for broad&lt;br&gt;
documentation test frameworks. A linter checks source; Snippet Fidelity checks what a real rendered&lt;br&gt;
page actually copies. Source-aware configuration can use literal canonical text or an exact UTF-8&lt;br&gt;
file, while discovery mode is useful for reconnaissance.&lt;/p&gt;

&lt;p&gt;Quick start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; snippet-fidelity
npx playwright &lt;span class="nb"&gt;install &lt;/span&gt;chromium
npx snippet-fidelity audit https://docs.example.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is also a &lt;a href="https://github.com/WLDKK/snippet-fidelity/blob/main/docs/github-action.md" rel="noopener noreferrer"&gt;GitHub Action&lt;/a&gt;&lt;br&gt;
for source-aware release gates.&lt;/p&gt;

&lt;p&gt;I have used the tool to validate copy-button work in two open upstream pull requests:&lt;br&gt;
&lt;a href="https://github.com/KosmosisDire/obsidian-webpage-export/pull/751" rel="noopener noreferrer"&gt;obsidian-webpage-export #751&lt;/a&gt; and&lt;br&gt;
&lt;a href="https://github.com/nexuslabs-ai/nexus/pull/681" rel="noopener noreferrer"&gt;Nexus #681&lt;/a&gt;. Those reviews are ongoing; they are evidence&lt;br&gt;
of real integration work, not claims of upstream adoption.&lt;/p&gt;

&lt;p&gt;The project is an early public release (&lt;code&gt;v0.2.0&lt;/code&gt;) and Chromium-only today. I would especially value a&lt;br&gt;
minimal public documentation page where the visual code and copied payload disagree—or a report&lt;br&gt;
showing that the tool classified a difference incorrectly. Reproducible counterexamples will shape&lt;br&gt;
the conformance contract more usefully than feature requests in the abstract.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repository: &lt;a href="https://github.com/WLDKK/snippet-fidelity" rel="noopener noreferrer"&gt;https://github.com/WLDKK/snippet-fidelity&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;npm: &lt;a href="https://www.npmjs.com/package/snippet-fidelity" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/snippet-fidelity&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Release: &lt;a href="https://github.com/WLDKK/snippet-fidelity/releases/tag/v0.2.0" rel="noopener noreferrer"&gt;https://github.com/WLDKK/snippet-fidelity/releases/tag/v0.2.0&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>testing</category>
      <category>documentation</category>
      <category>playwright</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
