<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://sabharwalrishabh.github.io/feed.xml" rel="self" type="application/atom+xml"/><link href="https://sabharwalrishabh.github.io/" rel="alternate" type="text/html" hreflang="en"/><updated>2026-09-14T12:17:08+00:00</updated><id>https://sabharwalrishabh.github.io/feed.xml</id><title type="html">Rishabh Sabharwal</title><subtitle>MSc Artificial Intelligence student at the University of Edinburgh. Interested in mechanistic interpretability, AI safety, and robust evaluation of LLM agents. </subtitle><entry><title type="html"></title><link href="https://sabharwalrishabh.github.io/blog/2026/2018-12-22-distill/" rel="alternate" type="text/html" title=""/><published>2026-09-14T12:17:08+00:00</published><updated>2026-09-14T12:17:08+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2026/2018-12-22-distill</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2026/2018-12-22-distill/"><![CDATA[<h2 id="citations">Citations</h2> <p>Citations are then used in the article body with the <code class="language-plaintext highlighter-rouge">&lt;d-cite&gt;</code> tag. The key attribute is a reference to the id provided in the bibliography. The key attribute can take multiple ids, separated by commas.</p> <p>The citation is presented inline like this: <d-cite key="gregor2015draw"></d-cite> (a number that displays more information on hover). If you have an appendix, a bibliography is automatically created and populated in it.</p> <p>Distill chose a numerical inline citation style to improve readability of citation dense articles and because many of the benefits of longer citations are obviated by displaying more information on hover. However, we consider it good style to mention author last names if you discuss something at length and it fits into the flow well — the authors are human and it’s nice for them to have the community associate them with their work.</p> <hr/> <h2 id="footnotes">Footnotes</h2> <p>Just wrap the text you would like to show up in a footnote in a <code class="language-plaintext highlighter-rouge">&lt;d-footnote&gt;</code> tag. The number of the footnote will be automatically generated.<d-footnote>This will become a hoverable footnote.</d-footnote></p> <hr/> <h2 id="code-blocks">Code Blocks</h2> <p>Syntax highlighting is provided within <code class="language-plaintext highlighter-rouge">&lt;d-code&gt;</code> tags. An example of inline code snippets: <code class="language-plaintext highlighter-rouge">&lt;d-code language="html"&gt;let x = 10;&lt;/d-code&gt;</code>. For larger blocks of code, add a <code class="language-plaintext highlighter-rouge">block</code> attribute:</p> <d-code block="" language="javascript"> var x = 25; function(x) { return x * x; } </d-code> <p><strong>Note:</strong> <code class="language-plaintext highlighter-rouge">&lt;d-code&gt;</code> blocks do not look good in the dark mode. You can instead use the standard Jekyll syntax highlight with the <code class="language-plaintext highlighter-rouge">highlight</code> liquid tag.</p> <figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="mi">25</span><span class="p">;</span>
<span class="kd">function</span><span class="p">(</span><span class="nx">x</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">x</span> <span class="err">\</span><span class="o">*</span> <span class="nx">x</span><span class="p">;</span>
<span class="p">}</span></code></pre></figure> <p>You can also write standard Markdown code blocks in triple ticks with a language tag, for instance:</p> <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
  <span class="k">return</span> <span class="n">x</span>
</code></pre></div></div> <hr/> <h2 id="interactive-plots">Interactive Plots</h2> <p>You can add interative plots using plotly + iframes :framed_picture:</p> <div class="l-page"> <iframe src="/assets/plotly/demo.html" frameborder="0" scrolling="no" height="500px" width="100%" style="border: 1px dashed grey;"></iframe> </div> <p>The plot must be generated separately and saved into an HTML file. To generate the plot that you see above, you can use the following code snippet:</p> <figure class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="n">pandas</span> <span class="k">as</span> <span class="n">pd</span>
<span class="kn">import</span> <span class="n">plotly.express</span> <span class="k">as</span> <span class="n">px</span>
<span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="nf">read_csv</span><span class="p">(</span>
<span class="sh">'</span><span class="s">https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv</span><span class="sh">'</span>
<span class="p">)</span>
<span class="n">fig</span> <span class="o">=</span> <span class="n">px</span><span class="p">.</span><span class="nf">density_mapbox</span><span class="p">(</span>
<span class="n">df</span><span class="p">,</span>
<span class="n">lat</span><span class="o">=</span><span class="sh">'</span><span class="s">Latitude</span><span class="sh">'</span><span class="p">,</span>
<span class="n">lon</span><span class="o">=</span><span class="sh">'</span><span class="s">Longitude</span><span class="sh">'</span><span class="p">,</span>
<span class="n">z</span><span class="o">=</span><span class="sh">'</span><span class="s">Magnitude</span><span class="sh">'</span><span class="p">,</span>
<span class="n">radius</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span>
<span class="n">center</span><span class="o">=</span><span class="nf">dict</span><span class="p">(</span><span class="n">lat</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">lon</span><span class="o">=</span><span class="mi">180</span><span class="p">),</span>
<span class="n">zoom</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">mapbox_style</span><span class="o">=</span><span class="sh">"</span><span class="s">stamen-terrain</span><span class="sh">"</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">fig</span><span class="p">.</span><span class="nf">show</span><span class="p">()</span>
<span class="n">fig</span><span class="p">.</span><span class="nf">write_html</span><span class="p">(</span><span class="sh">'</span><span class="s">assets/plotly/demo.html</span><span class="sh">'</span><span class="p">)</span></code></pre></figure> <hr/> <h2 id="details-boxes">Details boxes</h2> <p>Details boxes are collapsible boxes which hide additional information from the user. They can be added with the <code class="language-plaintext highlighter-rouge">details</code> liquid tag:</p> <details><summary>Click here to know more</summary> <p>Additional details, where math \(2x - 1\) and <code class="language-plaintext highlighter-rouge">code</code> is rendered correctly.</p> </details> <hr/> <h2 id="mermaid">Mermaid</h2> <p>This theme supports creating diagrams directly in markdown using <a href="https://mermaid.js.org/">Mermaid</a>. Mermaid enables users to render flowcharts, sequence diagrams, class diagrams, Gantt charts, and more. Simply embed the diagram syntax within a mermaid code block.</p> <p>To create a Gantt chart, you can use the following syntax:</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">mermaid
</span><span class="sb">gantt
    dateFormat  YYYY-MM-DD
    title A Gantt Diagram

    section Section
    Task A           :a1, 2025-01-01, 30d
    Task B           :after a1, 20d
    Task C           :2025-01-10, 12d</span>
<span class="p">```</span>
</code></pre></div></div> <p>And here’s how it will be rendered:</p> <pre><code class="language-mermaid">gantt
    dateFormat  YYYY-MM-DD
    title A Gantt Diagram

    section Section
    Task A           :a1, 2025-01-01, 30d
    Task B           :after a1, 20d
    Task C           :2025-01-10, 12d
</code></pre> <p>Similarly, you can also use it to create beautiful class diagrams:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>```mermaid
classDiagram
direction LR
    class Animal {
        +String species
        +int age
        +makeSound()
    }
    class Dog {
        +String breed
        +bark()
    }
    class Cat {
        +String color
        +meow()
    }
    class Bird {
        +String wingSpan
        +fly()
    }
    class Owner {
        +String name
        +int age
        +adoptAnimal(Animal animal)
    }

    Animal &lt;|-- Dog
    Animal &lt;|-- Cat
    Animal &lt;|-- Bird
    Owner "1" --&gt; "0..*" Animal

    Dog : +fetch()
    Cat : +purr()
    Bird : +sing()
```
</code></pre></div></div> <p>It will be presented as:</p> <pre><code class="language-mermaid">classDiagram
direction LR
    class Animal {
        +String species
        +int age
        +makeSound()
    }
    class Dog {
        +String breed
        +bark()
    }
    class Cat {
        +String color
        +meow()
    }
    class Bird {
        +String wingSpan
        +fly()
    }
    class Owner {
        +String name
        +int age
        +adoptAnimal(Animal animal)
    }

    Animal &lt;|-- Dog
    Animal &lt;|-- Cat
    Animal &lt;|-- Bird
    Owner "1" --&gt; "0..*" Animal

    Dog : +fetch()
    Cat : +purr()
    Bird : +sing()
</code></pre> <p>With Mermaid, you can easily add clear and dynamic diagrams to enhance your blog content.</p> <hr/> <h2 id="diff2html">Diff2Html</h2> <p>This theme also supports integrating <a href="https://github.com/rtfpessoa/diff2html">Diff2Html</a>, a tool that beautifully renders code differences (diffs) directly in markdown. Diff2Html is ideal for showcasing code changes, allowing you to clearly present additions, deletions, and modifications. It’s perfect for code reviews, documentation, and tutorials where step-by-step code changes need to be highlighted—you can even introduce changes across multiple files at once.</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">diff2html
</span><span class="sb">diff --git a/utils/mathUtils.js b/utils/mathUtils.js
index 3b5f3d1..c7f9b2e 100644
--- a/utils/mathUtils.js
+++ b/utils/mathUtils.js
@@ -1,8 +1,12 @@
-// Basic math utilities
+// Extended math utilities with additional functions

-export function calculateArea(radius) {
-    const PI = 3.14159;
+export function calculateCircleMetrics(radius) {
+    const PI = Math.PI;
     const area = PI * radius ** 2;
+    const circumference = 2 * PI * radius;
+
+    if (!isValidRadius(radius)) throw new Error("Invalid radius");
+
     return { area, circumference };
 }

-export function validateRadius(radius) {
+export function isValidRadius(radius) {
     return typeof radius === 'number' &amp;&amp; radius &gt; 0;
 }

diff --git a/main.js b/main.js
index 5f6a9c3..b7d4e8f 100644
--- a/main.js
+++ b/main.js
@@ -2,9 +2,12 @@
 import { calculateCircleMetrics } from './utils/mathUtils';

-function displayCircleMetrics(radius) {
-    const { area } = calculateCircleMetrics(radius);
+function displayCircleMetrics(radius) {
+    const { area, circumference } = calculateCircleMetrics(radius);
     console.log(`Area: ${area}`);
+    console.log(`Circumference: ${circumference}`);
 }

-displayCircleMetrics(5);
+try {
+    displayCircleMetrics(5);
+} catch (error) {
+    console.error("Error:", error.message);
+}</span>
<span class="p">```</span>
</code></pre></div></div> <p>Here’s how it will look when rendered with Diff2Html:</p> <pre><code class="language-diff2html">diff --git a/utils/mathUtils.js b/utils/mathUtils.js
index 3b5f3d1..c7f9b2e 100644
--- a/utils/mathUtils.js
+++ b/utils/mathUtils.js
@@ -1,8 +1,12 @@
-// Basic math utilities
+// Extended math utilities with additional functions

-export function calculateArea(radius) {
-    const PI = 3.14159;
+export function calculateCircleMetrics(radius) {
+    const PI = Math.PI;
     const area = PI * radius ** 2;
+    const circumference = 2 * PI * radius;
+
+    if (!isValidRadius(radius)) throw new Error("Invalid radius");
+
     return { area, circumference };
 }

-export function validateRadius(radius) {
+export function isValidRadius(radius) {
     return typeof radius === 'number' &amp;&amp; radius &gt; 0;
 }

diff --git a/main.js b/main.js
index 5f6a9c3..b7d4e8f 100644
--- a/main.js
+++ b/main.js
@@ -2,9 +2,12 @@
 import { calculateCircleMetrics } from './utils/mathUtils';

-function displayCircleMetrics(radius) {
-    const { area } = calculateCircleMetrics(radius);
+function displayCircleMetrics(radius) {
+    const { area, circumference } = calculateCircleMetrics(radius);
     console.log(`Area: ${area}`);
+    console.log(`Circumference: ${circumference}`);
 }

-displayCircleMetrics(5);
+try {
+    displayCircleMetrics(5);
+} catch (error) {
+    console.error("Error:", error.message);
+}
</code></pre> <hr/> <h2 id="leaflet">Leaflet</h2> <p><a href="https://leafletjs.com/">Leaflet</a> is created by Ukrainian software engineer <a href="https://agafonkin.com/">Volodymyr Agafonkin</a>, allowing interactive maps to be embedded in webpages. With support for <a href="https://geojson.org/">GeoJSON data</a>, Leaflet allows you to highlight specific regions, making it easy to visualize geographical information in detail.</p> <p>You can use the following code to load map information on <a href="https://www.openstreetmap.org/">OpenStreetMap</a>:</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">geojson
</span><span class="sb">{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "Crimea",
        "popupContent": "Occupied Crimea"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              33.9,
              45.3
            ],
            [
              36.5,
              45.3
            ],
            [
              36.5,
              44.4
            ],
            [
              33.9,
              44.4
            ],
            [
              33.9,
              45.3
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Donetsk",
        "popupContent": "Occupied Donetsk"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              37.5,
              48.5
            ],
            [
              39.5,
              48.5
            ],
            [
              39.5,
              47.5
            ],
            [
              37.5,
              47.5
            ],
            [
              37.5,
              48.5
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Luhansk",
        "popupContent": "Occupied Luhansk"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              38.5,
              49.5
            ],
            [
              40.5,
              49.5
            ],
            [
              40.5,
              48.5
            ],
            [
              38.5,
              48.5
            ],
            [
              38.5,
              49.5
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Kherson",
        "popupContent": "Occupied Kherson"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              32.3,
              47.3
            ],
            [
              34.3,
              47.3
            ],
            [
              34.3,
              46.3
            ],
            [
              32.3,
              46.3
            ],
            [
              32.3,
              47.3
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Zaporizhzhia",
        "popupContent": "Occupied Zaporizhzhia"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              34.3,
              48
            ],
            [
              36.3,
              48
            ],
            [
              36.3,
              47
            ],
            [
              34.3,
              47
            ],
            [
              34.3,
              48
            ]
          ]
        ]
      }
    }
  ]
}</span>
<span class="p">```</span>
</code></pre></div></div> <p>The rendered map below highlights the regions of Ukraine that have been illegally occupied by Russia over the years, including Crimea and the four eastern regions:</p> <pre><code class="language-geojson">{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "Crimea",
        "popupContent": "Occupied Crimea"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              33.9,
              45.3
            ],
            [
              36.5,
              45.3
            ],
            [
              36.5,
              44.4
            ],
            [
              33.9,
              44.4
            ],
            [
              33.9,
              45.3
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Donetsk",
        "popupContent": "Occupied Donetsk"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              37.5,
              48.5
            ],
            [
              39.5,
              48.5
            ],
            [
              39.5,
              47.5
            ],
            [
              37.5,
              47.5
            ],
            [
              37.5,
              48.5
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Luhansk",
        "popupContent": "Occupied Luhansk"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              38.5,
              49.5
            ],
            [
              40.5,
              49.5
            ],
            [
              40.5,
              48.5
            ],
            [
              38.5,
              48.5
            ],
            [
              38.5,
              49.5
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Kherson",
        "popupContent": "Occupied Kherson"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              32.3,
              47.3
            ],
            [
              34.3,
              47.3
            ],
            [
              34.3,
              46.3
            ],
            [
              32.3,
              46.3
            ],
            [
              32.3,
              47.3
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Zaporizhzhia",
        "popupContent": "Occupied Zaporizhzhia"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              34.3,
              48
            ],
            [
              36.3,
              48
            ],
            [
              36.3,
              47
            ],
            [
              34.3,
              47
            ],
            [
              34.3,
              48
            ]
          ]
        ]
      }
    }
  ]
}
</code></pre> <hr/> <h2 id="chartjs-echarts-and-vega-lite">Chartjs, Echarts and Vega-Lite</h2> <p><a href="https://www.chartjs.org/">Chart.js</a> is a versatile JavaScript library for creating responsive and interactive charts. Supporting multiple chart types like bar, line, pie, and radar, it’s an ideal tool for visualizing data directly in webpages.</p> <p>Here’s an example of a JSON-style configuration that creates a bar chart in Chart.js:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>```chartjs
{
  "type": "bar",
  "data": {
    "labels": ["2017", "2018", "2019", "2020", "2021"],
    "datasets": [
      {
        "label": "Population (millions)",
        "data": [12, 15, 13, 14, 16],
        "backgroundColor": "rgba(54, 162, 235, 0.6)",
        "borderColor": "rgba(54, 162, 235, 1)",
        "borderWidth": 1
      }
    ]
  },
  "options": {
    "scales": {
      "y": {
        "beginAtZero": true
      }
    }
  }
}
```
</code></pre></div></div> <p>The rendered bar chart illustrates population data from 2017 to 2021:</p> <pre><code class="language-chartjs">{
  "type": "bar",
  "data": {
    "labels": ["2017", "2018", "2019", "2020", "2021"],
    "datasets": [
      {
        "label": "Population (millions)",
        "data": [12, 15, 13, 14, 16],
        "backgroundColor": "rgba(54, 162, 235, 0.6)",
        "borderColor": "rgba(54, 162, 235, 1)",
        "borderWidth": 1
      }
    ]
  },
  "options": {
    "scales": {
      "y": {
        "beginAtZero": true
      }
    }
  }
}
</code></pre> <hr/> <p><a href="https://echarts.apache.org/">ECharts</a> is a powerful visualization library from <a href="https://www.apache.org/">Apache</a> that supports a wide range of interactive charts, including more advanced types such as scatter plots, heatmaps, and geographic maps.</p> <p>The following JSON configuration creates a visually enhanced line chart that displays monthly sales data for two products.</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>```echarts
{
  "title": {
    "text": "Monthly Sales Comparison",
    "left": "center"
  },
  "tooltip": {
    "trigger": "axis",
    "backgroundColor": "rgba(50, 50, 50, 0.7)",
    "borderColor": "#777",
    "borderWidth": 1,
    "textStyle": {
      "color": "#fff"
    }
  },
  "legend": {
    "data": ["Product A", "Product B"],
    "top": "10%"
  },
  "xAxis": {
    "type": "category",
    "data": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    "axisLine": {
      "lineStyle": {
        "color": "#888"
      }
    }
  },
  "yAxis": {
    "type": "value",
    "axisLine": {
      "lineStyle": {
        "color": "#888"
      }
    },
    "splitLine": {
      "lineStyle": {
        "type": "dashed"
      }
    }
  },
  "series": [
    {
      "name": "Product A",
      "type": "line",
      "smooth": true,
      "data": [820, 932, 901, 934, 1290, 1330, 1320, 1400, 1450, 1500, 1600, 1650],
      "itemStyle": {
        "color": "#5470C6"
      },
      "lineStyle": {
        "width": 3
      },
      "areaStyle": {
        "color": {
          "type": "linear",
          "x": 0,
          "y": 0,
          "x2": 0,
          "y2": 1,
          "colorStops": [
            { "offset": 0, "color": "rgba(84, 112, 198, 0.5)" },
            { "offset": 1, "color": "rgba(84, 112, 198, 0)" }
          ]
        }
      },
      "emphasis": {
        "focus": "series"
      }
    },
    {
      "name": "Product B",
      "type": "line",
      "smooth": true,
      "data": [620, 732, 701, 734, 1090, 1130, 1120, 1200, 1250, 1300, 1400, 1450],
      "itemStyle": {
        "color": "#91CC75"
      },
      "lineStyle": {
        "width": 3
      },
      "areaStyle": {
        "color": {
          "type": "linear",
          "x": 0,
          "y": 0,
          "x2": 0,
          "y2": 1,
          "colorStops": [
            { "offset": 0, "color": "rgba(145, 204, 117, 0.5)" },
            { "offset": 1, "color": "rgba(145, 204, 117, 0)" }
          ]
        }
      },
      "emphasis": {
        "focus": "series"
      }
    }
  ]
}
```
</code></pre></div></div> <p>The rendered output is shown below, and you can also interact with it using your mouse:</p> <pre><code class="language-echarts">{
  "title": {
    "text": "Monthly Sales Comparison",
    "left": "center"
  },
  "tooltip": {
    "trigger": "axis",
    "backgroundColor": "rgba(50, 50, 50, 0.7)",
    "borderColor": "#777",
    "borderWidth": 1,
    "textStyle": {
      "color": "#fff"
    }
  },
  "legend": {
    "data": ["Product A", "Product B"],
    "top": "10%"
  },
  "xAxis": {
    "type": "category",
    "data": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    "axisLine": {
      "lineStyle": {
        "color": "#888"
      }
    }
  },
  "yAxis": {
    "type": "value",
    "axisLine": {
      "lineStyle": {
        "color": "#888"
      }
    },
    "splitLine": {
      "lineStyle": {
        "type": "dashed"
      }
    }
  },
  "series": [
    {
      "name": "Product A",
      "type": "line",
      "smooth": true,
      "data": [820, 932, 901, 934, 1290, 1330, 1320, 1400, 1450, 1500, 1600, 1650],
      "itemStyle": {
        "color": "#5470C6"
      },
      "lineStyle": {
        "width": 3
      },
      "areaStyle": {
        "color": {
          "type": "linear",
          "x": 0,
          "y": 0,
          "x2": 0,
          "y2": 1,
          "colorStops": [
            { "offset": 0, "color": "rgba(84, 112, 198, 0.5)" },
            { "offset": 1, "color": "rgba(84, 112, 198, 0)" }
          ]
        }
      },
      "emphasis": {
        "focus": "series"
      }
    },
    {
      "name": "Product B",
      "type": "line",
      "smooth": true,
      "data": [620, 732, 701, 734, 1090, 1130, 1120, 1200, 1250, 1300, 1400, 1450],
      "itemStyle": {
        "color": "#91CC75"
      },
      "lineStyle": {
        "width": 3
      },
      "areaStyle": {
        "color": {
          "type": "linear",
          "x": 0,
          "y": 0,
          "x2": 0,
          "y2": 1,
          "colorStops": [
            { "offset": 0, "color": "rgba(145, 204, 117, 0.5)" },
            { "offset": 1, "color": "rgba(145, 204, 117, 0)" }
          ]
        }
      },
      "emphasis": {
        "focus": "series"
      }
    }
  ]
}
</code></pre> <hr/> <p><a href="https://vega.github.io/vega-lite/">Vega-Lite</a> is a declarative visualization grammar that allows users to create, share, and customize a wide range of interactive data visualizations. The following JSON configuration generates a straightforward bar chart:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>```vega_lite
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "width": 400,
  "height": 200,
  "padding": 5,

  "data": [
    {
      "name": "table",
      "values": [
        {"category": "A", "value": 28},
        {"category": "B", "value": 55},
        {"category": "C", "value": 43},
        {"category": "D", "value": 91},
        {"category": "E", "value": 81},
        {"category": "F", "value": 53},
        {"category": "G", "value": 19},
        {"category": "H", "value": 87}
      ]
    }
  ],

  "scales": [
    {
      "name": "xscale",
      "type": "band",
      "domain": {"data": "table", "field": "category"},
      "range": "width",
      "padding": 0.1
    },
    {
      "name": "yscale",
      "type": "linear",
      "domain": {"data": "table", "field": "value"},
      "nice": true,
      "range": "height"
    }
  ],

  "axes": [
    {"orient": "bottom", "scale": "xscale"},
    {"orient": "left", "scale": "yscale"}
  ],

  "marks": [
    {
      "type": "rect",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "x": {"scale": "xscale", "field": "category"},
          "width": {"scale": "xscale", "band": 0.8},
          "y": {"scale": "yscale", "field": "value"},
          "y2": {"scale": "yscale", "value": 0},
          "fill": {"value": "steelblue"}
        },
        "update": {
          "fillOpacity": {"value": 1}
        },
        "hover": {
          "fill": {"value": "orange"}
        }
      }
    }
  ]
}
```
</code></pre></div></div> <p>The rendered output shows a clean and simple bar chart with a hover effect：</p> <pre><code class="language-vega_lite">{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "width": 400,
  "height": 200,
  "padding": 5,

  "data": [
    {
      "name": "table",
      "values": [
        {"category": "A", "value": 28},
        {"category": "B", "value": 55},
        {"category": "C", "value": 43},
        {"category": "D", "value": 91},
        {"category": "E", "value": 81},
        {"category": "F", "value": 53},
        {"category": "G", "value": 19},
        {"category": "H", "value": 87}
      ]
    }
  ],

  "scales": [
    {
      "name": "xscale",
      "type": "band",
      "domain": {"data": "table", "field": "category"},
      "range": "width",
      "padding": 0.1
    },
    {
      "name": "yscale",
      "type": "linear",
      "domain": {"data": "table", "field": "value"},
      "nice": true,
      "range": "height"
    }
  ],

  "axes": [
    {"orient": "bottom", "scale": "xscale"},
    {"orient": "left", "scale": "yscale"}
  ],

  "marks": [
    {
      "type": "rect",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "x": {"scale": "xscale", "field": "category"},
          "width": {"scale": "xscale", "band": 0.8},
          "y": {"scale": "yscale", "field": "value"},
          "y2": {"scale": "yscale", "value": 0},
          "fill": {"value": "steelblue"}
        },
        "update": {
          "fillOpacity": {"value": 1}
        },
        "hover": {
          "fill": {"value": "orange"}
        }
      }
    }
  ]
}
</code></pre> <hr/> <h2 id="tikz">TikZ</h2> <p><a href="https://tikz.net/">TikZ</a> is a powerful LaTeX-based drawing tool powered by <a href="https://tikzjax.com/">TikZJax</a>. You can easily port TikZ drawings from papers, posters, and notes. For example, we can use the following code to illustrate Euler’s formula $ e^{i \theta} = \cos \theta + i \sin \theta $:</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/tikz"</span><span class="nt">&gt;</span>
<span class="se">\b</span>egin{tikzpicture}
    <span class="se">\f</span>illdraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);<span class="sb">

    \draw[-&gt;, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
    \draw[-&gt;, thick] (0,-2.5) -- (0,2.5) node[above] {Im};

    \draw[-&gt;, thick, color=purple] (0,0) -- (1.5,1.5);
    \node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};

    \draw[thick] (0.7,0) arc (0:45:0.7);
    \node at (0.9, 0.3) {$\theta$};

    \draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
    \draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
    \node at (2.2, 0) [below] {1};
    \node at (0, 2.2) [left] {$i$};
    \node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
</span><span class="se">\e</span>nd{tikzpicture}
<span class="nt">&lt;/script&gt;</span>
</code></pre></div></div> <p>The rendered output is shown below, displayed as a vector graphic：</p> <script type="text/tikz">
\begin{tikzpicture}
    \filldraw[fill=cyan!10, draw=blue, thick] (0,0) circle (2cm);

    \draw[->, thick] (-2.5,0) -- (2.5,0) node[right] {Re};
    \draw[->, thick] (0,-2.5) -- (0,2.5) node[above] {Im};

    \draw[->, thick, color=purple] (0,0) -- (1.5,1.5);
    \node[color=purple] at (1.1, 1.7) {$e^{i\theta}$};

    \draw[thick] (0.7,0) arc (0:45:0.7);
    \node at (0.9, 0.3) {$\theta$};

    \draw[dashed, color=gray] (1.5,1.5) -- (1.5,0) node[below, black] {$\cos \theta$};
    \draw[dashed, color=gray] (1.5,1.5) -- (0,1.5) node[left, black] {$\sin \theta$};
    \node at (2.2, 0) [below] {1};
    \node at (0, 2.2) [left] {$i$};
    \node at (1.5,1.5) [above right, color=blue] {$(\cos \theta \, \sin \theta)$};
\end{tikzpicture}
</script> <hr/> <h2 id="typograms">Typograms</h2> <p><a href="https://google.github.io/typograms/">Typograms</a> are a way of combining text and graphics to convey information in a clear and visually engaging manner. Typograms are particularly effective for illustrating simple diagrams, charts, and concept visuals where text and graphics are closely integrated. The following example demonstrates a simple Typogram:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>```typograms
             ___________________
            /                  /|
           /__________________/ |
          |                  |  |
          |     Distill      |  |
          |                  |  |
          |                  | /
          |__________________|/
```
</code></pre></div></div> <p>The rendered output is shown below：</p> <pre><code class="language-typograms">             ___________________
            /                  /|
           /__________________/ |
          |                  |  |
          |     Distill      |  |
          |                  |  |
          |                  | /
          |__________________|/
</code></pre> <hr/> <h2 id="layouts">Layouts</h2> <p>The main text column is referred to as the body. It is the assumed layout of any direct descendants of the <code class="language-plaintext highlighter-rouge">d-article</code> element.</p> <div class="fake-img l-body"> <p>.l-body</p> </div> <p>For images you want to display a little larger, try <code class="language-plaintext highlighter-rouge">.l-page</code>:</p> <div class="fake-img l-page"> <p>.l-page</p> </div> <p>All of these have an outset variant if you want to poke out from the body text a little bit. For instance:</p> <div class="fake-img l-body-outset"> <p>.l-body-outset</p> </div> <div class="fake-img l-page-outset"> <p>.l-page-outset</p> </div> <p>Occasionally you’ll want to use the full browser width. For this, use <code class="language-plaintext highlighter-rouge">.l-screen</code>. You can also inset the element a little from the edge of the browser by using the inset variant.</p> <div class="fake-img l-screen"> <p>.l-screen</p> </div> <div class="fake-img l-screen-inset"> <p>.l-screen-inset</p> </div> <p>The final layout is for marginalia, asides, and footnotes. It does not interrupt the normal flow of <code class="language-plaintext highlighter-rouge">.l-body</code> sized text except on mobile screen sizes.</p> <div class="fake-img l-gutter"> <p>.l-gutter</p> </div> <hr/> <h2 id="sidenotes">Sidenotes</h2> <p>Distill supports sidenotes, which are like footnotes but placed in the margin of the page. They are useful for providing additional context or references without interrupting the flow of the main text.</p> <p>There are two main ways to create a sidenote:</p> <p><strong>Using the <code class="language-plaintext highlighter-rouge">&lt;aside&gt;</code> tag:</strong></p> <p>The following code creates a sidenote with <strong><em>distill’s styling</em></strong> in the margin:</p> <div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;aside&gt;&lt;p&gt;</span>This is a sidenote using aside tag.<span class="nt">&lt;/p&gt;&lt;/aside&gt;</span>
</code></pre></div></div> <aside><p> This is a sidenote using `&lt;aside&gt;` tag</p> </aside> <p>We can also add images to sidenotes (click on the image to zoom in for a larger version):</p> <div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;aside&gt;</span>
  {% include figure.liquid loading="eager" path="assets/img/rhino.png" class="img-fluid rounded z-depth-1" zoomable=true %}
  <span class="nt">&lt;p&gt;</span>
    F.J. Cole, “The History of Albrecht Dürer’s Rhinoceros in Zoological Literature,” Science, Medicine, and History: Essays on the Evolution of
    Scientific Thought and Medical Practice (London, 1953), ed. E. Ashworth Underwood, 337-356. From page 71 of Edward Tufte’s Visual Explanations.
  <span class="nt">&lt;/p&gt;</span>
<span class="nt">&lt;/aside&gt;</span>
</code></pre></div></div> <aside> <figure> <picture> <source class="responsive-img-srcset" srcset="/assets/img/rhino-480.webp 480w,/assets/img/rhino-800.webp 800w,/assets/img/rhino-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/rhino.png" class="img-fluid rounded z-depth-1" width="100%" height="auto" data-zoomable="" loading="eager" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> <p>F.J. Cole, “The History of Albrecht Dürer’s Rhinoceros in Zoological Literature,” Science, Medicine, and History: Essays on the Evolution of Scientific Thought and Medical Practice (London, 1953), ed. E. Ashworth Underwood, 337-356. From page 71 of Edward Tufte’s Visual Explanations.</p> </aside> <p>Sidenotes can also contain equations and links:</p> <p>In physics, mass–energy equivalence is the relationship between mass and energy in a system’s rest frame. The two differ only by a multiplicative constant and the units of measurement.</p> <aside> <p>This principle is defined by Einstein's famous equation: $E = mc^2$ <a href="https://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence" target="_blank">(Source: Wikipedia)</a></p> </aside> <p><strong>Using the <code class="language-plaintext highlighter-rouge">l-gutter</code> class:</strong></p> <p>The following code creates a sidenote with <strong><em>al-folio’s styling</em></strong> in the margin:</p> <div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">"l-gutter"</span><span class="nt">&gt;&lt;p&gt;</span>This is a sidenote using l-gutter class.<span class="nt">&lt;/p&gt;&lt;/div&gt;</span>
</code></pre></div></div> <div class="l-gutter"> <p> This is a sidenote using `l-gutter` class. </p> </div> <hr/> <h2 id="other-typography">Other Typography?</h2> <p>Emphasis, aka italics, with <em>asterisks</em> (<code class="language-plaintext highlighter-rouge">*asterisks*</code>) or <em>underscores</em> (<code class="language-plaintext highlighter-rouge">_underscores_</code>).</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> <ol> <li>First ordered list item</li> <li>Another item ⋅⋅* Unordered sub-list.</li> <li>Actual numbers don’t matter, just that it’s a number ⋅⋅1. Ordered sub-list</li> <li>And another item.</li> </ol> <p>⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we’ll use three here to also align the raw Markdown).</p> <p>⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p> <ul> <li> <p>Unordered list can use asterisks</p> </li> <li> <p>Or minuses</p> </li> <li> <p>Or pluses</p> </li> </ul> <p><a href="https://www.google.com">I’m an inline-style link</a></p> <p><a href="https://www.google.com" title="Google's Homepage">I’m an inline-style link with title</a></p> <p><a href="https://www.mozilla.org">I’m a reference-style link</a></p> <p><a href="http://slashdot.org">You can use numbers for reference-style link definitions</a></p> <p>Or leave it empty and use the <a href="http://www.reddit.com">link text itself</a>.</p> <p>URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com or <a href="http://www.example.com">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>Here’s our logo (hover to see the title text):</p> <p>Inline-style: <img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 1"/></p> <p>Reference-style: <img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 2"/></p> <p>Inline <code class="language-plaintext highlighter-rouge">code</code> has <code class="language-plaintext highlighter-rouge">back-ticks around</code> it.</p> <div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">JavaScript syntax highlighting</span><span class="dl">"</span><span class="p">;</span>
<span class="nf">alert</span><span class="p">(</span><span class="nx">s</span><span class="p">);</span>
</code></pre></div></div> <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">s</span> <span class="o">=</span> <span class="sh">"</span><span class="s">Python syntax highlighting</span><span class="sh">"</span>
<span class="k">print</span> <span class="n">s</span>
</code></pre></div></div> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>No language indicated, so no syntax highlighting.
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
</code></pre></div></div> <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 class="language-plaintext highlighter-rouge">renders</code></td> <td><strong>nicely</strong></td> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> </tbody> </table> <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> <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>]]></content><author><name></name></author></entry><entry><title type="html"></title><link href="https://sabharwalrishabh.github.io/blog/2026/2024-01-27-code-diff/" rel="alternate" type="text/html" title=""/><published>2026-09-14T12:17:08+00:00</published><updated>2026-09-14T12:17:08+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2026/2024-01-27-code-diff</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2026/2024-01-27-code-diff/"><![CDATA[<p>scripts/hulk.js | 4 ++– src/diff2html.js | 3 +– src/file-list-printer.js | 11 ++++++++— src/hoganjs-utils.js | 29 +++++++++++++++++———— src/html-printer.js | 6 ++++++ src/line-by-line-printer.js | 6 +++++- src/side-by-side-printer.js | 6 +++++- test/file-list-printer-tests.js | 2 +- test/hogan-cache-tests.js | 18 +++++++++++++++— test/line-by-line-tests.js | 3 +– test/side-by-side-printer-tests.js | 3 +– 11 files changed, 62 insertions(+), 29 deletions(-)</p> <p>diff –git a/scripts/hulk.js b/scripts/hulk.js index 5a793c18..a4b1a4d5 100755 — a/scripts/hulk.js +++ b/scripts/hulk.js @@ -173,11 +173,11 @@ function namespace(name) { // write a template foreach file that matches template extension templates = extractFiles(options.argv.remain) .map(function(file) {</p> <ul> <li>var openedFile = fs.readFileSync(file, ‘utf-8’);</li> <li>var openedFile = fs.readFileSync(file, ‘utf-8’).trim(); var name; if (!openedFile) return; name = namespace(path.basename(file).replace(/..*$/, ‘’));</li> <li>openedFile = removeByteOrderMark(openedFile.trim());</li> <li>openedFile = removeByteOrderMark(openedFile); openedFile = wrap(file, name, openedFile); if (!options.outputdir) return openedFile; fs.writeFileSync(path.join(options.outputdir, name + ‘.js’) diff –git a/src/diff2html.js b/src/diff2html.js index 21b0119e..64e138f5 100644 — a/src/diff2html.js +++ b/src/diff2html.js @@ -7,7 +7,6 @@</li> </ul> <p>(function() { var diffParser = require(‘./diff-parser.js’).DiffParser;</p> <ul> <li> <p>var fileLister = require(‘./file-list-printer.js’).FileListPrinter; var htmlPrinter = require(‘./html-printer.js’).HtmlPrinter;</p> <p>function Diff2Html() { @@ -43,7 +42,7 @@</p> <p>var fileList = ‘’; if (configOrEmpty.showFiles === true) {</p> </li> <li>fileList = fileLister.generateFileList(diffJson, configOrEmpty);</li> <li>fileList = htmlPrinter.generateFileListSummary(diffJson, configOrEmpty); }</li> </ul> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> var diffOutput = ''; diff --git a/src/file-list-printer.js b/src/file-list-printer.js index e408d9b2..1e0a2c61 100644 --- a/src/file-list-printer.js +++ b/src/file-list-printer.js @@ -8,11 +8,16 @@  (function() {    var printerUtils = require('./printer-utils.js').PrinterUtils;
</code></pre></div></div> <ul> <li>var hoganUtils = require(‘./hoganjs-utils.js’).HoganJsUtils;</li> <li> <p>var hoganUtils; + var baseTemplatesPath = ‘file-summary’; var iconsBaseTemplatesPath = ‘icon’;</p> </li> <li>function FileListPrinter() {</li> <li>function FileListPrinter(config) {</li> <li>this.config = config; +</li> <li>var HoganJsUtils = require(‘./hoganjs-utils.js’).HoganJsUtils;</li> <li>hoganUtils = new HoganJsUtils(config); }</li> </ul> <p>FileListPrinter.prototype.generateFileList = function(diffFiles) { @@ -38,5 +43,5 @@ }); };</p> <ul> <li>module.exports.FileListPrinter = new FileListPrinter();</li> <li> <p>module.exports.FileListPrinter = FileListPrinter; })(); diff –git a/src/hoganjs-utils.js b/src/hoganjs-utils.js index 9949e5fa..0dda08d7 100644 — a/src/hoganjs-utils.js +++ b/src/hoganjs-utils.js @@ -8,18 +8,19 @@ (function() { var fs = require(‘fs’); var path = require(‘path’); - var hogan = require(‘hogan.js’);</p> <p>var hoganTemplates = require(‘./templates/diff2html-templates.js’);</p> </li> <li>var templatesPath = path.resolve(__dirname, ‘templates’);</li> <li> <p>var extraTemplates;</p> </li> <li>function HoganJsUtils() {</li> <li>function HoganJsUtils(configuration) {</li> <li> <table> <tbody> <tr> <td>this.config = configuration</td> <td> </td> <td>{};</td> </tr> </tbody> </table> </li> <li> <p>extraTemplates = this.config.templates || {}; }</p> </li> <li>HoganJsUtils.prototype.render = function(namespace, view, params, configuration) {</li> <li>var template = this.template(namespace, view, configuration);</li> <li>HoganJsUtils.prototype.render = function(namespace, view, params) {</li> <li> <p>var template = this.template(namespace, view); if (template) { return template.render(params); } @@ -27,17 +28,16 @@ return null; };</p> </li> <li>HoganJsUtils.prototype.template = function(namespace, view, configuration) {</li> <li> <table> <tbody> <tr> <td>var config = configuration</td> <td> </td> <td>{};</td> </tr> </tbody> </table> </li> <li> <p>HoganJsUtils.prototype.template = function(namespace, view) { var templateKey = this._templateKey(namespace, view);</p> </li> <li>return this._getTemplate(templateKey, config);</li> <li> <p>return this._getTemplate(templateKey); };</p> </li> <li>HoganJsUtils.prototype._getTemplate = function(templateKey, config) {</li> <li> <p>HoganJsUtils.prototype._getTemplate = function(templateKey) { var template;</p> </li> <li>if (!config.noCache) {</li> <li>if (!this.config.noCache) { template = this._readFromCache(templateKey); }</li> </ul> <p>@@ -53,6 +53,7 @@</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> try {
   if (fs.readFileSync) { +        var templatesPath = path.resolve(__dirname, 'templates');
     var templatePath = path.join(templatesPath, templateKey);
     var templateContent = fs.readFileSync(templatePath + '.mustache', 'utf8');
     template = hogan.compile(templateContent); @@ -66,12 +67,16 @@    };
</code></pre></div></div> <p>HoganJsUtils.prototype._readFromCache = function(templateKey) {</p> <ul> <li>return hoganTemplates[templateKey];</li> <li>return extraTemplates[templateKey] || hoganTemplates[templateKey]; };</li> </ul> <p>HoganJsUtils.prototype._templateKey = function(namespace, view) { return namespace + ‘-‘ + view; };</p> <ul> <li>module.exports.HoganJsUtils = new HoganJsUtils();</li> <li>HoganJsUtils.prototype.compile = function(templateStr) {</li> <li>return hogan.compile(templateStr);</li> <li>}; +</li> <li>module.exports.HoganJsUtils = HoganJsUtils; })(); diff –git a/src/html-printer.js b/src/html-printer.js index 585d5b66..13f83047 100644 — a/src/html-printer.js +++ b/src/html-printer.js @@ -8,6 +8,7 @@ (function() { var LineByLinePrinter = require(‘./line-by-line-printer.js’).LineByLinePrinter; var SideBySidePrinter = require(‘./side-by-side-printer.js’).SideBySidePrinter;</li> <li> <p>var FileListPrinter = require(‘./file-list-printer.js’).FileListPrinter;</p> <p>function HtmlPrinter() { } @@ -22,5 +23,10 @@ return sideBySidePrinter.generateSideBySideJsonHtml(diffFiles); };</p> </li> <li>HtmlPrinter.prototype.generateFileListSummary = function(diffJson, config) {</li> <li>var fileListPrinter = new FileListPrinter(config);</li> <li>return fileListPrinter.generateFileList(diffJson);</li> <li> <p>}; + module.exports.HtmlPrinter = new HtmlPrinter(); })(); diff –git a/src/line-by-line-printer.js b/src/line-by-line-printer.js index b07eb53c..d230bedd 100644 — a/src/line-by-line-printer.js +++ b/src/line-by-line-printer.js @@ -11,7 +11,8 @@ var utils = require(‘./utils.js’).Utils; var Rematch = require(‘./rematch.js’).Rematch;</p> </li> <li>var hoganUtils = require(‘./hoganjs-utils.js’).HoganJsUtils;</li> <li> <p>var hoganUtils; + var genericTemplatesPath = ‘generic’; var baseTemplatesPath = ‘line-by-line’; var iconsBaseTemplatesPath = ‘icon’; @@ -19,6 +20,9 @@</p> <p>function LineByLinePrinter(config) { this.config = config; +</p> </li> <li>var HoganJsUtils = require(‘./hoganjs-utils.js’).HoganJsUtils;</li> <li>hoganUtils = new HoganJsUtils(config); }</li> </ul> <p>LineByLinePrinter.prototype.makeFileDiffHtml = function(file, diffs) { diff –git a/src/side-by-side-printer.js b/src/side-by-side-printer.js index bbf1dc8d..5e3033b3 100644 — a/src/side-by-side-printer.js +++ b/src/side-by-side-printer.js @@ -11,7 +11,8 @@ var utils = require(‘./utils.js’).Utils; var Rematch = require(‘./rematch.js’).Rematch;</p> <ul> <li>var hoganUtils = require(‘./hoganjs-utils.js’).HoganJsUtils;</li> <li> <p>var hoganUtils; + var genericTemplatesPath = ‘generic’; var baseTemplatesPath = ‘side-by-side’; var iconsBaseTemplatesPath = ‘icon’; @@ -26,6 +27,9 @@</p> <p>function SideBySidePrinter(config) { this.config = config; +</p> </li> <li>var HoganJsUtils = require(‘./hoganjs-utils.js’).HoganJsUtils;</li> <li>hoganUtils = new HoganJsUtils(config); }</li> </ul> <p>SideBySidePrinter.prototype.makeDiffHtml = function(file, diffs) { diff –git a/test/file-list-printer-tests.js b/test/file-list-printer-tests.js index a502a46f..60ea3208 100644 — a/test/file-list-printer-tests.js +++ b/test/file-list-printer-tests.js @@ -1,6 +1,6 @@ var assert = require(‘assert’);</p> <p>-var fileListPrinter = require(‘../src/file-list-printer.js’).FileListPrinter; +var fileListPrinter = new (require(‘../src/file-list-printer.js’).FileListPrinter)();</p> <p>describe(‘FileListPrinter’, function() { describe(‘generateFileList’, function() { diff –git a/test/hogan-cache-tests.js b/test/hogan-cache-tests.js index 190bf6f8..3bb754ac 100644 — a/test/hogan-cache-tests.js +++ b/test/hogan-cache-tests.js @@ -1,6 +1,6 @@ var assert = require(‘assert’);</p> <p>-var HoganJsUtils = require(‘../src/hoganjs-utils.js’).HoganJsUtils; +var HoganJsUtils = new (require(‘../src/hoganjs-utils.js’).HoganJsUtils)(); var diffParser = require(‘../src/diff-parser.js’).DiffParser;</p> <p>describe(‘HoganJsUtils’, function() { @@ -21,16 +21,28 @@ describe(‘HoganJsUtils’, function() { }); assert.equal(emptyDiffHtml, result); }); + it(‘should render view without cache’, function() { var result = HoganJsUtils.render(‘generic’, ‘empty-diff’, { contentClass: ‘d2h-code-line’, diffParser: diffParser }, {noCache: true});</p> <ul> <li>assert.equal(emptyDiffHtml + ‘\n’, result);</li> <li>assert.equal(emptyDiffHtml, result); }); + it(‘should return null if template is missing’, function() {</li> <li>var result = HoganJsUtils.render(‘generic’, ‘missing-template’, {}, {noCache: true});</li> <li>var hoganUtils = new (require(‘../src/hoganjs-utils.js’).HoganJsUtils)({noCache: true});</li> <li>var result = hoganUtils.render(‘generic’, ‘missing-template’, {}); assert.equal(null, result); }); +</li> <li>it(‘should allow templates to be overridden’, function() {</li> <li>var emptyDiffTemplate = HoganJsUtils.compile(‘&lt;p&gt;&lt;/p&gt;’); +</li> <li>var config = {templates: {‘generic-empty-diff’: emptyDiffTemplate}};</li> <li>var hoganUtils = new (require(‘../src/hoganjs-utils.js’).HoganJsUtils)(config);</li> <li>var result = hoganUtils.render(‘generic’, ‘empty-diff’, {myName: ‘Rodrigo Fernandes’});</li> <li>assert.equal(‘&lt;p&gt;Rodrigo Fernandes&lt;/p&gt;’, result);</li> <li>}); }); }); diff –git a/test/line-by-line-tests.js b/test/line-by-line-tests.js index 1cd92073..8869b3df 100644 — a/test/line-by-line-tests.js +++ b/test/line-by-line-tests.js @@ -14,7 +14,7 @@ describe(‘LineByLinePrinter’, function() { ‘ File without changes\n’ + ‘ &lt;/div&gt;\n’ + ‘ &lt;/td&gt;\n’ +</li> <li>’&lt;/tr&gt;\n’;</li> <li>’&lt;/tr&gt;’;</li> </ul> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>   assert.equal(expected, fileHtml);
 }); @@ -422,7 +422,6 @@ describe('LineByLinePrinter', function() {
     '        &lt;/div&gt;\n' +
     '    &lt;/td&gt;\n' +
     '&lt;/tr&gt;\n' + -        '\n' +
     '                &lt;/tbody&gt;\n' +
     '            &lt;/table&gt;\n' +
     '        &lt;/div&gt;\n' + diff --git a/test/side-by-side-printer-tests.js b/test/side-by-side-printer-tests.js index 76625f8e..771daaa5 100644 --- a/test/side-by-side-printer-tests.js +++ b/test/side-by-side-printer-tests.js @@ -14,7 +14,7 @@ describe('SideBySidePrinter', function() {
     '            File without changes\n' +
     '        &lt;/div&gt;\n' +
     '    &lt;/td&gt;\n' + -        '&lt;/tr&gt;\n'; +        '&lt;/tr&gt;';

   assert.equal(expectedRight, fileHtml.right);
   assert.equal(expectedLeft, fileHtml.left); @@ -324,7 +324,6 @@ describe('SideBySidePrinter', function() {
     '        &lt;/div&gt;\n' +
     '    &lt;/td&gt;\n' +
     '&lt;/tr&gt;\n' + -        '\n' +
     '                    &lt;/tbody&gt;\n' +
     '                &lt;/table&gt;\n' +
     '            &lt;/div&gt;\n' +
</code></pre></div></div> <p>From f3cadb96677d0eb82fc2752dc3ffbf35ca9b5bdb Mon Sep 17 00:00:00 2001 From: Rodrigo Fernandes <a href="mailto:rtfrodrigo@gmail.com">rtfrodrigo@gmail.com</a> Date: Sat, 15 Oct 2016 13:21:22 +0100 Subject: [PATCH 2/2] Allow uncompiled templates</p> <hr/> <p>README.md | 3 +++ src/hoganjs-utils.js | 7 +++++++ test/hogan-cache-tests.js | 24 +++++++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-)</p> <p>diff –git a/README.md b/README.md index 132c8a28..46909f25 100644 — a/README.md +++ b/README.md @@ -98,6 +98,9 @@ The HTML output accepts a Javascript object with configuration. Possible options</p> <ul> <li><code class="language-plaintext highlighter-rouge">synchronisedScroll</code>: scroll both panes in side-by-side mode: <code class="language-plaintext highlighter-rouge">true</code> or <code class="language-plaintext highlighter-rouge">false</code>, default is <code class="language-plaintext highlighter-rouge">false</code></li> <li><code class="language-plaintext highlighter-rouge">matchWordsThreshold</code>: similarity threshold for word matching, default is 0.25</li> <li><code class="language-plaintext highlighter-rouge">matchingMaxComparisons</code>: perform at most this much comparisons for line matching a block of changes, default is <code class="language-plaintext highlighter-rouge">2500</code></li> <li> <ul> <li><code class="language-plaintext highlighter-rouge">templates</code>: object with previously compiled templates to replace parts of the html</li> </ul> </li> <li> <ul> <li><code class="language-plaintext highlighter-rouge">rawTemplates</code>: object with raw not compiled templates to replace parts of the html</li> </ul> </li> <li> <blockquote> <p>For more information regarding the possible templates look into <a href="https://github.com/rtfpessoa/diff2html/tree/master/src/templates">src/templates</a></p> </blockquote> </li> </ul> <p>## Diff2HtmlUI Helper</p> <p>diff –git a/src/hoganjs-utils.js b/src/hoganjs-utils.js index 0dda08d7..b2e9c275 100644 — a/src/hoganjs-utils.js +++ b/src/hoganjs-utils.js @@ -17,6 +17,13 @@ function HoganJsUtils(configuration) { this.config = configuration || {}; extraTemplates = this.config.templates || {}; +</p> <ul> <li> <table> <tbody> <tr> <td>var rawTemplates = this.config.rawTemplates</td> <td> </td> <td>{};</td> </tr> </tbody> </table> </li> <li>for (var templateName in rawTemplates) {</li> <li>if (rawTemplates.hasOwnProperty(templateName)) {</li> <li>if (!extraTemplates[templateName]) extraTemplates[templateName] = this.compile(rawTemplates[templateName]);</li> <li>}</li> <li>} }</li> </ul> <p>HoganJsUtils.prototype.render = function(namespace, view, params) { diff –git a/test/hogan-cache-tests.js b/test/hogan-cache-tests.js index 3bb754ac..a34839c0 100644 — a/test/hogan-cache-tests.js +++ b/test/hogan-cache-tests.js @@ -36,7 +36,7 @@ describe(‘HoganJsUtils’, function() { assert.equal(null, result); });</p> <ul> <li>it(‘should allow templates to be overridden’, function() {</li> <li> <p>it(‘should allow templates to be overridden with compiled templates’, function() { var emptyDiffTemplate = HoganJsUtils.compile(‘&lt;p&gt;&lt;/p&gt;’);</p> <p>var config = {templates: {‘generic-empty-diff’: emptyDiffTemplate}}; @@ -44,5 +44,27 @@ describe(‘HoganJsUtils’, function() { var result = hoganUtils.render(‘generic’, ‘empty-diff’, {myName: ‘Rodrigo Fernandes’}); assert.equal(‘&lt;p&gt;Rodrigo Fernandes&lt;/p&gt;’, result); }); +</p> </li> <li>it(‘should allow templates to be overridden with uncompiled templates’, function() {</li> <li>var emptyDiffTemplate = ‘&lt;p&gt;&lt;/p&gt;’; +</li> <li>var config = {rawTemplates: {‘generic-empty-diff’: emptyDiffTemplate}};</li> <li>var hoganUtils = new (require(‘../src/hoganjs-utils.js’).HoganJsUtils)(config);</li> <li>var result = hoganUtils.render(‘generic’, ‘empty-diff’, {myName: ‘Rodrigo Fernandes’});</li> <li>assert.equal(‘&lt;p&gt;Rodrigo Fernandes&lt;/p&gt;’, result);</li> <li>}); +</li> <li>it(‘should allow templates to be overridden giving priority to compiled templates’, function() {</li> <li>var emptyDiffTemplate = HoganJsUtils.compile(‘&lt;p&gt;&lt;/p&gt;’);</li> <li>var emptyDiffTemplateUncompiled = ‘&lt;p&gt;Not used!&lt;/p&gt;’; +</li> <li>var config = {</li> <li>templates: {‘generic-empty-diff’: emptyDiffTemplate},</li> <li>rawTemplates: {‘generic-empty-diff’: emptyDiffTemplateUncompiled}</li> <li>};</li> <li>var hoganUtils = new (require(‘../src/hoganjs-utils.js’).HoganJsUtils)(config);</li> <li>var result = hoganUtils.render(‘generic’, ‘empty-diff’, {myName: ‘Rodrigo Fernandes’});</li> <li>assert.equal(‘&lt;p&gt;Rodrigo Fernandes&lt;/p&gt;’, result);</li> <li>}); }); }); ```</li> </ul>]]></content><author><name></name></author></entry><entry><title type="html"></title><link href="https://sabharwalrishabh.github.io/blog/2026/2024-12-04-photo-gallery/" rel="alternate" type="text/html" title=""/><published>2026-09-14T12:17:08+00:00</published><updated>2026-09-14T12:17:08+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2026/2024-12-04-photo-gallery</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2026/2024-12-04-photo-gallery/"><![CDATA[<h2 id="photoswipe"><a href="https://photoswipe.com/">PhotoSwipe</a></h2> <div class="pswp-gallery pswp-gallery--single-column" id="gallery--getting-started"> <a href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-2500.jpg" data-pswp-width="1669" data-pswp-height="2500" target="_blank"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-200.jpg" alt=""/> </a> <a href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/7/img-2500.jpg" data-pswp-width="1875" data-pswp-height="2500" data-cropped="true" target="_blank"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/7/img-200.jpg" alt=""/> </a> <a href="https://unsplash.com" data-pswp-src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-2500.jpg" data-pswp-width="2500" data-pswp-height="1666" target="_blank"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-200.jpg" alt=""/> </a> <div> <a href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/6/img-2500.jpg" data-pswp-width="2500" data-pswp-height="1667" target="_blank"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/6/img-200.jpg" alt=""/> </a> </div> </div> <hr/> <h2 id="spotlight-js"><a href="https://nextapps-de.github.io/spotlight/">Spotlight JS</a></h2> <div class="spotlight-group"> <a class="spotlight" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/1/img-2500.jpg"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/1/img-200.jpg"/> </a> <a class="spotlight" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-2500.jpg"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-200.jpg"/> </a> <a class="spotlight" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-2500.jpg"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-200.jpg"/> </a> </div> <div class="spotlight-group"> <a class="spotlight" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/4/img-2500.jpg"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/4/img-200.jpg"/> </a> <a class="spotlight" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/5/img-2500.jpg"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/5/img-200.jpg"/> </a> <a class="spotlight" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/6/img-2500.jpg"> <img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/6/img-200.jpg"/> </a> </div> <hr/> <h2 id="venobox"><a href="https://veno.es/venobox/">Venobox</a></h2> <p><a class="venobox" data-gall="myGallery" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/1/img-2500.jpg"><img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/1/img-200.jpg"/></a> <a class="venobox" data-gall="myGallery" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-2500.jpg"><img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/2/img-200.jpg"/></a> <a class="venobox" data-gall="myGallery" href="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-2500.jpg"><img src="https://cdn.photoswipe.com/photoswipe-demo-images/photos/3/img-200.jpg"/></a></p>]]></content><author><name></name></author></entry><entry><title type="html">Plotly</title><link href="https://sabharwalrishabh.github.io/blog/2025/plotly/" rel="alternate" type="text/html" title="Plotly"/><published>2025-03-26T00:00:00+00:00</published><updated>2025-03-26T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2025/plotly</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2025/plotly/"><![CDATA[<hr/> <p>layout: post title: a post with plotly.js date: 2025-03-26 14:24:00 description: this is what included plotly.js code could look like tags: formatting charts categories: sample-posts chart: plotly: true published: false—</p> <p>This is an example post with some <a href="https://plotly.com/javascript/">plotly</a> code.</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">plotly
</span><span class="sb">{
  "data": [
    {
      "x": [1, 2, 3, 4],
      "y": [10, 15, 13, 17],
      "type": "scatter"
    },
    {
      "x": [1, 2, 3, 4],
      "y": [16, 5, 11, 9],
      "type": "scatter"
    }
  ]
}</span>
<span class="p">```</span>
</code></pre></div></div> <p>Which generates:</p> <pre><code class="language-plotly">{
  "data": [
    {
      "x": [1, 2, 3, 4],
      "y": [10, 15, 13, 17],
      "type": "scatter"
    },
    {
      "x": [1, 2, 3, 4],
      "y": [16, 5, 11, 9],
      "type": "scatter"
    }
  ]
}
</code></pre> <p>Also another example chart.</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">plotly
</span><span class="sb">{
  "data": [
    {
      "x": [1, 2, 3, 4],
      "y": [10, 15, 13, 17],
      "mode": "markers"
    },
    {
      "x": [2, 3, 4, 5],
      "y": [16, 5, 11, 9],
      "mode": "lines"
    },
    {
      "x": [1, 2, 3, 4],
      "y": [12, 9, 15, 12],
      "mode": "lines+markers"
    }
  ],
  "layout": {
    "title": {
      "text": "Line and Scatter Plot"
    }
  }
}</span>
<span class="p">```</span>
</code></pre></div></div> <p>This is how it looks like:</p> <pre><code class="language-plotly">{
  "data": [
    {
      "x": [1, 2, 3, 4],
      "y": [10, 15, 13, 17],
      "mode": "markers"
    },
    {
      "x": [2, 3, 4, 5],
      "y": [16, 5, 11, 9],
      "mode": "lines"
    },
    {
      "x": [1, 2, 3, 4],
      "y": [12, 9, 15, 12],
      "mode": "lines+markers"
    }
  ],
  "layout": {
    "title": {
      "text": "Line and Scatter Plot"
    }
  }
}
</code></pre>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post with plotly.js date: 2025-03-26 14:24:00 description: this is what included plotly.js code could look like tags: formatting charts categories: sample-posts chart: plotly: true published: false—]]></summary></entry><entry><title type="html">Tabs</title><link href="https://sabharwalrishabh.github.io/blog/2024/tabs/" rel="alternate" type="text/html" title="Tabs"/><published>2024-05-01T00:00:00+00:00</published><updated>2024-05-01T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2024/tabs</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2024/tabs/"><![CDATA[<hr/> <p>layout: post title: a post with tabs date: 2024-05-01 00:32:13 description: this is what included tabs in a post could look like tags: formatting code categories: sample-posts tabs: true published: false—</p> <p>This is how a post with <a href="https://github.com/Ovski4/jekyll-tabs">tabs</a> looks like. Note that the tabs could be used for different purposes, not only for code.</p> <h2 id="first-tabs">First tabs</h2> <p>To add tabs, use the following syntax:</p> <div class="language-liquid highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">{%</span><span class="w"> </span><span class="nt">tabs</span><span class="w"> </span><span class="nv">group-name</span><span class="w"> </span><span class="cp">%}</span>

