[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Displaying HTML entities
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Displaying HTML entities

You need to log onto the forum to reply or create new threads.

  [Refresh] Refresh page


Posted by AdInfinitum   (35 posts)  [Biography] bio
Date Wed 09 May 2018 03:13 AM (UTC)
Message
I'm attempting to convert a script from an old client to MUSHclient, and part of that script uses MXP to display things like headers and paragraph breaks using <h1> and <p>.

I know MUSHclient can use MXP, but how can I get it to display things as an HTML page would? For example, if I had:

<h2>Title</h2>


I'd want that "Title" to be at a size 2 header. Is this possible, or do I need to seek an alternate way of doing so?
[Go to top] top

Posted by Nick Gammon   Australia  (21,652 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 09 May 2018 04:52 AM (UTC)
Message

No, MUSHclient does not support rich text in the output window. The best you could do is make text bold/italic etc. And there are already MXP elements to do that. See here for what MUSHclient supports.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by AdInfinitum   (35 posts)  [Biography] bio
Date Reply #2 on Wed 09 May 2018 05:01 AM (UTC)
Message
Okay, that explains a bit then. h# seems to be supported, according to the page, but all it does is return the <bold> element instead, which I can understand.

How would I go about displaying these MXP elements, however? For instance, I have a code that displays a calendar, and I want it to display the current day in bold. I've not figured that out yet.
[Go to top] top

Posted by Nick Gammon   Australia  (21,652 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 09 May 2018 06:59 AM (UTC)
Message
AdInfinitum said:

How would I go about displaying these MXP elements, however?


I don't quite understand that question.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by AdInfinitum   (35 posts)  [Biography] bio
Date Reply #4 on Wed 09 May 2018 07:47 AM (UTC)
Message
Nick Gammon said:

AdInfinitum said:

How would I go about displaying these MXP elements, however?


I don't quite understand that question.


Well, forgive my ignorance with MXP, because it's a new project to tackle.

What I'm trying to figure out is of the MXP elements that are available to MUSH, how would I go about using them if, for instance, I wanted to make a certain text bold? I know that I can't do something like:

Note("<bold>Test</bold>")


because that doesn't work. I realize I can use NoteStyle for that particular instance, but I was under the impression that I could use the actual bold tags somehow to produce output. Am I wrong?
[Go to top] top

Posted by Nick Gammon   Australia  (21,652 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 09 May 2018 07:58 AM (UTC)
Message
Oh I see. MXP is really intended to be interpreted from the server, not when you just display notes in the output window.

For doing it client-side, see, for example:

Template:function=NoteStyle NoteStyle

The documentation for the NoteStyle script function is available online. It is also in the MUSHclient help file.



You can also use ColourNote to do different colours.

Template:function=ColourNote ColourNote

The documentation for the ColourNote script function is available online. It is also in the MUSHclient help file.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by AdInfinitum   (35 posts)  [Biography] bio
Date Reply #6 on Wed 09 May 2018 08:11 AM (UTC)
Message
Fair enough. I wasn't sure if it worked the same way CMUD did with MXP. I was hoping there was something like an MXPDisplay("<color = red><b>Testing</b></color>") to display a bold Testing in red.

I think it's mainly because to me, it's easier to remember rather than remembering NoteStyle(5) is bold italic, etc. Thanks for the explanations!
[Go to top] top

Posted by Nick Gammon   Australia  (21,652 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 09 May 2018 08:31 PM (UTC)

Amended on Wed 09 May 2018 08:32 PM (UTC) by Nick Gammon

Message
You can make a simple coloured-line displayer. For example see this thread:

http://www.gammon.com.au/forum/?id=9529


To round that out to actually display them I take the code from reply #8 and add a display function:


-- copied from http://www.gammon.com.au/forum/?id=8947
local BLACK = 1
local RED = 2
local GREEN = 3  
local YELLOW = 4 
local BLUE = 5 
local MAGENTA = 6 
local CYAN = 7 
local WHITE = 8

-- colour styles (eg. @r is normal red, @R is bold red)

-- @- is shown as ~
-- @@ is shown as @

-- This table uses the colours as defined in the MUSHclient ANSI tab, however the
-- defaults are shown on the right if you prefer to use those.
local colour_conversion = {
   k = GetNormalColour (BLACK)   ,   -- 0x000000 
   r = GetNormalColour (RED)     ,   -- 0x000080 
   g = GetNormalColour (GREEN)   ,   -- 0x008000 
   y = GetNormalColour (YELLOW)  ,   -- 0x008080 
   b = GetNormalColour (BLUE)    ,   -- 0x800000 
   m = GetNormalColour (MAGENTA) ,   -- 0x800080 
   c = GetNormalColour (CYAN)    ,   -- 0x808000 
   w = GetNormalColour (WHITE)   ,   -- 0xC0C0C0 
   K = GetBoldColour   (BLACK)   ,   -- 0x808080 
   R = GetBoldColour   (RED)     ,   -- 0x0000FF 
   G = GetBoldColour   (GREEN)   ,   -- 0x00FF00 
   Y = GetBoldColour   (YELLOW)  ,   -- 0x00FFFF 
   B = GetBoldColour   (BLUE)    ,   -- 0xFF0000 
   M = GetBoldColour   (MAGENTA) ,   -- 0xFF00FF 
   C = GetBoldColour   (CYAN)    ,   -- 0xFFFF00 
   W = GetBoldColour   (WHITE)   ,   -- 0xFFFFFF 
   
   -- add custom colours here

  }  -- end conversion table


-----------
-- our code:  :)

local P, C, Ct, Cs, Cg, S, Cc = lpeg.P, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Cg, lpeg.S, lpeg.Cc

local tmpcolorkeys = {}
for k,v in pairs(colour_conversion) do tmpcolorkeys[#tmpcolorkeys+1] = k end

local Colors = P"@" * C(S( table.concat(tmpcolorkeys, "") ))
tmpcolorkeys = nil  -- Clean up on aisle tempvar!
local NotAt = P(1) - P"@"
local NotAColor = P(1) - Colors
local text = Cg(Cs( (NotAt + P"@-"/"~" + P"@@"/"@" + NotAColor )^1 ),"text") 
local color = Cg( (Colors + Cc('w')) / colour_conversion ,"textcolour") 
local res = Ct( Ct( color * text)^1) 


function ShowStyledLine (s)
 local styles = res:match(s)
  for k, v in ipairs (t) do
    ColourTell (RGBColourToName (v.textcolour), "", v.text)
  end -- for each style run
  print ()  -- finish off the line
end -- ShowStyledLine 


If you put that into your script file (language: Lua) then you can display colours like this using the same syntax that Aardwolf does:


ShowStyledLine ("an @RAardwolf @WAdventurer's Guide@w (type @Rread guide@w)")


Then you just use things like @R for bold red, and @r for normal red, and so on as you can see in the script near the top.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (1,774 posts)  [Biography] bio   Global Moderator
Date Reply #8 on Thu 10 May 2018 12:51 AM (UTC)
Message
If this is actually for Aardwolf, functions like that are already built https://github.com/fiendish/aardwolfclientpackage/wiki/Color-Functions

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


234 views.

You need to log onto the forum to reply or create new threads.

  [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]