5E Storm Kings Thunder Playlist
  1. #1

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096

    TableManager Moon Wizard Question

    MW, you have the following in the onTableRoll handler of the manager_table.lua file:
    Code:
    				elseif (bTopTable or (#v.aTableLinks == 0)) then
    					if sText:match("^<[biu]>") then
    						sAddDesc = sAddDesc .. "<p>" .. UtilityManager.encodeXML(sText):gsub("&lt;(/?[phbiu])&gt;", "<%1>") .. "</p>";
    					elseif sText:match("^<[ph]>") then
    						sAddDesc = sAddDesc .. UtilityManager.encodeXML(sText):gsub("&lt;(/?[phbiu])&gt;", "<%1>");
    					else
    						sAddDesc = sAddDesc .. "<list><li>" .. UtilityManager.encodeXML(sText) .. "</li></list>";
    					end
    				end
    This code is in the section that outputs table rolls to a story window. What it appears to do is:
    1. search for bold, underlined, or italicized text, encode that text and then strip out the xml safe tags (the &lt; and &gt after the XML encoding.
    2. do the same for paragraph and heading tags in text.
    3. if the text doesn't have any of the tags, surround it with xml encoded text bounded by table tags (<list><li>)

    Later, the text is then saved to the story data node.

    So, the questions I have are:
    1. Why encode the text with encodeXML and then go to the trouble to reverse the encoding for the text formatting tags?
    2. Does the DB.setValue call with a formattedtext type field not do the xml encoding?
    3. If the answer to #2 is yes, then why is it necessary to explicitly encode the generated table text in the code above?
    4. If the answer to #2 is no, then how does the '<' character which is forbidden in xml (other than tags) ever get encoded since you are stripping the encoding out?

  2. #2
    1. This allows people to specify formatting in their table for story output. (Just p/h/b/i/u tags) This was a feature request.
    2. No, it does not. The setValue for formattedtext database nodes assumes you pass it valid XML, using FG formattedtext tags and encoded text. Otherwise, we wouldn't know which tags should be encoded, and which ones shouldn't.
    3/4. If you look at the pattern matching, we are explicitly only rewriting these tags back to XML. (<p>, <h>, <b>, <i>, <u>, </p>, </h>, </b>, </i>, </u>) Thus, any other uses of the <> characters will be encoded.

    Regards,
    JPG

  3. #3

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Thanks, MW. I was thinking backwards.

  4. #4

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    One follow-up, MW. Why did you put paragraph markings around text markup except for headings? (obviously, you didn't want to nest them around user-inserted paragraph tags)?

  5. #5
    That’s required for the internal FG formatted text format. See the formattedtextcontrol reference in the Ruleset Reference API.

    Regards,
    JPG

  6. #6

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Hey, MW, that section of the documentation seems to have an error. In the 'table' tag section it says:

    table - Indicates a table. Tables can not be created or edited, only accessed via modules created outside of FG.
    This leads one to think you cannot edit a table in the interface, but above that, in the list of keyboard commands is the following:


    CTRL+TAB - Insert new cell in table, or assign speaker to chat text.
    CTRL+PLUS - Increase column width of table cell by one.
    CTRL+MINUS - Decrease column width of tabel cell by one.
    Maybe I am not understanding something....

  7. #7
    When the documentation gets updated, we typically upgrade the existing documentation. The note about being unable to create tables in the user interface looks like a leftover note from a time when that was true. (It was true when I started working on FG.) I’ll note it for a fix.

    JPG

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in