Agree.
Should it be 0;
?
In terms of priority @DavidG I think the enhanced command line options are the highest priority.
Supporting a BBCode mode (targeting Discourse’s set) would be amazing but a lower priority.
Agree.
Should it be 0;
?
In terms of priority @DavidG I think the enhanced command line options are the highest priority.
Supporting a BBCode mode (targeting Discourse’s set) would be amazing but a lower priority.
You mean as a preprocessing step? Doing this will strip out the formatting codes that are sent individually, as the 0
clears all text attributes…
No, as opposed to 1;
ie:
\e[37m —> \e[0;37m
This latter code doesn’t exist as a mapping value in the ansi Ruby gem btw
I’m not losing any info? I’m simply upscaling. Those are targetted substring replacements.
I have no clue what the Ruby library does but a quick look seems to imply just simple pattern matching, which is not how it should work. You can concatenate separate ANSI CSI sequences, so \e[0;37m
is two commands, reset
followed by white
, with the reset clearing any formatting code for the following text.
Eeek, I feared I’d opened Pandora’s box:
Here are the mappings from the libary https://github.com/rubyworks/ansi/blob/master/lib/ansi/bbcode.rb
## ANSIname => ANSIcode LUT
ANSINAME2CODE= { "reset" => "\e[0m", "bold" => "\e[1m",
"underline" => "\e[4m", "blink" => "\e[5m",
"reverse" => "\e[7m", "invisible" => "\e[8m",
"black" => "\e[0;30m", "darkgrey" => "\e[1;30m",
"red" => "\e[0;31m", "lightred" => "\e[1;31m",
"green" => "\e[0;32m", "lightgreen" => "\e[1;32m",
"brown" => "\e[0;33m", "yellow" => "\e[1;33m",
"blue" => "\e[0;34m", "lightblue" => "\e[1;34m",
"purple" => "\e[0;35m", "magenta" => "\e[1;35m",
"cyan" => "\e[1;36m", "lightcyan" => "\e[1;36m",
"grey" => "\e[0;37m", "white" => "\e[1;37m",
"bgblack" => "\e[40m", "bgred" => "\e[41m",
"bggreen" => "\e[42m", "bgyellow" => "\e[43m",
"bgblue" => "\e[44m", "bgmagenta" => "\e[45m",
"bgcyan" => "\e[46m", "bgwhite" => "\e[47m"
}
What’s the internal standard that these games employ and is it consistent?
Yes, this is the code I browsed.
I’ll make a quick prototype for a dump frotz bbcode mode - it will be easier. Do you have a simple reference for the formatting codes you want?
Here’s the appropriate target:
I make no apologies for suggesting this because BBCode is not a maintained standard. afaia, this is as good as any.
We want the one that works for the use case we have. So this is fine.
Picking up the other thread, this is how I’m currently stripping the output.
(forgive the current bugs, but you get the idea):
BEFORE strip:
Using ANSI formatting.
Loading frotz/stories/zork1.z5.
West of House Score: 0 Moves: 0
ZORK I: The Great Underground Empire
Copyright (c) 1981, 1982, 1983 Infocom, Inc. All rights reserved.
Licensed to Tandy Corporation.
ZORK is a registered trademark of Infocom, Inc.
Revision 88 / Serial number 840726
West of House
You are standing in an open field west of a white house, with a boarded
front door.
There is a small mailbox here.
>Please enter a filename [zork1.qzl]: Overwrite existing file? Ok.
>
AFTER strip:
[color=white][bgcolor=black] West of House Score: 0 Moves: 0 [/bgcolor][/color
]
ZORK I: The Great Underground Empire
Copyright (c) 1981, 1982, 1983 Infocom, Inc. All rights reserved.
Licensed to Tandy Corporation.
ZORK is a registered trademark of Infocom, Inc.
Revision 88 / Serial number 840726
West of House
You are standing in an open field west of a white house, with a boarded
front door.
There is a small mailbox here.
The ability to enter a mode that would silence Frotz from providing its “housekeeping”/status text would be great so all it outputs is the story text.
Here’s the current command line (slightly simplified for this purpose):
input_data += "#{msg}\nsave\n#{new_save_location}#{overwrite}\n\cD"
output, s = Open3.capture2("#{SiteSetting.frotz_dumb_executable_directory}/./dfrotz -L #{save_location} -f ansi -i -Z 0 #{story_path}", :stdin_data=>input_data, :binmode=>true )
This is already superior to my first attempt but there are improvements that could be made:
So on top of silencing Frotz’s housekeeping status text, It would be good to remove the need to perform any stdin streaming, that is:
as a command arguments.
Here is a simple patch to dumb frotz, adding a bbcode
option to -f
, currently only supporting bold and italics, but should be enough for a first test: https://gitlab.com/borg323/frotz/-/compare/master...bbcode
Thanks!
FYI my current setup supports quite a lot of features already (including background colours), but happy to test in any case.
It would be great to rationalise the code where appropriate (obviously I can only do that once the Frotz feature set exceeds mine).
Can you recommend a test story?
I think the TerpEtude (etude.z5
) test is a good starting point.
For color support, what happens with something like
[color=red]red[color=blue]blue[bgcolor=black]black background[color=white]white[\color][\bgcolor]
?
Needs to be:
[color=red]red[/color][color=blue]blue[/color][bgcolor=black]black background[color=white]white[/color][/bgcolor]
or Discourse doesn’t render as formatted text (note the slash direction, same tags can’t be nested)
That gives:
Thanks for that, I have now added color support (fg, bg and reverse color). Use the same link as before (https://gitlab.com/borg323/frotz/-/compare/master...bbcode) for tests.
You couldn’t provide me a link could you? For some reason I can’t find it on https://ifdb.tads.org/!
Slashes are still in the wrong direction and tags are closing in the wrong order
[color=white][bgcolor=black] Bedroom Score: 0 Moves: 0 [\color][\bgcolor]
THE HITCHHIKER’S GUIDE TO THE GALAXY
Infocom interactive fiction - a science fiction story
Copyright © 1984 by Infocom, Inc. All rights reserved.
Release 59 / Serial number 851108
You wake up. The room is spinning very gently round your head. Or at least
it would be if you could see it which you can’t.
It is pitch black.
You can get TerpEtude from the IF-Archive: https://www.ifarchive.org/indexes/if-archive/infocom/interpreters/tools/ - the file is “etude.tar.Z”.
Sorry about the closing tags, I should have read the doc more carefully. However how important is the closing tag order? To keep a strict ordering for all tags may be a bit messy.