I just had a little idea for a symbol list in markdown, and thought other people might be interested in it. I wanted to get the symbol list to show the first 8 or so words of each paragraph, kind of like a mini summary. You can accomplish this by creating a new preferences file, pasting the following code in it and setting its scope to: "text.html.markdown markup.paragraph"
/* preferences */ { showInSymbolList = '1'; symbolTransformation = 's/^([A-Z](([^ \t]*[ \t]*){1,8})).*$/$1/g;'; }
This is supposed to only pick lines that start with a capital letter. For some reason though, it doesn't. Any ideas?
Haris
On 4/12/2005, at 6:48, Charilaos Skiadas wrote:
[...] This is supposed to only pick lines that start with a capital letter. For some reason though, it doesn't. Any ideas?
Well, the transformation only picks up lines which start with A-Z, the scope select still selects all paragraphs.
You could do something like this instead:
symbolTransformation = ' s/^\W.*/-/m; s/(\w+(?:\W+\w+){,7})\W*(.+)?/$1(?2:…)/m; ';
Here I first replace all lines that start with a non-word character to '-', which appear as a divider in the list (I actually wanted to replace them with nothing, but TM picks up empty entries, which it shouldn't).
I went a little overboard with the second line, it matches up to 8 words, and only when there is a 9th word, will it insert an ellipsis.
The /m option is just to make . match newlines. Probably not necessary, as I don't think these get included by the scope selector.
On Dec 4, 2005, at 1:22 AM, Allan Odgaard wrote:
You could do something like this instead:
symbolTransformation = ' s/^\W.*/-/m; s/(\w+(?:\W+\w+){,7})\W*(.+)?/$1(?2:…)/m; ';
Hm, doesn't work over here. Tried these lines: {
markdown will pick up
this line
And this too
works well with long lines though, puts the ellipses as promised
}
It actually picks up all these lines, and does the ellipses nicely. This is how my preferences file looks:
/* preferences */ { showInSymbolList = '1'; symbolTransformation = ' s/^\W.*/-/m; s/(\w+(?:\W+\w+){,7})\W*(.+)?/$1(?2:…)/m; '; }
Haris
On Dec 4, 2005, at 2:02 AM, Allan Odgaard wrote:
Ah, the first regexp subst. should of course have been:
s/^[^[:upper:]].*/-/m;
\W will match all non-word characters, I wanted all non-uppercased (word) characters.
Excellent, this works great, except for the many extra separators of course. Oh well, can't have everything :-)
Haris