Description
Line numbers toggling javascript works buggy, when highlight parser without parameters supplied.
Steps to reproduce
Add code block with highlight parser without setting highlight parser parameters
Example
Component selection
- highlight parser
Details
MoinMoin Version |
1.9.0rc1 |
OS and Version |
Mozilla Firefox-3.6 3.6b2pre, Linux 2.6.24-24-generic SMP i686 |
Python Version |
|
Server Setup |
|
Server Details |
|
Language you are using the wiki in (set in the browser/UserPreferences) |
|
Workaround
1 --- orig_moin/moin-1.9.0rc1/MoinMoin/parser/highlight.py 2009-11-03 02:41:42.000000000 +0300
2 +++ highlight.py 2009-11-15 18:08:03.000000000 +0300
3 @@ -116,13 +116,14 @@
4 self.request = request
5 self.raw = raw.strip('\n')
6 self.filename = filename
7 +
8 if self.parsername == 'highlight':
9 # user is directly using the highlight parser
10 parts = format_args.split(None)
11 if parts:
12 self.syntax = parts[0]
13 else:
14 - self.syntax = ''
15 + self.syntax = 'text'
16 if len(parts) > 1:
17 params = ' '.join(parts[1:])
18 else:
19 @@ -134,10 +135,14 @@
20 self.show_nums, self.num_start, self.num_step, attrs = parse_start_step(request, params)
21
22 def format(self, formatter):
23 + _ = self.request.getText
24 +
25 fmt = PygmentsFormatter(formatter)
26 fmt.result.append(formatter.div(1, css_class="highlight %s" % self.syntax))
27 self._code_id = hash_new('sha1', self.raw.encode(config.charset)).hexdigest()
28 - fmt.result.append(formatter.code_area(1, self._code_id, self.parsername, self.show_nums, self.num_start, self.num_step))
29 +
30 + msg = None
31 +
32 if self.filename is not None:
33 try:
34 lexer = pygments.lexers.get_lexer_for_filename(self.filename)
35 @@ -148,8 +153,9 @@
36 try:
37 lexer = pygments.lexers.get_lexer_by_name(self.syntax)
38 except pygments.util.ClassNotFound:
39 - fmt.result.append(formatter.text('#!%s\n' % self.syntax))
40 + msg = _("Lexer \"%s\" not found. Rendering as plain text.") % self.syntax
41 lexer = pygments.lexers.TextLexer()
42 + fmt.result.append(formatter.code_area(1, self._code_id, self.parsername, self.show_nums, self.num_start, self.num_step, msg))
43 pygments.highlight(self.raw, lexer, fmt)
44 fmt.result.append(formatter.code_area(0, self._code_id))
45 fmt.result.append(formatter.div(0))
1 --- orig_moin/moin-1.9.0rc1/MoinMoin/formatter/text_html.py 2009-11-03 02:41:41.000000000 +0300
2 +++ text_html.py 2009-11-15 18:08:18.000000000 +0300
3 @@ -859,7 +859,7 @@
4 </script>
5 """
6
7 - def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1):
8 + def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1, msg=None):
9 """Creates a formatted code region, with line numbering.
10
11 This region is formatted as a <div> with a <pre> inside it. The
12 @@ -885,6 +885,12 @@
13 # id in here no longer used
14 self._code_area_state = [None, show, start, step, start]
15
16 + if msg != None:
17 + attr = {'class': 'codemsg'}
18 + res.append(self._open('div', attr={ 'class' : 'codemsg' }))
19 + res.append(self.text(msg))
20 + res.append(self._close('div'))
21 +
22 # Open the code div - using left to right always!
23 attr = {'class': 'codearea', 'lang': 'en', 'dir': 'ltr'}
24 res.append(self._open('div', attr=attr))
1 --- common.css.old 2009-11-15 18:12:46.000000000 +0300
2 +++ common.css 2009-11-15 18:17:56.000000000 +0300
3 @@ -305,6 +305,19 @@
4
5 /* CSS for new code_area markup used by Colorizer and ParserBase */
6
7 +div.codemsg {
8 + margin: 0.5em 0;
9 + padding: 0.5em;
10 + padding-left:2.5em;
11 + background:none;
12 + border: 1pt solid #CCBDAE;
13 + background-color: #F7F0E0;
14 + background-image:url('../img/alert.png');
15 + background-repeat:no-repeat;
16 + background-position: 0.5em 0.5em;
17 + color: black;
18 +}
19 +
20 div.codearea { /* the div makes the border */
21 margin: 0.5em 0;
22 padding: 0;
Discussion
thanks for the patch,
Plan
- Priority:
- Assigned to:
Status: a bit modified added as 1.9:a83a65fcbb69