<?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: Alexei</title>
    <description>The latest articles on DEV Community by Alexei (@linkerin).</description>
    <link>https://dev.to/linkerin</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2710804%2F2019c303-3c30-41c6-b52f-142155da16a5.jpeg</url>
      <title>DEV Community: Alexei</title>
      <link>https://dev.to/linkerin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/linkerin"/>
    <language>en</language>
    <item>
      <title>Transforming Starlight into PDF: experience and insights</title>
      <dc:creator>Alexei</dc:creator>
      <pubDate>Tue, 14 Jan 2025 20:44:44 +0000</pubDate>
      <link>https://dev.to/linkerin/transforming-starlight-into-pdf-experience-and-insights-j1d</link>
      <guid>https://dev.to/linkerin/transforming-starlight-into-pdf-experience-and-insights-j1d</guid>
      <description>&lt;p&gt;Imagine you are given a task: create a new documentation website in a week. It should be visually appealing, fast, and easy to navigate. You’re handed a pile of *.docs files, images, and screenshots, with the instruction to &lt;em&gt;"get it done"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;There are many excellent tools to choose from, such as &lt;em&gt;Docusaurus&lt;/em&gt;, &lt;em&gt;Nextra&lt;/em&gt;, &lt;em&gt;VitePress&lt;/em&gt;, &lt;em&gt;Docus&lt;/em&gt;, and others. Previously, I had a great experience building a documentation website with &lt;a href="https://starlight.astro.build" rel="noopener noreferrer"&gt;Starlight&lt;/a&gt;, so it was my choice for this task. However, I discovered a missing feature: the ability to generate a PDF from the documentation. And it was one of the requirements. &lt;em&gt;"Sounds like a nice side project,"&lt;/em&gt; I thought for myself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tackling the task
&lt;/h2&gt;

&lt;p&gt;At first, it seemed straightforward: fetch the pages, parse the HTML, group the content, and voila!&lt;/p&gt;

&lt;p&gt;Starlight powered websites have a &lt;code&gt;Next&lt;/code&gt; button to navigate through the documentation. As PDF essentially is an array of pages, it seemed logical to parse them one by one, using this &lt;code&gt;Next&lt;/code&gt; button. Since the website generates static pages, I quickly wrote a script to fetch the HTML, query the necessary parts, and combine everything together. However, generating a PDF that retained the website's styles proved to be more complex. After some brainstorming, I realized Puppeteer was the best solution.&lt;/p&gt;

&lt;p&gt;Now the process became clear:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identify the starting page.&lt;/strong&gt; This is the first page with a &lt;code&gt;Next&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Navigate through the pages.&lt;/strong&gt; Extract the heading and main content from each page and at the same time build a table of contents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Combine the content.&lt;/strong&gt; Add page breaks and additional styles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prepare the final HTML.&lt;/strong&gt; Rewrite the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; of the initial page with the resulting HTML.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load resources.&lt;/strong&gt; Scroll the page to the bottom to load all the images.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generate the PDF.&lt;/strong&gt; Puppeteer's &lt;a href="https://pptr.dev/api/puppeteer.page.pdf" rel="noopener noreferrer"&gt;&lt;code&gt;Page.pdf()&lt;/code&gt;&lt;/a&gt; method nails it.&lt;/li&gt;
&lt;li&gt;Done!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is how &lt;a href="https://github.com/Linkerin/starlight-to-pdf" rel="noopener noreferrer"&gt;starlight-to-pdf&lt;/a&gt; works. Following this pattern, you can build similar tools for other documentation frameworks lacking PDF export functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;Once the basic functionality was ready, it was time to add some extras. Below are the most interesting and challenging features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding headers and footers
&lt;/h3&gt;

&lt;p&gt;It's nice to have a page number and some additional information in the header or footer. Puppeteer's &lt;code&gt;Page.pdf()&lt;/code&gt; method accepts &lt;a href="https://pptr.dev/api/puppeteer.pdfoptions#headertemplate" rel="noopener noreferrer"&gt;&lt;code&gt;headerTemplate&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;footerTemplate&lt;/code&gt; options. These options accept HTML strings. Puppeteer automatically injects values into the elements that have specific utility classes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.date&lt;/code&gt;: formatted date;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.title&lt;/code&gt;: web page's &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; tag value;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.url&lt;/code&gt;: page's URL on which printing function was called;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.pageNumber&lt;/code&gt;: current page number;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.totalPages&lt;/code&gt;: total number of pages in the document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As we combine all the content on one page before printing, &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;url&lt;/code&gt; don't have much value for us: the inserted value will always remain the same. However, other classes help a lot. Here’s an example footer template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="nc"&gt;.footer-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space-between&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;border-block-start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Arial&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Helvetica&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;margin-inline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5cm&lt;/span&gt; &lt;span class="m"&gt;1cm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;padding-block&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.25cm&lt;/span&gt; &lt;span class="m"&gt;0.5cm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"footer-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;Awesome docs&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- Numbers inside the elements with `.pageNumber` and `.totalPages` classes are injected automatically by Puppeteer --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pageNumber"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt; / &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"totalPages"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- Same for the `.date` class value --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"date"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use this, do not forget to set the &lt;code&gt;displayHeaderFooter&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;puppeteer&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;puppeteer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;browser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;puppeteer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;browser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;newPage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://someUrl&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;footerTemplateStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;style&amp;gt;...&amp;lt;style&amp;gt;&amp;lt;div&amp;gt;...&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// replace with the HTML string from the example above&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;displayHeaderFooter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;footerTemplate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;footerTemplateStr&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some findings that you should keep in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The template must be a valid HTML structure.&lt;/li&gt;
&lt;li&gt;Define &lt;code&gt;font-size&lt;/code&gt; CSS property as Puppeteer's default value is &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use inline &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag to define your styles. Website styles are not available inside the templates.&lt;/li&gt;
&lt;li&gt;Images should be encoded as base64 strings.&lt;/li&gt;
&lt;li&gt;Use Puppeteer's &lt;a href="https://pptr.dev/api/puppeteer.pdfoptions#margin" rel="noopener noreferrer"&gt;&lt;code&gt;margin&lt;/code&gt;&lt;/a&gt; option to achieve the desired layout.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What about CLI styles?
&lt;/h3&gt;

&lt;p&gt;Everything works fine, the resulting PDF looks great, but the terminal messages feel bland. Attention to details separates the good from the great, isn’t it? Let's make our messages more colorful and easier to read.&lt;/p&gt;

&lt;p&gt;Here comes the magic of &lt;a href="https://en.wikipedia.org/wiki/ANSI_escape_code" rel="noopener noreferrer"&gt;ANSI escape sequences&lt;/a&gt;. I decided that 4-bit colours would be enough for the job. Let's say you want to have a white text on red background &lt;em&gt;(that's what I used for my &lt;code&gt;[ERROR]:&lt;/code&gt; prefix before error messages)&lt;/em&gt;. Here is how you can achieve this look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[37;41m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;White on red message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;\x1b[&lt;/code&gt; is a hexadecimal escape code (you may also use &lt;code&gt;\u001b&lt;/code&gt; as the Unicode alternative);&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;37&lt;/code&gt; is a foreground white color, where &lt;code&gt;3&lt;/code&gt; stands for foreground and &lt;code&gt;7&lt;/code&gt; for the white color;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;41&lt;/code&gt; is a background red color, where &lt;code&gt;4&lt;/code&gt; stands for background and &lt;code&gt;1&lt;/code&gt; for the red color.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything is working, but now all of our &lt;code&gt;console.log()&lt;/code&gt; output will be styled in this manner. To reset the style back to default, simply add the reset sequence &lt;code&gt;\x1b[0m&lt;/code&gt; at the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[37;41m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;White on red message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[0m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much better. What if we want bold cyan text on a gray background &lt;em&gt;(&lt;code&gt;bright black&lt;/code&gt; in the names of 4-bit colors)&lt;/em&gt;? It's easy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[1;36;100m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Cyan on gray message in bold&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[0m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what each part does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;1&lt;/code&gt; after the escape code applies the bold effect;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;36&lt;/code&gt; sets the text color to cyan;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;100&lt;/code&gt; changes the background to bright black color, where &lt;code&gt;10&lt;/code&gt; means &lt;em&gt;bright&lt;/em&gt; and &lt;code&gt;0&lt;/code&gt; is a code for &lt;em&gt;black&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using this knowledge, you can make your CLI tool visually appealing. For example, I styled all URLs and file paths as underlined blue text in my project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[4;34m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./underlined/blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s1"&gt;x1b[0m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check out &lt;a href="https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797" rel="noopener noreferrer"&gt;this cheatsheet&lt;/a&gt; to learn more on the topic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;You never know when a routine task might inspire a rewarding side project. Development of &lt;a href="https://github.com/Linkerin/starlight-to-pdf" rel="noopener noreferrer"&gt;starlight-to-pdf&lt;/a&gt; provided valuable experience with Puppeteer and CLI styling, and a new tool emerged in the open source community. Here’s a quick demonstration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flp5cvutf0fzy7cs90gld.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flp5cvutf0fzy7cs90gld.gif" alt="starlight-to-pdf usage demo" width="798" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>astro</category>
      <category>javascript</category>
      <category>pdf</category>
    </item>
  </channel>
</rss>
