scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Syntax error with the non-breaking space

Open haijinSk opened this issue 7 months ago • 0 comments

In master and rebis-dev. (But maybe I'm wrong, and in Scryer it's expected?)

?- NBSP = " ".
   error(syntax_error(missing_quote),read_term/3:0), unexpected.
   NBSP = "\xa0\". % expected, but not found.

And, for example, If this works as expected:

?- NbspChar = '\xa0\'.
   NbspChar = '\xa0\'. % as expected

then this is unexpected (?):

?- use_module(library(charsio)).
   true.
?- read_from_chars("nbsp('\xa0\').",T).
   error(syntax_error(invalid_single_quoted_character),read_term_from_chars/3), unexpected.
   T = nbsp('\xa0\'). % expected, but not found.

And, it seems, that, for example, the same problem with the "NARROW NO-BREAK SPACE"...

Thank you.


PS:

My personal & humorous context. I was creating a simple "HTTP & DCGs" program, where the first task is transforming a hand-made text file with lines of URL links to a Prolog file of "factoids" like: web(<url>,<title>,<h1>). and, hard to believe, but my first URL would be a web page with a non-breaking space in the title and h1:

https://frontenddogma.com/

And, again, hard to believe, that web page has two h1 HTML elements... And the first of them is an image (in the h1). Super easy, except, in my naive case, quick and dirty, with some naive negation and pruning:

h1(H1) --> ..., "<h1>", seq(H1), "</h1>", { \+ image(H1) }, ... .

image(H1) :- once(phrase((..., "<img src=", ...), H1)). 

So far so good. I have my data file like this:

web("https://frontenddogma.com/","News and Tools for Frontend Developers · Frontend Dogma","News and Tools for Frontend Developers").
web("https://jakearchibald.com/2023/against-self-closing-tags-in-html/","The case against self-closing tags in HTML - JakeArchibald.com","The case against self-closing tags in HTML").
[...]

But, I can't load/consult it with Scryer, because of the non-breaking space. I know, I could simply transform it to the "normal space" before phrasing to the data file.

haijinSk avatar Jun 17 '25 21:06 haijinSk