= Description = Line numbers toggling javascript works buggy, when `highlight` parser without parameters supplied. == Steps to reproduce == 1. Add code block with `highlight` parser without setting highlight parser parameters == Example == * /TestHighlightBlock * /TestHighlightFormat == 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 == {{{#!highlight diff --- orig_moin/moin-1.9.0rc1/MoinMoin/parser/highlight.py 2009-11-03 02:41:42.000000000 +0300 +++ highlight.py 2009-11-15 18:08:03.000000000 +0300 @@ -116,13 +116,14 @@ self.request = request self.raw = raw.strip('\n') self.filename = filename + if self.parsername == 'highlight': # user is directly using the highlight parser parts = format_args.split(None) if parts: self.syntax = parts[0] else: - self.syntax = '' + self.syntax = 'text' if len(parts) > 1: params = ' '.join(parts[1:]) else: @@ -134,10 +135,14 @@ self.show_nums, self.num_start, self.num_step, attrs = parse_start_step(request, params) def format(self, formatter): + _ = self.request.getText + fmt = PygmentsFormatter(formatter) fmt.result.append(formatter.div(1, css_class="highlight %s" % self.syntax)) self._code_id = hash_new('sha1', self.raw.encode(config.charset)).hexdigest() - fmt.result.append(formatter.code_area(1, self._code_id, self.parsername, self.show_nums, self.num_start, self.num_step)) + + msg = None + if self.filename is not None: try: lexer = pygments.lexers.get_lexer_for_filename(self.filename) @@ -148,8 +153,9 @@ try: lexer = pygments.lexers.get_lexer_by_name(self.syntax) except pygments.util.ClassNotFound: - fmt.result.append(formatter.text('#!%s\n' % self.syntax)) + msg = _("Lexer \"%s\" not found. Rendering as plain text.") % self.syntax lexer = pygments.lexers.TextLexer() + fmt.result.append(formatter.code_area(1, self._code_id, self.parsername, self.show_nums, self.num_start, self.num_step, msg)) pygments.highlight(self.raw, lexer, fmt) fmt.result.append(formatter.code_area(0, self._code_id)) fmt.result.append(formatter.div(0)) }}} {{{#!highlight diff --- orig_moin/moin-1.9.0rc1/MoinMoin/formatter/text_html.py 2009-11-03 02:41:41.000000000 +0300 +++ text_html.py 2009-11-15 18:08:18.000000000 +0300 @@ -859,7 +859,7 @@ """ - def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1): + def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1, msg=None): """Creates a formatted code region, with line numbering. This region is formatted as a
with a
 inside it.  The
@@ -885,6 +885,12 @@
             # id in here no longer used
             self._code_area_state = [None, show, start, step, start]
 
+            if msg != None:
+                attr = {'class': 'codemsg'}
+                res.append(self._open('div', attr={ 'class' : 'codemsg' }))
+                res.append(self.text(msg))
+                res.append(self._close('div'))
+
             # Open the code div - using left to right always!
             attr = {'class': 'codearea', 'lang': 'en', 'dir': 'ltr'}
             res.append(self._open('div', attr=attr))
}}}

{{{#!highlight diff
--- common.css.old      2009-11-15 18:12:46.000000000 +0300
+++ common.css  2009-11-15 18:17:56.000000000 +0300
@@ -305,6 +305,19 @@
 
 /* CSS for new code_area markup used by Colorizer and ParserBase */
 
+div.codemsg {
+       margin: 0.5em 0;
+       padding: 0.5em;
+       padding-left:2.5em;
+       background:none;
+       border: 1pt solid #CCBDAE;
+       background-color: #F7F0E0;
+       background-image:url('../img/alert.png');
+       background-repeat:no-repeat;
+       background-position: 0.5em 0.5em;
+       color: black;
+}
+
 div.codearea { /* the div makes the border */
        margin: 0.5em 0;
        padding: 0;
}}}


= Discussion =
thanks for the patch, 

= Plan =
## This part is for Moin``Moin developers:

 * Priority: 
 * Assigned to:
 * Status: a bit modified added as [[http://hg.moinmo.in/moin/1.9/rev/a83a65fcbb69|1.9:a83a65fcbb69]]

----
## If you are a moin core developer, replace the category to Category* in these cases:
## Category MoinMoinNoBug - if this is not a bug.
## Category MoinMoinBugConfirmed - if you can confirm the bug on current code.
## Category MoinMoinBugFixed - after the bug is fixed in current code.
CategoryMoinMoinBugFixed