cloutiy / tml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a "escape" char - '\'

cloutiy opened this issue · comments

commented

Identify a way to escape literals, basically <> [] {} || (if
this last remains in tml).

commented

so please tell me, do I just need to find a way to escape <>{}[] and \

Yep. That's what I'm saying.

To review:
We encountered a problem with inline comments.

tml is a typesetting markup language, therefore we can make no
assumptions about which characters are wanted literally.

Without an "escape sequence" character (escape character), there is
no way to guarantee that any glyph or combination thereof, chosen
to start inline comments, will not also, on occasion, be wanted
literally.

The solution is to require an escape character before the comment
character when it's used inline. The backslash is an obvious
choice.

The problem with an escape character is that it may be required
literally from time to time. The solution is to double it when it's
wanted literally.

Sample tml (line numbers are for reference only):

1  ! This is a single line comment
2  The backslash character followed by an exclamation mark, \! Inline comment.
3  i.e. \\!, introduces an inline comment.

Match/replacement:

Match 1:

^!

Replace:

  \# This is a single line comment

Match 2:

\!

Replace:
The backslash character followed by an exaclamation mark:

\" This is an inline comment.

Match 3:

\\!

Replace (none):

  i.e. \\!, introduces an inline comment.

In short, with the doubling mechanism, you never have to match other
than ^! and \!for comments.

Now, since the possibility exists that confusion may arise in the
parser concerning the use of other tml-reserved glyphs, it makes all
kinds of programming sense to require a backslash before them to say
"print these literally"--even if you can't see the need right now.
Thus, e.g., \< for an non-interpreted left angle-bracket and \{ for
a non-interpreted left brace, etc.

How would all this sound to the user?

Pseudo-documentation on comments:

A line beginning with ! is treated as a comment, and silently
ignored. For inline comments, precede ! with a backslash.

Pseudo-documentation on characters with special meaning in tml:

Configuration directives are enclosed in curly braces. If you
want literal curly braces, precede them with a backslash.

Pseudo-documentation on the backslash:

The backslash has a special meaning in tml. If you want a literal
backslash, precede it with another backslash.

Sorry to go on so long about this. It's one of those situations
I've encountered before, where something is blazingly evident to one
person and the other just can't see it. The problem with blazingly
evident is that it's really hard to unravel so that the other person
gets it. Like explaining satori after you've achieved it.

another question. would it not be easier to implement \ escape
in MOM rather than TML?

Not even possible. The interpretation of the backslash is hardwired
into groff and can't be changed at the macro level.

commented

I think my confusion is that other than needing to escape the ! for inline comments, I don't understand the real problem.

I am matching patterns, not going and scanning character by character.

If someone wants to use a curly brace I'm not preventing them. I am looking for patterns:

match exactly curly brace followed by 0 or more spaces followed by this specific text, a colon, maybe some space and a some more text, all this followed by another curly brace. ( {chapter-left-string: Title} )

I'll be damned if they use a curly brace, because I'm not looking for a pattern of a single curly brace. This is why I'm a bit confused. Maybe you can give me an example where you got stuck and wasn't able to add a curly brace? That will help me understand the problem.

Same with square brackets. Im matching very specific patterns: [ followed by maybe some space then the word chapter then maybe some space then another ].

Nothing is preventing someone from using a square bracket...cause TML is not doing anything with square brackets, other than matching very specific pattern. Maybe an example of where you ran into this problem of not being able to use square brackets? That will help me understand the problem.

Same with the backslash. if someone wants to use a backslash , they can sure go ahead. TML is not looking for them and not doing anything with them. Dont really see the need to double them.

I know you see a problem, and I am trying to see what you see, by narrowing down one by one.

commented

Done.