<span class="cp">{%</span><span class="w"> </span><span class="nt">tab</span><span class="w"> </span><span class="nv">group-name</span><span class="w"> </span><span class="nv">tab-name-1</span><span class="w"> </span><span class="cp">%}</span>

Content 1

<span class="cp">{%</span><span class="w"> </span><span class="nt">endtab</span><span class="w"> </span><span class="cp">%}</span>

<span class="cp">{%</span><span class="w"> </span><span class="nt">tab</span><span class="w"> </span><span class="nv">group-name</span><span class="w"> </span><span class="nv">tab-name-2</span><span class="w"> </span><span class="cp">%}</span>

Content 2

<span class="cp">{%</span><span class="w"> </span><span class="nt">endtab</span><span class="w"> </span><span class="cp">%}</span>

<span class="cp">{%</span><span class="w"> </span><span class="nt">endtabs</span><span class="w"> </span><span class="cp">%}</span>
</code></pre></div></div> <p>With this you can generate visualizations like:</p> <ul id="log" class="tab" data-tab="26015c37-2820-4cef-aaf3-b098443a23f1" data-name="log"> <li class="active" id="log-php"> <a href="#">php </a> </li> <li id="log-js"> <a href="#">js </a> </li> <li id="log-ruby"> <a href="#">ruby </a> </li> </ul> <ul class="tab-content" id="26015c37-2820-4cef-aaf3-b098443a23f1" data-name="log"> <li class="active"> <div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">var_dump</span><span class="p">(</span><span class="s1">'hello'</span><span class="p">);</span>
</code></pre></div></div> </li> <li> <div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">console</span><span class="p">.</span><span class="nf">log</span><span class="p">(</span><span class="dl">"</span><span class="s2">hello</span><span class="dl">"</span><span class="p">);</span>
</code></pre></div></div> </li> <li> <div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">pputs</span> <span class="dl">'</span><span class="s1">hello</span><span class="dl">'</span>
</code></pre></div></div> </li> </ul> <h2 id="another-example">Another example</h2> <ul id="data-struct" class="tab" data-tab="b89c0cbd-0263-43a9-a922-bddec746294c" data-name="data-struct"> <li class="active" id="data-struct-yaml"> <a href="#">yaml </a> </li> <li id="data-struct-json"> <a href="#">json </a> </li> </ul> <ul class="tab-content" id="b89c0cbd-0263-43a9-a922-bddec746294c" data-name="data-struct"> <li class="active"> <div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">hello</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="s2">"</span><span class="s">whatsup"</span>
  <span class="pi">-</span> <span class="s2">"</span><span class="s">hi"</span>
</code></pre></div></div> </li> <li> <div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"hello"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"whatsup"</span><span class="p">,</span><span class="w"> </span><span class="s2">"hi"</span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div> </li> </ul> <h2 id="tabs-for-something-else">Tabs for something else</h2> <ul id="something-else" class="tab" data-tab="21b5c294-bc4e-4b9c-bfae-9654a989ef05" data-name="something-else"> <li class="active" id="something-else-text"> <a href="#">text </a> </li> <li id="something-else-quote"> <a href="#">quote </a> </li> <li id="something-else-list"> <a href="#">list </a> </li> </ul> <ul class="tab-content" id="21b5c294-bc4e-4b9c-bfae-9654a989ef05" data-name="something-else"> <li class="active"> <p>Regular text</p> </li> <li> <blockquote> <p>A quote</p> </blockquote> </li> <li> <p>Hipster list</p> <ul> <li>brunch</li> <li>fixie</li> <li>raybans</li> <li>messenger bag</li> </ul> </li> </ul>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post with tabs date: 2024-05-01 00:32:13 description: this is what included tabs in a post could look like tags: formatting code categories: sample-posts tabs: true published: false—]]></summary></entry><entry><title type="html">Typograms</title><link href="https://sabharwalrishabh.github.io/blog/2024/typograms/" rel="alternate" type="text/html" title="Typograms"/><published>2024-04-29T00:00:00+00:00</published><updated>2024-04-29T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2024/typograms</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2024/typograms/"><![CDATA[<hr/> <p>layout: post title: a post with typograms date: 2024-04-29 23:36:10 description: this is what included typograms code could look like tags: formatting diagrams categories: sample-posts typograms: true published: false—</p> <p>This is an example post with some <a href="https://github.com/google/typograms/">typograms</a> code.</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">typograms
</span><span class="sb">+----+
|    |---&gt; My first diagram!
+----+</span>
<span class="p">```</span>
</code></pre></div></div> <p>Which generates:</p> <pre><code class="language-typograms">+----+
|    |---&gt; My first diagram!
+----+
</code></pre> <p>Another example:</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">typograms
</span><span class="sb">.------------------------.
|.----------------------.|
||"https://example.com" ||
|'----------------------'|
| ______________________ |
||                      ||
||   Welcome!           ||
||                      ||
||                      ||
||  .----------------.  ||
||  | username       |  ||
||  '----------------'  ||
||  .----------------.  ||
||  |"*******"       |  ||
||  '----------------'  ||
||                      ||
||  .----------------.  ||
||  |   "Sign-up"    |  ||
||  '----------------'  ||
||                      ||
|+----------------------+|
.------------------------.</span>
<span class="p">```</span>
</code></pre></div></div> <p>which generates:</p> <pre><code class="language-typograms">.------------------------.
|.----------------------.|
||"https://example.com" ||
|'----------------------'|
| ______________________ |
||                      ||
||   Welcome!           ||
||                      ||
||                      ||
||  .----------------.  ||
||  | username       |  ||
||  '----------------'  ||
||  .----------------.  ||
||  |"*******"       |  ||
||  '----------------'  ||
||                      ||
||  .----------------.  ||
||  |   "Sign-up"    |  ||
||  '----------------'  ||
||                      ||
|+----------------------+|
.------------------------.
</code></pre> <p>For more examples, check out the <a href="https://google.github.io/typograms/#examples">typograms documentation</a>.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post with typograms date: 2024-04-29 23:36:10 description: this is what included typograms code could look like tags: formatting diagrams categories: sample-posts typograms: true published: false—]]></summary></entry><entry><title type="html">Post Citation</title><link href="https://sabharwalrishabh.github.io/blog/2024/post-citation/" rel="alternate" type="text/html" title="Post Citation"/><published>2024-04-28T00:00:00+00:00</published><updated>2024-04-28T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2024/post-citation</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2024/post-citation/"><![CDATA[<hr/> <p>layout: post title: a post that can be cited date: 2024-04-28 15:06:00 description: this is what a post that can be cited looks like tags: formatting citation categories: sample-posts citation: true published: false—</p> <p>This is an example post that can be cited. The content of the post ends here, while the citation information is automatically provided below. The only thing needed is for you to set the <code class="language-plaintext highlighter-rouge">citation</code> key in the front matter to <code class="language-plaintext highlighter-rouge">true</code>.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post that can be cited date: 2024-04-28 15:06:00 description: this is what a post that can be cited looks like tags: formatting citation categories: sample-posts citation: true published: false—]]></summary></entry><entry><title type="html">Pseudocode</title><link href="https://sabharwalrishabh.github.io/blog/2024/pseudocode/" rel="alternate" type="text/html" title="Pseudocode"/><published>2024-04-15T00:00:00+00:00</published><updated>2024-04-15T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2024/pseudocode</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2024/pseudocode/"><![CDATA[<hr/> <p>layout: post title: a post with pseudo code date: 2024-04-15 00:01:00 description: this is what included pseudo code could look like tags: formatting code categories: sample-posts pseudocode: true published: false—</p> <p>This is an example post with some pseudo code rendered by <a href="https://github.com/SaswatPadhi/pseudocode.js">pseudocode</a>. The example presented here is the same as the one in the <a href="https://saswat.padhi.me/pseudocode.js/">pseudocode.js</a> documentation, with only one simple but important change: everytime you would use <code class="language-plaintext highlighter-rouge">$</code>, you should use <code class="language-plaintext highlighter-rouge">$$</code> instead. Also, note that the <code class="language-plaintext highlighter-rouge">pseudocode</code> key in the front matter is set to <code class="language-plaintext highlighter-rouge">true</code> to enable the rendering of pseudo code. As an example, using this code:</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">pseudocode
</span><span class="sb">% This quicksort algorithm is extracted from Chapter 7, Introduction to Algorithms (3rd edition)
\begin{algorithm}
\caption{Quicksort}
\begin{algorithmic}
\PROCEDURE{Quicksort}{$$A, p, r$$}
    \IF{$$p &lt; r$$}
        \STATE $$q = $$ \CALL{Partition}{$$A, p, r$$}
        \STATE \CALL{Quicksort}{$$A, p, q - 1$$}
        \STATE \CALL{Quicksort}{$$A, q + 1, r$$}
    \ENDIF
\ENDPROCEDURE
\PROCEDURE{Partition}{$$A, p, r$$}
    \STATE $$x = A[r]$$
    \STATE $$i = p - 1$$
    \FOR{$$j = p$$ \TO $$r - 1$$}
        \IF{$$A[j] &lt; x$$}
            \STATE $$i = i + 1$$
            \STATE exchange
            $$A[i]$$ with $$A[j]$$
        \ENDIF
        \STATE exchange $$A[i]$$ with $$A[r]$$
    \ENDFOR
\ENDPROCEDURE
\end{algorithmic}
\end{algorithm}</span>
<span class="p">```</span>
</code></pre></div></div> <p>Generates:</p> <pre><code class="language-pseudocode">% This quicksort algorithm is extracted from Chapter 7, Introduction to Algorithms (3rd edition)
\begin{algorithm}
\caption{Quicksort}
\begin{algorithmic}
\PROCEDURE{Quicksort}{$$A, p, r$$}
    \IF{$$p &lt; r$$}
        \STATE $$q = $$ \CALL{Partition}{$$A, p, r$$}
        \STATE \CALL{Quicksort}{$$A, p, q - 1$$}
        \STATE \CALL{Quicksort}{$$A, q + 1, r$$}
    \ENDIF
\ENDPROCEDURE
\PROCEDURE{Partition}{$$A, p, r$$}
    \STATE $$x = A[r]$$
    \STATE $$i = p - 1$$
    \FOR{$$j = p$$ \TO $$r - 1$$}
        \IF{$$A[j] &lt; x$$}
            \STATE $$i = i + 1$$
            \STATE exchange
            $$A[i]$$ with $$A[j]$$
        \ENDIF
        \STATE exchange $$A[i]$$ with $$A[r]$$
    \ENDFOR
\ENDPROCEDURE
\end{algorithmic}
\end{algorithm}
</code></pre>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post with pseudo code date: 2024-04-15 00:01:00 description: this is what included pseudo code could look like tags: formatting code categories: sample-posts pseudocode: true published: false—]]></summary></entry><entry><title type="html">Advanced Images</title><link href="https://sabharwalrishabh.github.io/blog/2024/advanced-images/" rel="alternate" type="text/html" title="Advanced Images"/><published>2024-01-27T00:00:00+00:00</published><updated>2024-01-27T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2024/advanced-images</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2024/advanced-images/"><![CDATA[<hr/> <p>layout: post title: a post with advanced image components date: 2024-01-27 11:46:00 description: this is what advanced image components could look like tags: formatting images categories: sample-posts thumbnail: assets/img/9.jpg images: compare: true slider: true published: false—</p> <p>This is an example post with advanced image components.</p> <h2 id="image-slider">Image Slider</h2> <p>This is a simple image slider. It uses the <a href="https://swiperjs.com/">Swiper</a> library. Check the <a href="https://swiperjs.com/demos">examples page</a> for more information of what you can achieve with it.</p> <swiper-container keyboard="true" navigation="true" pagination="true" pagination-clickable="true" pagination-dynamic-bullets="true" rewind="true"> <swiper-slide> <figure> <picture> <source class="responsive-img-srcset" srcset="/assets/img/9-480.webp 480w,/assets/img/9-800.webp 800w,/assets/img/9-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/9.jpg" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="eager" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> </swiper-slide> <swiper-slide> <figure> <picture> <source class="responsive-img-srcset" srcset="/assets/img/7-480.webp 480w,/assets/img/7-800.webp 800w,/assets/img/7-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/7.jpg" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="eager" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> </swiper-slide> <swiper-slide> <figure> <picture> <source class="responsive-img-srcset" srcset="/assets/img/8-480.webp 480w,/assets/img/8-800.webp 800w,/assets/img/8-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/8.jpg" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="eager" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> </swiper-slide> <swiper-slide> <figure> <picture> <source class="responsive-img-srcset" srcset="/assets/img/10-480.webp 480w,/assets/img/10-800.webp 800w,/assets/img/10-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/10.jpg" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="eager" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> </swiper-slide> <swiper-slide> <figure> <picture> <source class="responsive-img-srcset" srcset="/assets/img/12-480.webp 480w,/assets/img/12-800.webp 800w,/assets/img/12-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/12.jpg" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="eager" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> </swiper-slide> </swiper-container> <h2 id="image-comparison-slider">Image Comparison Slider</h2> <p>This is a simple image comparison slider. It uses the <a href="https://img-comparison-slider.sneas.io/">img-comparison-slider</a> library. Check the <a href="https://img-comparison-slider.sneas.io/examples.html">examples page</a> for more information of what you can achieve with it.</p> <img-comparison-slider> <figure slot="first"> <picture> <source class="responsive-img-srcset" srcset="/assets/img/prof_pic-480.webp 480w,/assets/img/prof_pic-800.webp 800w,/assets/img/prof_pic-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/prof_pic.jpg" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="lazy" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> <figure slot="second"> <picture> <source class="responsive-img-srcset" srcset="/assets/img/prof_pic_color-480.webp 480w,/assets/img/prof_pic_color-800.webp 800w,/assets/img/prof_pic_color-1400.webp 1400w," type="image/webp" sizes="95vw"/> <img src="/assets/img/prof_pic_color.png" class="img-fluid rounded z-depth-1" width="100%" height="auto" loading="lazy" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"/> </picture> </figure> </img-comparison-slider>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post with advanced image components date: 2024-01-27 11:46:00 description: this is what advanced image components could look like tags: formatting images categories: sample-posts thumbnail: assets/img/9.jpg images: compare: true slider: true published: false—]]></summary></entry><entry><title type="html">Vega Lite</title><link href="https://sabharwalrishabh.github.io/blog/2024/vega-lite/" rel="alternate" type="text/html" title="Vega Lite"/><published>2024-01-27T00:00:00+00:00</published><updated>2024-01-27T00:00:00+00:00</updated><id>https://sabharwalrishabh.github.io/blog/2024/vega-lite</id><content type="html" xml:base="https://sabharwalrishabh.github.io/blog/2024/vega-lite/"><![CDATA[<hr/> <p>layout: post title: a post with vega lite date: 2024-01-27 00:20:00 last_updated: 2024-04-14 04:30:00 description: this is what included vega lite code could look like tags: formatting charts categories: sample-posts chart: vega_lite: true published: false—</p> <p>This is an example post with some <a href="https://vega.github.io/vega-lite/">vega lite</a> code.</p> <div class="language-markdown highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">```</span><span class="nl">vega_lite
</span><span class="sb">{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A dot plot showing each movie in the database, and the difference from the average movie rating. The display is sorted by year to visualize everything in sequential order. The graph is for all Movies before 2019.",
  "data": {
    "url": "https://raw.githubusercontent.com/vega/vega/main/docs/data/movies.json"
  },
  "transform": [
    {"filter": "datum['IMDB Rating'] != null"},
    {"filter": {"timeUnit": "year", "field": "Release Date", "range": [null, 2019]}},
    {
      "joinaggregate": [{
        "op": "mean",
        "field": "IMDB Rating",
        "as": "AverageRating"
      }]
    },
    {
      "calculate": "datum['IMDB Rating'] - datum.AverageRating",
      "as": "RatingDelta"
    }
  ],
  "mark": "point",
  "encoding": {
    "x": {
      "field": "Release Date",
      "type": "temporal"
    },
    "y": {
      "field": "RatingDelta",
      "type": "quantitative",
      "title": "Rating Delta"
    },
    "color": {
      "field": "RatingDelta",
      "type": "quantitative",
      "scale": {"domainMid": 0},
      "title": "Rating Delta"
    }
  }
}</span>
<span class="p">```</span>
</code></pre></div></div> <p>Which generates:</p> <pre><code class="language-vega_lite">{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A dot plot showing each movie in the database, and the difference from the average movie rating. The display is sorted by year to visualize everything in sequential order. The graph is for all Movies before 2019.",
  "data": {
    "url": "https://raw.githubusercontent.com/vega/vega/main/docs/data/movies.json"
  },
  "transform": [
    {"filter": "datum['IMDB Rating'] != null"},
    {"filter": {"timeUnit": "year", "field": "Release Date", "range": [null, 2019]}},
    {
      "joinaggregate": [{
        "op": "mean",
        "field": "IMDB Rating",
        "as": "AverageRating"
      }]
    },
    {
      "calculate": "datum['IMDB Rating'] - datum.AverageRating",
      "as": "RatingDelta"
    }
  ],
  "mark": "point",
  "encoding": {
    "x": {
      "field": "Release Date",
      "type": "temporal"
    },
    "y": {
      "field": "RatingDelta",
      "type": "quantitative",
      "title": "Rating Delta"
    },
    "color": {
      "field": "RatingDelta",
      "type": "quantitative",
      "scale": {"domainMid": 0},
      "title": "Rating Delta"
    }
  }
}
</code></pre> <p>This plot supports both light and dark themes.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[layout: post title: a post with vega lite date: 2024-01-27 00:20:00 last_updated: 2024-04-14 04:30:00 description: this is what included vega lite code could look like tags: formatting charts categories: sample-posts chart: vega_lite: true published: false—]]></summary></entry></feed>