Skip to main content

Colors

Your terminal’s palette or the book’s, light or dark

tomes reads the HTML that Quarto made, so code keeps its syntax colors, and the output of terminal sessions made with quarto-term keeps the colors it had in the terminal.

Your terminal’s colors or the book’s

By default, tomes uses your terminal’s own palette and background: the book looks like everything else in your terminal. Space c switches to the book’s palette (from quarto-term, or a default one), which also paints the background. Space l switches between the book’s light and dark colors:

tomes
tomes https://dsatcl.jeroenjanssens.com/ -c 5
tomes
 Data Science at the Command Li… │                                                                           ┃
 Welcome                         │ 5  Scrubbing Data                                                         │
 Foreword                        │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  │
 Preface                         │                                                                           │
 1  Introduction                 │ Two chapters ago, in the first step of the OSEMN model for data science,  │
 2  Getting Started              │ we looked at obtaining data from a variety of sources. This chapter is    │
 3  Obtaining Data               │ all about the second step: scrubbing data. You see, it’s quite rare that  │
 4  Creating Command-line Tools  │ you can immediately continue with exploring or even modeling the data.    │
▸5  Scrubbing Data               │ There’s a plethora of reasons why your data first needs some cleaning,    │
   5.1 Overview                  │ or scrubbing.                                                             │
   5.2 Transformations, Transf…  │                                                                           │
   5.3 Plain Text                │ For starters, the data might not be in the desired format. For example,   │
     5.3.1 Filtering Lines       │ you may have obtained some JSON data from an API, but you need it to be   │
     5.3.2 Extracting Values     │ in CSV format to create a visualization. Other common formats include     │
     5.3.3 Replacing and Delet…  │ plain text, HTML, and XML. Most command-line tools only work with one or  │
   5.4 CSV                       │ two formats, so it’s important that you’re able to convert data from one  │
     5.4.1 Bodies and Headers …  │ format to another.                                                        │
     5.4.2 Performing SQL Quer…  │                                                                           │
     5.4.3 Extracting and Reor…  │ Once the data is in the desired format, there could still be issues like  │
     5.4.4 Filtering Rows        │ missing values, inconsistencies, weird characters, or unnecessary parts.  │
     5.4.5 Merging Columns       │ You can fix these by applying filters, replacing values, and combining    │
     5.4.6 Combining Multiple …  │ multiple files. The command line is especially well-suited for these      │
   5.5 Working with XML/HTML a…  │ kind of transformations, because there are many specialized tools         │
   5.6 Summary                   │ available, most of which can handle large amounts of data. In this        │
   5.7 For Further Exploration   │ chapter I’ll discuss classic tools such as grep¹ and awk², and newer      │
 6  Project Management with Ma…  │ tools such as jq³ and pup⁴.                                               │
 7  Exploring Data               │                                                                           │
 8  Parallel Pipelines           │ Sometimes you can use the same command-line tool to perform several       │
 9  Modeling Data                │ operations or multiple tools to perform the same operation. This chapter  │
 5  Scrubbing Data                                                                ▶ terminal  term  8/16  Top 
tomes
 Data Science at the Command Li… │ operations or multiple tools to perform the same operation. This chapter  ┃
 Welcome                         │ is more structured like a cookbook, where the focus is on the problems    │
 Foreword                        │ or recipes, rather than diving deeply into the command-line tools         │
 Preface                         │ themselves.                                                               │
 1  Introduction                 │                                                                           │
 2  Getting Started              │ 5.1 Overview                                                              │
 3  Obtaining Data               │ ────────────                                                              │
 4  Creating Command-line Tools  │                                                                           │
 5  Scrubbing Data               │ In this chapter, you’ll learn how to:                                     │
▸  5.1 Overview                  │                                                                           │
   5.2 Transformations, Transf…  │ • Convert data from one format to another                                 │
   5.3 Plain Text                │ • Apply SQL queries directly to CSV                                       │
     5.3.1 Filtering Lines       │ • Filter lines                                                            │
     5.3.2 Extracting Values     │ • Extract and replace values                                              │
     5.3.3 Replacing and Delet…  │ • Split, merge, and extract columns                                       │
   5.4 CSV                       │ • Combine multiple files                                                  │
     5.4.1 Bodies and Headers …  │                                                                           │
     5.4.2 Performing SQL Quer…  │ This chapter starts with the following files:                             │
     5.4.3 Extracting and Reor…  │                                                                           │
     5.4.4 Filtering Rows        │                                                         ⧉ copy  ▶ send    │
     5.4.5 Merging Columns       │  $ cd /data/ch05                                                          │
     5.4.6 Combining Multiple …  │                                                                           │
   5.5 Working with XML/HTML a…  │  $ l                                                                      │
   5.6 Summary                   │  total 200K                                                               │
   5.7 For Further Exploration   │  -rw-r--r-- 1 dst dst 164K Nov 26 11:54 alice.txt                         │
 6  Project Management with Ma…  │  -rw-r--r-- 1 dst dst 4.5K Nov 26 11:54 iris.csv                          │
 7  Exploring Data               │  -rw-r--r-- 1 dst dst  179 Nov 26 11:54 irismeta.csv                      │
 8  Parallel Pipelines           │  -rw-r--r-- 1 dst dst  160 Nov 26 11:54 names-comma.csv                   │
 9  Modeling Data                │  -rw-r--r-- 1 dst dst  129 Nov 26 11:54 names.csv                         │
 5  Scrubbing Data › 5.1 Overview                                                  ▶ terminal  term  8/16  3% 

