Tuesday, June 4, 2013

Re: How to fix <h1> id strings?

On Mon, 3 Jun 2013 16:16:08 -0700 (PDT)
Andrei Olsen <andrei.olsen@gmail.com> wrote:

> On Monday, June 3, 2013 11:07:48 PM UTC+2, stevelitt wrote:
> > This is actually two different problems:
> >
> >
> >
> > 1) Spaces can't appear in an id string
> >
> > 2) <h?> text isn't guaranteed unique
>
>
> 1) You are absolutely right, whitespaces are not allowed in id and
> name tokens. 2) Text node doesn't have to be unique, id token does.
> For example,
>
> <h1 id="heading-1">Heading</h1>
> <h1 id="heading-2">Heading</h1>
>
> is fine, while
>
> <h1 id="heading">First heading</h1>
> <h1 id="heading">Second heading</h1>
>
> is not.
>
> And finally... let's take a look at the snippet in question:
>
> snippet h1
> <h1 id="${1:heading}">${2:$1}</h1>
>
> You type h1<TAB> and you'll get <h1 id="heading">heading</h1>. Cursor
> at the first tabstop and id value is highlighted and ready to be
> replaced. Now you type a new value (it should not, actually must not,
> contain spaces; but no one is forcing you to type spaces here), this
> value is also used as a placeholder for next and final tabstop. You
> hit <TAB>, cursor moves to the second tabstop (element's text node),
> text is again highlighted and ready to be replaced. You type a new
> heading.
>
> Personally, I see no value in using the first variable as a
> placeholder for the second (for header tags anyway). I much more
> prefer the way it's done in this snippet file (it also has a final
> tabstop outside the closing tag):
>
> https://gist.github.com/smt/1112952

The value of having the id depend on the text is 1) speed, 2)
recognizeability when doing links. I enjoy having my authoring tool
make the id string for me, based on the visible string.

In my ideal world, the cursor would first go between the start and stop
tags, where I'd type my visible text. As I type my visible text, a
tweaked version of same, with punctuation removed and spaces replaced
by underscores, would appear in the id. I could probably make that
happen, but so much to do, so little time, so I just made a
Ctrl+Space+o mapping fix the id created by the current snipMate <h1>
snippet.

Thanks,

SteveT

Steve Litt * http://www.troubleshooters.com/
Troubleshooting Training * Human Performance

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment