-
October 17th, 2017, 01:49 #1
Archangel
- 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("<(/?[phbiu])>", "<%1>") .. "</p>"; elseif sText:match("^<[ph]>") then sAddDesc = sAddDesc .. UtilityManager.encodeXML(sText):gsub("<(/?[phbiu])>", "<%1>"); else sAddDesc = sAddDesc .. "<list><li>" .. UtilityManager.encodeXML(sText) .. "</li></list>"; end end
1. search for bold, underlined, or italicized text, encode that text and then strip out the xml safe tags (the < and > 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?
-
October 17th, 2017, 03:02 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,651
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
-
October 17th, 2017, 03:27 #3
Archangel
- Join Date
- Apr 2008
- Location
- Virginia Beach
- Posts
- 3,096
Thanks, MW. I was thinking backwards.
-
October 18th, 2017, 02:03 #4
Archangel
- 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)?
-
October 18th, 2017, 02:06 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,651
That’s required for the internal FG formatted text format. See the formattedtextcontrol reference in the Ruleset Reference API.
Regards,
JPG
-
October 18th, 2017, 02:49 #6
Archangel
- 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.
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.
-
October 18th, 2017, 09:55 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,651
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)
Bookmarks