jEdit Community - Resources for users of the jEdit Text Editor
jEdit Modes: Am I using at_word_start right?
Submitted by hurricanedavid on Wednesday, 2 April, 2014 - 16:50
I have a basic edit mode I'm creating and I want to make words bold when they have asterisks around them. This does it, but I'd rather have it work only if the * is right next to a word. The docs seem to say I can do it this way.

< SPAN TYPE="KEYWORD1" NO_LINE_BREAK="TRUE" AT_WORD_START="TRUE" >
< BEGIN >*< /BEGIN >
< END >*< /END >
< /SPAN >

In other words, I want *this to be bold*
But * this should not be bold *
Right now, both are getting bolded.

Thanks!
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Work-around
by hurricanedavid on Fri, 11/04/2014 - 20:52
Folks on the email list suggested I switch to the span_regexp tag instead. This works to get the start right, but if I omit the ending asterisk, this still applies the KEYWORD1 to it. But right now, I'll take what I can get.

<SPAN_REGEXP TYPE="KEYWORD1" HASH_CHAR="*" NO_LINE_BREAK="TRUE">
<BEGIN>\*\b</BEGIN>
<END>*</END>
</SPAN_REGEXP>
 
Positive Lookahead to the rescue
by Vampire on Thu, 15/05/2014 - 10:24
As you do not support line breaks, you can simply use a positive lookahead like so:

<SPAN_REGEXP TYPE="KEYWORD1" HASH_CHAR="*" NO_LINE_BREAK="TRUE">
    <BEGIN>\*\b(?=.*\b\*)</BEGIN>
    <END>*</END>
</SPAN_REGEXP>

This will at least not highlight from the sole asterisk on a line to the end but only match if there is another asterisk that follows a word immediately. Unfortunately the tag does not support regexps, so it will highlight "*bar *" in "foo *bar * baz* bam", but only if the third asterisk is present.
User login
Browse archives
« September 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   99925
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300