Discussion:
[t2t] Custom Sections
Kevin
2012-05-25 23:40:28 UTC
Permalink
Hello,

I was thinking about switching some documents to t2t after finding some
limitations in other plain-text mark-up languages.

The biggest thing that I would like to see is some sort of named
sections. For example if I want to put a warning or sidenote it would
be nice to have it delimited by a colored box or other thing. I noticed
that a lot of output formats support some time of section or division
that can be styled.

If I want to limit my docs to html I can simply use: ''<div
class="warning">'' and ''</div>'' but then I can only get html output
(and AFAIK there are no conditional macros).

I think that this is a common feature and it would be nice to have some
syntax for it. My first thoughts are "{{class text}}" for inline and
"{{{class line" for one line and "{{{class" closed with "}}}" for
multi-line. I chose braces because they have different opening and
closing allowing nesting and I tried to match your syntax for quoted and
non-parsed areas. Also the name-space combination matches links.

I was thinking that you could add a separator if you wish ("{{{class: ...").

I was wondering what you guys think. I'm sorry if something like this
was proposed but I couldn't find any record of it.
Little Girl
2012-05-26 01:52:15 UTC
Permalink
Hey there,
Post by Kevin
The biggest thing that I would like to see is some sort of named
sections. For example if I want to put a warning or sidenote it
would be nice to have it delimited by a colored box or other
thing. I noticed that a lot of output formats support some time of
section or division that can be styled.
If I want to limit my docs to html I can simply use: ''<div
class="warning">'' and ''</div>'' but then I can only get html
output (and AFAIK there are no conditional macros).
I think that this is a common feature and it would be nice to have
some syntax for it. My first thoughts are "{{class text}}" for
inline and "{{{class line" for one line and "{{{class" closed with
"}}}" for multi-line. I chose braces because they have different
opening and closing allowing nesting and I tried to match your
syntax for quoted and non-parsed areas. Also the name-space
combination matches links.
I was thinking that you could add a separator if you wish
("{{{class: ...").
I was wondering what you guys think. I'm sorry if something like
this was proposed but I couldn't find any record of it.
I'm not sure if this would be of use to you, but I made two example
txt2tags documents that create web pages using CSS. One uses style
and the other uses css-sugar. The style method customizes entire
pages. The css-sugar method divides pages into zones, allowing for
quite extensive customization. If you'd like to see these in action,
you can get them here:

http://host-a.net/littlegirl/txt2tagsCSS.zip

