s2k

s2k

Author of Fast Feedback Using Ruby

Write Better with Vale: Is is possible to copy & paste code from the epub version without invisible characters?

Context

Hardware & OS:

OS: macOS Tahoe 26.0 arm64
Host: MacBook Pro

Observation

One of the code snippets as seen in epub is this:

When I mark the code and copy it into a text editor, I get

“​ StylesPath = ​../styles​​ MinAlertLevel = ​suggestion​​ ​ ​[*.html]​​ BasedOnStyles = ​Vale​​ Vale.Spelling = ​error​”

Excerpt From
Write Better with Vale
Brian P. Hogan
This material may be protected by copyright.

…and that’s fine. Removing the lower part and reformatting the part in the double quotes is easy enough. After doing that, I’m left with:

StylesPath = ​../styles​​
MinAlertLevel = ​suggestion​​

[*.html]​​
BasedOnStyles = ​Vale​​
Vale.Spelling = ​error​

This looks good, but alas it isn’t: Running vale . in (an empty) folder containing only this ini file, I get:

> vale .
E100 [NewE201] Runtime error
The path ‘/Users/stephan/dev/vale_example_project/​../styles​​’ does not exist.
Execution stopped with code 1.

It took me a while to find the issue.
Using caton the file doesn’t show anything suspecting:

> cat .vale.ini
StylesPath = ​../styles
MinAlertLevel = ​suggestion

[*.html]
BasedOnStyles = ​Vale
Vale.Spelling = ​error

Dumping the file to show the characters and hex codes, I get this:

> fd -w16 .vale.ini
.vale.ini
53 74 79 6c 65 73 50 61 74 68 20 3d 20 e2 80 8b |     S t y l e s P a t h ␠ = ␠
2e 2e 2f 73 74 79 6c 65 73 e2 80 8b e2 80 8b 0a |         . . / s t y l e s ​ ​ ␊
4d 69 6e 41 6c 65 72 74 4c 65 76 65 6c 20 3d 20 | M i n A l e r t L e v e l ␠ = ␠
e2 80 8b 73 75 67 67 65 73 74 69 6f 6e e2 80 8b |         ​ s u g g e s t i o n
e2 80 8b 0a 0a 5b 2a 2e 68 74 6d 6c 5d e2 80 8b |         ​ ␊ ␊ [ * . h t m l ]
e2 80 8b 0a 42 61 73 65 64 4f 6e 53 74 79 6c 65 |     ​ ␊ B a s e d O n S t y l e
      73 20 3d 20 e2 80 8b 56 61 6c 65 e2 80 8b |             s ␠ = ␠ ​ V a l e
e2 80 8b 0a 56 61 6c 65 2e 53 70 65 6c 6c 69 6e |     ​ ␊ V a l e . S p e l l i n
67 20 3d 20 e2 80 8b 65 72 72 6f 72 e2 80 8b 0a |         g ␠ = ␠ ​ e r r o r ​ ␊

(fdis for ‘file dump’, a Ruby tool I wrote [and available at https://github.com/s2k/fd\])

Aha! There are sequences of e2 80 8b that vale can’t cope with.
Now, this sequence (in UTF-8) is a ‘zero width space’ (→ U+200B ZERO WIDTH SPACE: ​ – Unicode – Codepoints ) which also explains why it’s not visible.

My question is: Is it possible to not put this zero-width-space in the copied code snippet (or not in the epub file)?

Cheers

Stephan

Where Next?

Popular Pragmatic Bookshelf topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
483 11078 254
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
New
PragmaticBookshelf
Explore the power of Ash Framework by modeling and building the domain for a real-world web application. Rebecca Le @sevenseacat and ...
New

Sub Categories: