Difference between revisions of "NeoText Markup Language"

From Spherical
Jump to: navigation, search
(created from http://web.archive.org/web/20111224204146/http://www.spheredev.org/wiki/NeoText_Markup_Language)
 
(Syntax: cleanup)
Line 11: Line 11:
 
Recommended syntaxes for a string to be parsed (uses HTML style tags encased in < and >):
 
Recommended syntaxes for a string to be parsed (uses HTML style tags encased in < and >):
  
* <tag>any necessary text</tag> - a "tag" element with no properties properly opened and closed
+
* '''<tag>'''any necessary text'''</tag>''' - a "tag" element with no properties properly opened and closed
* <tag prop1=val prop2 >any necessary text</tag> - a "tag" element with variable properties properly opened and closed
+
* '''<tag''' ''prop1=val prop2'' '''>'''any necessary text'''</tag>''' - a "tag" element with variable properties properly opened and closed
* <tag/> - an empty "tag" element with no properties (although I'm sure there can be one written to have properties as well)
+
* '''<tag/>''' - an empty "tag" element with no properties (although I'm sure there can be one written to have properties as well)
  
 
===About the Tech Demo===
 
===About the Tech Demo===

Revision as of 22:10, 3 June 2013

NTML example (resolution: 320 * 240 * 32)

The NTML system is a custom script written by NeoLogiX. It is a markup parser that takes text similar to HTML and transforms it much like HTML or a word processor can.

Download and Usage

Getting started

Download the NTML tech demo at http://sphere.sourceforge.net/neologix/files/ntml.zip. The tech demo contains my NFont object (I usually just call it Font object when I write it mostly for myself) parsing an NTML object using an HTML style grammar.

Syntax

Recommended syntaxes for a string to be parsed (uses HTML style tags encased in < and >):

  • <tag>any necessary text</tag> - a "tag" element with no properties properly opened and closed
  • <tag prop1=val prop2 >any necessary text</tag> - a "tag" element with variable properties properly opened and closed
  • <tag/> - an empty "tag" element with no properties (although I'm sure there can be one written to have properties as well)

About the Tech Demo

The tech demo defines a custom grammar inside an NFont with which to parse an NTML object. I found it easier this way, and also more extensible. The grammar is HTML style (for visual markup), and is as follows (currently the NTML code is written so that the element tags are case-sensitive; it shouldn't be hard to modify it so that it's case-insensitive):

Element Tags

font - general purpose marked up font element

Available Properties for Element "font"

bgcolor=color - change the background color of the selected text; color can either be the name of a previously declared color variable or hex; hex can be either an HTML compatible 6 digit hexadecimal string or an 8 digit hexadecimal string (which is an HTML style 6 digit hex string plus an extra 2 digit hexadecimal string for the alpha channel); is evaluated before ALL the other font properties in tech demo color=color - change the color of the selected text; color can either be the name of a previously declared color variable or hex; hex can be either an HTML compatible 6 digit hexadecimal string or an 8 digit hexadecimal string (which is an HTML style 6 digit hex string plus an extra 2 digit hexadecimal string for the alpha channel); is evaluated third in tech demo bold=bool - boldfaces the selected text by adding a drop shadow behind the text; bool can either be the string "true," "false," 0, or 1 (the strings must not have quotation marks); is evaluated second in tech demo italic=bool - italicizes the selected text; bool can either be the string "true," "false," 0, or 1 (the strings must not have quotation marks); is evaluated fourth in tech demo decor=decoration - adds line decoration to the selected text; decoration is a | (vertical pipe) delimited string that can contain one or more of the following strings (with no quotation marks surrounding them): "uline" (underline), "oline" (overline), "thru" (strikethrough) (an example would be decor=uline|oline generating an underline and overline in the selected text); is evaluated last in tech demo

Tech Demo Usage

The tech demo is a self-contained Sphere game. It has three fonts it uses as an example: MS Mincho (Sphere conversion of Windows font), S_Capt (one of my custom made caption fonts), and Square 1 (a pixel-by-pixel recreation of the monospaced Chrono Trigger font). You can rewrite the code to choose between any of them, though you'll get the best results with Mincho, then Square 1. The demo loads a windowstyle (otherwise a background would be harder to notice), draws the window, then creates an NTML object and draws the parsed version on the window. It flips the screen, waits for a key, then outputs a text log of the structure of that NTML object for later reading.

Notes

"NTML" stands for "NeoText Markup Language" and the concept is based largely on a script written for Sphere by LinkMasterSab (now known as Paragon) called MML (Marble Markup Language). The intent was to create a script that could successfully parse marked up text and successfully display the text onscreen in its marked up form, much like a web browser handles HTML. I feel the primary goal of simply creating this system has been accomplished in what I call NTML 1.0 (and yes, I hope it evolves likes HTML), with the ability to boldface, italicize, underline, overline, and strikethrough text, as well as the ability to change the colors of the background and the text itself. Major revisions will result in a +1 (a major revision being something such as adding animation effects like blink or typewriter), while minor revisions will either result in a +0.1 or +0.01 (a minor revision being something such as creating an alias for an existing markup, such as aliasing as ).

Disclaimer

Throughout the tech demo I have written many notes, mostly new tags for me to implement in future releases of NTML-NFont. If anybody would like to extend NFont's capabilities by adding the ability to parse those noted tags (and any others you'd like) properly I give full permission, as long as you fulfill the following conditions: credit goes to me for the system as it is currently distributed; credit goes to Paragon for originally creating MML in Sphere, on which NTML is based; a copy of the extended script is sent to me for approval and updating NTML as it stands. I, Alex Rosario aka NeoLogiX, reserve the right to modify any and all code submitted with regards to NTML for any and all reasons whatsoever, though there is a 99.9999999% chance I will credit you for submitting the function. Any ideas submitted with regards to NTML will be credited as such, though there's a good chance I probably already thought of including it into a future release of NTML. You are free to modify NTML code for your own personal use as long as 1. you know what you are doing, 2. you credit me and Paragon if you choose to distribute it, 3. you allow others to modify it along the same permissions granted to the original NTML code. If you choose to distribute NTML unchanged you are NOT allowed to take credit for writing it.

I know it seems like a lot of disclaimer, but I definitely could have been much more limiting. In essence, there are tags which can be added which I have not. If you like, add them yourself, but send me a copy so I can include it in official NTML releases. If you use NTML in your project, credit me for NTML and Paragon for MML (who was not, is not, and will not be affiliated with NTML unless I am told otherwise). If you edit NTML, send me a copy, credit me and Paragon, and make sure you allow it to be edited like NTML can be. Other than that, you are free to experiment with NTML as you wish.

P.S. I like Sulphur21's custom script entry style, so I'll be using that from now on as well. - NeoLogiX