Anticipative behavior

Under this concept can be difficult to imagine its real meaning. Therefore, it is in the following paragraphs I will try best to explain. And as this is a key feature Texy, an explanation will be somewhat are full. We start with a rather general:

Normally formatter work on the principle that helping a series of sophisticated regular expression scanning the input text and formatting commands found assimilated HTML tags. It's quite fast and simple way. Thus the first version worked Texy.

Let's try to demonstrate in practice how it works. Consider a very simple syntax:

  • Bold text: entered *text* and the system will confuse the <strong>text</strong>
  • Image: written as [* url *] a regular expression, it turns to <img src="url">

Create a system that those rules will reformat the text. First of all searches throughout the text the symbols denoting the bold and replace them with the appropriate HTML tags. In the second step searches for a string representing the image is also confuse the HTML element.

Very quickly but we find that the system is not working as it should. Let it formatted this entry:

 This is an image [* images / benny.jpg *] my * dog *. 

We expect this result:

 This is a picture <img src="images/benny.jpg">
my dog <strong> </ strong>. 

However, the system returns:

 This is a picture [<strong> images / benny.jpg </ strong>]
my dog <strong> </ strong>. 

Where is the problem? By replacing the first stars for signs <strong> damaging the string representing the image and the second step will be found. How out of it?

Perhaps you can think of two ways:

  • switch the order in which the substitution is realized
  • or edit the regular expression looking for stars to be ignored if the left and right bracket is found by an asterisk.

Unfortunately, neither solution is perfect. Invert expressions is just breaking wedge wedge. The system collapses to the input text:

 This is an unusual image url:
[* / Images / * my * / foto.jpg *] 

In the first step can be adjusted to the form:

 This is an unusual image url:
[* / Images / <strong> my </ strong> / foto.jpg *] 

And in the second step:

 This is an unusual image url:
<img src = "/ images / <strong> my </ strong> / foto.jpg"> 

But the user did not intend this result. The address did not have the brand image <strong> but ordinary stars. You can argue that the stars are unusual in the address. Granted, but there may appear. Then the solution is not one hundred percent.

And what kind of solution? Not much better. It requires superhuman effort from the programmer: it must identify all the possible interference of regular expressions. Regular expressions become more complicated. Moreover, the universality of the system disappears, any change in the syntax will require difficult adjustments of all terms. Such an approach is only spawns for severe odhalitelných errors. Again, the solution is not one hundred percent.

How do Texy

And now, when both normal formatting means failed appears on the scene Texy. A save situation :-)

But forsake advertising jargon. She actually reality is that well-known and popular formatter (Textile, Markdown, ...) on similar structures reliably collapsed. Therefore Texy also arose from the requirement for proper formatter with očekávatelným behavior.

The advantage of using only Texy is wholly techniques. Priority is not speed, but the perfection and perfection of the transfer. This differs from the competition.

Still do not believe?

Consider the popular converter Textile. Its syntax says that the text enclosed between the stars will be highlighted mark <strong> the text underscores the brand <em> Moreover, it is possible immediately after the first underscore to use a modifier, such as _ (class) text_. However, if we use the modifier Stars, Textile Confuse and return undue result. Try to get your word format:

 _ (* this * the Textile) nezvládne_ 

But do not want Textile crashing - on the contrary, it is a great tool!