SWI-Prolog / packages-pengines

Pengines: Prolog engines
11 stars 13 forks source link

write_term/2: nl(true) Option Is Ignored #54

Closed nbcarey closed 2 years ago

nbcarey commented 2 years ago

The predicate write_term/2 appears to ignore (at least) the nl(true) option.

Steps To Reproduce See test case at https://swish.swi-prolog.org/p/BfGWbyLR.pl

test_case :-
  writeln('-----'),
  write_term( 1 + 2 , [ nl(true) ] ),
  writeln('-----').

Expected Output:

-----
1+2
-----

Actual Output:

-----
1+2-----
kamahen commented 2 years ago

Works for me with non-Swish:

$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- [user].
|: test_case :-
|:     writeln('==========='),
|:     write_term(1+2, [nl(true)]),
|:     writeln('------------').
|: ^D% user://1 compiled 0.04 sec, 1 clauses
true.

?- test_case.
===========
1+2
------------
true.
JanWielemaker commented 2 years ago

The Pengine system has its own implementation of write_term/2 to emit HTML. That implementation is probably incomplete. Patch 3713df49bc8b3bd707bb4574589b8cbc6c8b8d71 adds the full_stop and nl options. Public SWISH will be updated the next time its Prolog version is updated.