With the book’s light colors:

tomes
 Data Science at the Command Li… │ operations or multiple tools to perform the same operation. This chapter  ┃
 Welcome                         │ is more structured like a cookbook, where the focus is on the problems    │
 Foreword                        │ or recipes, rather than diving deeply into the command-line tools         │
 Preface                         │ themselves.                                                               │
 1  Introduction                 │                                                                           │
 2  Getting Started              │ 5.1 Overview                                                              │
 3  Obtaining Data               │ ────────────                                                              │
 4  Creating Command-line Tools  │                                                                           │
 5  Scrubbing Data               │ In this chapter, you’ll learn how to:                                     │
▸  5.1 Overview                  │                                                                           │
   5.2 Transformations, Transf…  │ • Convert data from one format to another                                 │
   5.3 Plain Text                │ • Apply SQL queries directly to CSV                                       │
     5.3.1 Filtering Lines       │ • Filter lines                                                            │
     5.3.2 Extracting Values     │ • Extract and replace values                                              │
     5.3.3 Replacing and Delet…  │ • Split, merge, and extract columns                                       │
   5.4 CSV                       │ • Combine multiple files                                                  │
     5.4.1 Bodies and Headers …  │                                                                           │
     5.4.2 Performing SQL Quer…  │ This chapter starts with the following files:                             │
     5.4.3 Extracting and Reor…  │                                                                           │
     5.4.4 Filtering Rows        │                                                         ⧉ copy  ▶ send    │
     5.4.5 Merging Columns       │  $ cd /data/ch05                                                          │
     5.4.6 Combining Multiple …  │                                                                           │
   5.5 Working with XML/HTML a…  │  $ l                                                                      │
   5.6 Summary                   │  total 200K                                                               │
   5.7 For Further Exploration   │  -rw-r--r-- 1 dst dst 164K Nov 26 11:54 alice.txt                         │
 6  Project Management with Ma…  │  -rw-r--r-- 1 dst dst 4.5K Nov 26 11:54 iris.csv                          │
 7  Exploring Data               │  -rw-r--r-- 1 dst dst  179 Nov 26 11:54 irismeta.csv                      │
 8  Parallel Pipelines           │  -rw-r--r-- 1 dst dst  160 Nov 26 11:54 names-comma.csv                   │
 9  Modeling Data                │  -rw-r--r-- 1 dst dst  129 Nov 26 11:54 names.csv                         │
 The book's light colors (Space c: your terminal's colors)                   ▶ terminal  book·light  8/16  3% 

tomes remembers your choice. You can also start with --colors book, --colors terminal, --light, or --dark, or set colors and dark in the configuration.

Code blocks

Code blocks have a background. Space k adds a rounded border around them, just outside the text, so 80 columns of code still fit:

tomes
 Data Science at the Command Li… │ operations or multiple tools to perform the same operation. This chapter  ┃
 Welcome                         │ is more structured like a cookbook, where the focus is on the problems    │
 Foreword                        │ or recipes, rather than diving deeply into the command-line tools         │
 Preface                         │ themselves.                                                               │
 1  Introduction                 │                                                                           │
 2  Getting Started              │ 5.1 Overview                                                              │
 3  Obtaining Data               │ ────────────                                                              │
 4  Creating Command-line Tools  │                                                                           │
 5  Scrubbing Data               │ In this chapter, you’ll learn how to:                                     │
▸  5.1 Overview                  │                                                                           │
   5.2 Transformations, Transf…  │ • Convert data from one format to another                                 │
   5.3 Plain Text                │ • Apply SQL queries directly to CSV                                       │
     5.3.1 Filtering Lines       │ • Filter lines                                                            │
     5.3.2 Extracting Values     │ • Extract and replace values                                              │
     5.3.3 Replacing and Delet…  │ • Split, merge, and extract columns                                       │
   5.4 CSV                       │ • Combine multiple files                                                  │
     5.4.1 Bodies and Headers …  │                                                                           │
     5.4.2 Performing SQL Quer…  │ This chapter starts with the following files:                             │
     5.4.3 Extracting and Reor…  │                                                                           │
     5.4.4 Filtering Rows        │╭─────────────────────────────────────────────────────── ⧉ copy  ▶ send ─╮ │
     5.4.5 Merging Columns       ││ $ cd /data/ch05                                                        │ │
     5.4.6 Combining Multiple …  ││                                                                        │ │
   5.5 Working with XML/HTML a…  ││ $ l                                                                    │ │
   5.6 Summary                   ││ total 200K                                                             │ │
   5.7 For Further Exploration   ││ -rw-r--r-- 1 dst dst 164K Nov 26 11:54 alice.txt                       │ │
 6  Project Management with Ma…  ││ -rw-r--r-- 1 dst dst 4.5K Nov 26 11:54 iris.csv                        │ │
 7  Exploring Data               ││ -rw-r--r-- 1 dst dst  179 Nov 26 11:54 irismeta.csv                    │ │
 8  Parallel Pipelines           ││ -rw-r--r-- 1 dst dst  160 Nov 26 11:54 names-comma.csv                 │ │
 9  Modeling Data                ││ -rw-r--r-- 1 dst dst  129 Nov 26 11:54 names.csv                       │ │
 Code blocks with a border                                                   ▶ terminal  book·light  8/16  3% 

The width of the text

The text is at most 82 columns wide, so the 80 columns of a terminal session plus the padding of its block fit. Space + and Space - change it, or set width in the configuration. Code and tables that are wider scroll sideways with zh and zl (or ← and →).