Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

The new forum code formatting


  • Please log in to reply
1 reply to this topic
Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I apologize up front if this isn't the right place to mention forum issues.

 

I quite like the idea of prettified code, and am surprised such an update came out (any announcement about it being planned that I could check out?). But it's not quite ironed out. It looks like single and double quotes can span multiple lines unintentionally. Here's an example:

a:=0
b:=0
c:=0 ; Hey, it's the third line
d:=0
e:=0
f:=0 ; now it's the sixth line. Notice from the first single quote to the next it was all green?
g:=0
h:=0
i:=0 ; And here I am experimenting with a (") double quote
j:=0
k:=0
l:=0 ; And here's the closing (") double quote
m:=0
n:=0
o:=0 ; as well as `n and the like, and that doesn't even need to be in a comment

MsgBox `n yeah?

Also, is there any Notepad++ language that matches up with the forum's new coloring of code syntax?



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Has it changed recently?  I'm pretty sure this is how it was when the forum was first moved to IP.Board, though maybe it has been disabled and re-enabled since then.  I don't pay much attention on this forum (I have a pretty low opinion of IP.Board in general).
 
IP.Board uses a JavaScript-based highlighter called "prettify", but we appear to have only the SQL and CSS modules.  I don't have sufficient access to disable it, but if you use an ad blocker or user-script manager (like GreaseMonkey/TamperMonkey), it's pretty easy.
 
To disable it with an ad blocker, block the following:

http://autohotkey-dequeue.netdna-ssl.com/board/public/js/3rd_party/prettify/*

To disable it from a user-script, you can use the following:

$$('.prettyprint').each(function(item) {
    item.addClassName('prettyprinted');
})

The following can be used to implement a very basic highlighter, which does not recognize any keywords:

PR.registerLangHandler(
      PR.createSimpleLexer([], [
          [PR.PR_COMMENT, /^;.*|^\/\*[\s\S]*?\r?\n\s*\*\//],
          [PR.PR_STRING, /^".*?"/],
          ['var', /^%[\w#@$]+%/],
          [PR.PR_PUNCTUATION, /^[%<>=/|^,:*&~!()\[\]{}.+\-*&!?~]/],
          [PR.PR_TAG, /^`./],
      ]), ['ahk']);

$$('.prettyprint').each(function(item) {
    // Override the CSS class, which is usually "prettyprint lang-auto" but sometimes
    // has an invalid class like just "lang-", probably depending on the bbcode tag.
    item.className = 'prettyprint lang-ahk';
})

These both work on page load (or at least, TamperMonkey works on page load), so do not apply to quick-replies or quick-edits.