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

Marked As Solved

Margaret

Margaret

Editor at PragProg

IDK if this helps you, but there is a zip file with the code for the vale.ini file on the book’s web page: https://media.pragprog.com/titles/bhvale/code/bhvale-code.zip

Also Liked

bphogan

bphogan

Author of Build Websites with Hugo (and 4 other titles)

@s2k that just makes me smile so much. What a great application of the book’s content.

This is exactly how I use Vale at $dayJob… to find things we want to fix.

FWIW I verified that there’s nothing in the original code that causes this, so it’s something I’ll have to raise with the publisher.

Where Next?

Popular Pragmatic Bookshelf topics Top

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
New

Other popular topics Top

Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
First poster: AstonJ
Jan | Rethink the Computer. Jan turns your computer into an AI machine by running LLMs locally on your computer. It’s a privacy-focus, l...
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New
NewsBot
Node.js v22.14.0 has been released. Link: Release 2025-02-11, Version 22.14.0 'Jod' (LTS), @aduh95 · nodejs/node · GitHub
New
PragmaticBookshelf
A concise guide to MySQL 9 database administration, covering fundamental concepts, techniques, and best practices. Neil Smyth MySQL...
New

Sub Categories: