Use the last used language for highlighting

Leonth - July 8, 2008 - 14:59
Project:GeSHi Filter for syntax highlighting
Version:6.x-1.1
Component:Filtering
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Description

Currently when there is no "type" attribute in a tag, we can choose a default programming language for highlighting. Is it possible to let geshifilter choose the last language used in the input? For example,

<blockcode type="c">blockcode 1</blockcode>
<blockcode>blockcode 2</blockcode>
<blockcode>blockcode 3</blockcode>
<blockcode type="python">blockcode 4</blockcode>
<blockcode>blockcode 5</blockcode>

Now blockcode 1, 2, and 3 are highlighted in C but blockcode 4 and 5 is highlighted in Python. This will save some time when you're typing lots of code snippets.

I have not looked into the code but I presume this will not be very complicated. If I have some time I might look into it and do a patch.

(I got the idea from \lstset{} of LaTeX)

#1

soxofaan - July 8, 2008 - 15:57
Priority:normal» minor

This is not possible with the current version.

Also, I'm note sure if it would be a good idea to implement this.
Introducing a sort of context to the code block filtering is tricky and could introduce a lot of confusion to the user.
For example, if you want blockcode 3 to be highlighted with the default (which is no highlighting in most cases), how would you achieve this when you have a "sticky" mode?

I think it's just better to be explicit than to be implicit,

The cost of typing the extra 'lang="python"' is not that big, I think
Moreover, if you are concerned about typing, why don't you just enable language tags instead of the generic ones so you can write:

[c]blockcode 1[/c]
[c]blockcode 2[/c]
[c]blockcode 3[/c]
[python]blockcode 4[/python]
[python]blockcode 5[/python]

 
 

Drupal is a registered trademark of Dries Buytaert.