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

jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
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
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “>...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
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
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New

Sub Categories: