Document (globalcampus.site/namespace.stxt): Chapter 8: Examples and Other Technologies Default: Title: STXT: The Book Navigation: Previous: Previous (07-parser) Next: Next (09-semantic-web) Metadata: Title: Chapter 8: Examples and Other Technologies Description: Various examples of STxT are shown, and comparisons with other popular languages are made. Author: Joan Costa Mombiela last modif: 2013-03-01 Header: Examples Content: There are thousands of examples that can be made with this technology. It is as simple as taking any example from another language and seeing how it would be written in @STxT@. Perhaps the simplest is an example derived from XML, as it has many parallels with @STxT@. Many examples I have obtained from [Wikipedia](https://www.wikipedia.org). An (invented) example of XML would be: Code: The Fellowship of the Ring J.R.R. Tolkien EN 29 July 1954 High fantasy Adventure The Two Towers J.R.R. Tolkien 76542 EN 11 November 1954 High fantasy Adventure The Return of the King J.R.R. Tolkien 12345 EN 20 October 1955 High fantasy Adventure Content: The same in @STxT@: Code: Library (www.examples.com/demo.stxt): Book: id: 1 Title: The Fellowship of the Ring Author: J.R.R. Tolkien Language: EN Published: 29 July 1954 Genre: High fantasy Adventure Book: id: 2 Title: The Two Towers Author: J.R.R. Tolkien ISBN: 76542 Language: EN Published: 11 November 1954 Genre: High fantasy Adventure Book: id: 3 Title: The Return of the King Author: J.R.R. Tolkien ISBN: 12345 Language: EN Published: 20 October 1955 Genre: High fantasy Adventure Content: Another example in XML: Code: John Smith Mery Adams Keyla Brown Project report Hello Mery!! The book is finished!! Content: In @STxT@, it is transformed into: Code: Email (www.example.com/email.stxt): From: John Smith To: Mery Adams Cc: Keyla Brown Title: Project report Body: Hello Mery!! The book is finished!! Content: We can see that the conversion between the two formats is instant, though @STxT@ is much more aesthetically pleasing. By the way, there is a hidden chapter, [STXT and XML](08-stxt-xml), in case you want to read it. I wrote it in 2013, and it's... interesting. Read at your own risk ;-) Header: Wikipedia (*) Content: I have great admiration for Wikipedia. I think it is one of the best projects created on the Internet. _How could it benefit from @STxT@?_ Well, Wikipedia could have different templates: actors, politicians, TV series, movies, cities, countries, rivers... sharing grammars in many cases. For example, both actors and politicians can have biographies, but actors would also have a list of movies. Moreover, it would be very interesting to mix @STxT@ with Wikipedia's own language. I think this is a point where @STxT@ excels compared to most languages. The blend with so-called "lightweight markup languages" is truly spectacular. So, you can create mixed texts like this: Code: City (www.wikipedia.org/city.stxt): Name: Barcelona Autonomous Community: Catalonia Country: Spain History: {{Main|History of Barcelona}} The founding of Barcelona is the subject of two different legends. The first attributes the founding of the city to the mythological [[Hercules]]. The second legend attributes the foundation of the city directly to the historical [[Carthage|Carthaginian]] [[Hamilcar Barca]], father of [[Hannibal]], who named the city ''Barcino'' after his family in the 3rd century BC. ... Content: Another advantage is that with @STxT@ we would not only have "templates" of what city information should look like, but we could also apply styles and formats depending on the type of document. Header: @STxT@ and Other Technologies Subheader: Lightweight Markup Language Content: Lightweight markup languages have seen a spectacular rise thanks to projects like Wikipedia. Thanks to them, text can be defined much more simply than having to write tags like HTML. But they have a major drawback: They do not have a clear structure or semantics. In fact, practically all of them focus on text styling: * Bold * Italics * Lists of items * Data tables * ... It is surprising to see what we can achieve by combining these languages with @STxT@. We get text that is easy to interpret, with defined semantics, and the expressiveness of both languages. An example: Code: Product: Name: Magic memory Price: 10€ Description: This product produces a _magical rejuvenation_ of memory and provides an **immediate** effect on all those who try it. Effects: * Rapid memorization * Automatic learning * Increased concentration Content: We see that we have given structure thanks to @STxT@, but the description is given in Wikipedia style. Assert: The combination of @STxT@ with _Lightweight markup languages_ is simply spectacular Subheader: TeX, LaTeX Content: Apologies if I criticize too much. I never do it without offering an alternative or a reason. I like constructive criticism ;-) I have seen that one of TeX's goals is for a document to print the same now and 100 years from now. I thought that was perfect... until today. Now I think the goal should be for it to mean the same thing now and 100 years from now, and for it to be _understood_ now and 100 years from now. And by as many people as possible. This is not achieved with TeX, but it is with @STxT@. A document is understood today and 100 years from now. How do I think it should evolve? I would create documents in @STxT@, specify a grammar for the different types of documents, allow TeX elements (like formulas) in the same way that lightweight markup languages do, and use TeX as the rendering engine. I dare say that TeX is unbeatable in terms of rendering; and I think it will remain so for at least 100 more years ;-) What would a document look like? Well, a simple example would be something like this: Code: Article (www.latex.com/article.stxt): Title: Author: References: Reference: Title: Year: ISBN: Reference: Title: Year: ISBN: Paragraph: This is a mathematical formula: Formula: \begin{eqnarray} x&=&y\\ x^2&=&xy\\ x^2-y^2&=&xy-y^2\\ (x+y)(x-y)&=&y(x-y)\\ x+y&=&y\\ 2y&=&y\quad \mbox{(first equation)}\\ 2&=&1 \end{eqnarray} Paragraph: Hello World!! Content: In fact, now that we can think about @STxT@, it might be time to create formulas in another way, or a more simplified notation, such as: Code: Article (www.latex.com/article.stxt): Title: Author: References: Reference: Title: Year: ISBN: Reference: Title: Year: ISBN: Paragraph: This is a mathematical formula: Formula: Array: Element: x&=&y Element: x^2&=&xy Element: x^2-y^2&=&xy-y^2 Element: (x+y)(x-y)&=&y(x-y) Element: x+y&=&y Complex: Element: 2y&=&y\quad Element: mbox{(first equation)} 2&=&1 Paragraph: Hello World!! Content: Well, there are thousands of possibilities and ways to approach the problem; I'll leave it to you as an exercise ;-D Assert: What have we gained compared to just TeX? Content: * Ease of document creation * UTF-8 * Defined structure * Semantic text * Readable text And also, we have maintained the compactness in the creation of mathematical formulas and other elements where TeX is indeed a great language. Subheader: JSON Content: JSON initially has nothing to do with @STxT@, but there are certain times when they might compete. I am thinking of configuration files, for example. Furthermore, it is more flexible and easier to read when embedding large amounts of text, something that always needs to be considered with JSON due to escaping characters. But there is no need to worry too much. I do not think JSON and @STxT@ are direct competitors, due to their different areas of application. Subheader: YAML Content: Perhaps YAML is the one that most resembles @STxT@ in approach, although it is also very different. We believe that with our structure, we can show the same as YAML, and much more simply. Additionally, we can add semantics to the document with namespaces, while still allowing text that is readable to most people, regardless of their technical knowledge.