Enjoy! (:
--
Little Girl

There is no spoon.
Kevin
2012-05-26 03:59:08 UTC
Permalink
Post by Little Girl
I'm not sure if this would be of use to you, but I made two example
txt2tags documents that create web pages using CSS. One uses style
and the other uses css-sugar. The style method customizes entire
pages. The css-sugar method divides pages into zones, allowing for
quite extensive customization. If you'd like to see these in action,
http://host-a.net/littlegirl/txt2tagsCSS.zip
Thanks for the example but that is not what I'm looking for. Hopefully
this example helps.

HTML:

<p>This piece of software does things.</p>
<p class="warning"> There is a small chance that it will kill your cat,
use with caution.</p>

This way I can style that warning message into a pretty little box with
an exclamation mark image in the background. Getting the <p> element
might be hard to do but something like this would be fine.

<p>This piece of software does things.</p>
<div class="warning"><p> There is a small chance that it will kill your
cat, use with caution.</p></div>

Then you write some fancy CSS.

.warning {
/* fancy css */
}
.warning p {
/* more fancy css */
}

I hope you understand what I am going for. According to my proposed
syntax it would be written like so.

~~~~~~~~~~~
This piece of software does things.

{{{warning There is a small chance that it will kill your cat, use with
caution.
~~~~~~~~~~~

And seeing that I like the separator idea.

~~~~~~~~~~~
This piece of software does things.

{{{warning| There is a small chance that it will kill your cat, use with
caution.
~~~~~~~~~~~

Thanks for the help.
Little Girl
2012-05-26 06:26:13 UTC
Permalink
Hey there,
Post by Kevin
Thanks for the example but that is not what I'm looking for.
Hopefully this example helps.
<p>This piece of software does things.</p>
<p class="warning"> There is a small chance that it will kill your
cat, use with caution.</p>
This way I can style that warning message into a pretty little box
with an exclamation mark image in the background. Getting the <p>
element might be hard to do but something like this would be fine.
<p>This piece of software does things.</p>
<div class="warning"><p> There is a small chance that it will kill
your cat, use with caution.</p></div>
Then you write some fancy CSS.
.warning {
/* fancy css */
}
.warning p {
/* more fancy css */
}
I hope you understand what I am going for. According to my proposed
syntax it would be written like so.
~~~~~~~~~~~
This piece of software does things.
{{{warning There is a small chance that it will kill your cat, use
with caution.
~~~~~~~~~~~
And seeing that I like the separator idea.
~~~~~~~~~~~
This piece of software does things.
{{{warning| There is a small chance that it will kill your cat, use
with caution.
~~~~~~~~~~~
Thanks for the help.
Hmmm, the only thing that comes to mind is either preproc or
postproc, and you've probably already tried those. Sorry!
--
Little Girl

There is no spoon.
Forgeot Eric
2012-05-26 18:15:50 UTC
Permalink
I think you can use something like this to achieve your effect:

%!postproc(html): '\{\{\{warning (.*?)$' '<p class="warning">\1</p>'

The only problem I see so far is that it will add a double < p >
I hope you understand what I am going for.  According to my proposed
syntax it would be written like so.
~~~~~~~~~~~
This piece of software does things.
{{{warning There is a small chance that it will kill your cat, use
with caution.
~~~~~~~~~~~
Forgeot Eric
2012-05-26 19:09:44 UTC
Permalink
To avoid the problem of the double < p >, you can also use a div class instead of a p class, it's what I usually do in fact.




----- Mail original -----
De : Forgeot Eric <***@yahoo.fr>
À : txt2tags mailing list <txt2tags-***@lists.sourceforge.net>
Cc :
Envoyé le : Samedi 26 mai 2012 20h15
Objet : [t2t] Re : Custom Sections

I think you can use something like this to achieve your effect:

%!postproc(html): '\{\{\{warning (.*?)$' '<p class="warning">\1</p>'

The only problem I see so far is that it will add a double < p >
I hope you understand what I am going for.  According to my proposed
syntax it would be written like so.
~~~~~~~~~~~
This piece of software does things.
{{{warning There is a small chance that it will kill your cat, use
with caution.
~~~~~~~~~~~
Kevin
2012-05-27 01:57:43 UTC
Permalink
Post by Forgeot Eric
%!postproc(html): '\{\{\{warning (.*?)$' '<p class="warning">\1</p>'
The only problem I see so far is that it will add a double < p >
Yes I could do this but is there any way to do a conditional postproc?
Otherwise I am limiting myself to HTML output. That's why I think it
would make sense as a language feature because it is cross-target.
Forgeot Eric
2012-05-27 09:51:07 UTC
Permalink
yes, the conditional postproc is enabled by adding the target between brackets, like in my example (html). This way if you want to remove the special marks for a LaTeX output, add this for example:
%!postproc(tex): '\{\{\{warning' ' '


About adding this particular option to txt2tags, it would probably be useful only for html, and I don't think it would be accepted, especially when we can use pre or postproc to add those features.




----- Mail original -----
De : Kevin <***@gmail.com>
À : Forgeot Eric <***@yahoo.fr>; txt2tags mailing list <txt2tags-***@lists.sourceforge.net>
Cc :
Envoyé le : Dimanche 27 mai 2012 3h57
Objet : Re: [t2t] Re : Custom Sections
Post by Forgeot Eric
%!postproc(html): '\{\{\{warning (.*?)$' '<p class="warning">\1</p>'
The only problem I see so far is that it will add a double < p >
Yes I could do this but is there any way to do a conditional postproc?
Otherwise I am limiting myself to HTML output.  That's why I think it
would make sense as a language feature because it is cross-target.
Forgeot Eric
2012-05-27 18:03:57 UTC
Permalink
----- Mail original -----
Post by Forgeot Eric
%!postproc(tex): '\{\{\{warning' ' '
Oh, I missed that. Thanks.
you're welcome. Don't hesitate if you have further questions.
Post by Forgeot Eric
useful only for html, and I don't think it would be accepted,
especially when we can use pre or postproc to add those features.
Okay, I could see it work with a couple formats but the rest would be a
pain to get anything working right.
txt2tags is following the KISS principe ( see https://en.wikipedia.org/wiki/KISS_principle ), so it means only "simple" bricks will be made available, and people are left to extend txt2tags themselves, with the power of the pre and postproc, so the possibilities are virtually endless.

Now we only need to make such tips available as examples on the website, or when it's already here (like this one: http://txt2tags.org/tips.html#html-custom-tags ), make it more visible to all users.
Continue reading on narkive:
Loading...