Proposed stack exchange site for Interactive Fiction

I don’t know.

I wrote an alternate I7 lexer module for Pygments 2. (The ZarfI7Lexer class in github.com/erkyrath/glk-dev/blo … i7tortf.py .) Dunno if that’s easy to install.

You’d have to modify the local copy of Pygments in the server to add the modified lexer. If it’s a lexer just for I7, probably after merging it with the i6 and tads lexers already in the file with the i7 lexer. Why not merge in your fixed lexer and submit a pull request to Pygments?

Edit: If you’re too busy, I could do it (with your permission of course). I’m posting IF stuff on a Jekyll blog now, and having a correct lexer for I7 code would be useful, but figuring out how to write lexers for Pygments/Rouge/Highlight.js hurts my brain.

I said it was an alternate version, not an improved version. (It does fix the bug with nested square brackets.)

I’ve now added the Markdown editor plugin. I’ve enabled the support for highlight.js which does syntax highlighting - it seems there’s no support for Inform with this though.

Integrating Pygments would probably require creating a custom plugin for Question2Answer. I’m happy to add this if somebody wants to write one.

I’ve written a language definition file for highlight.js for Inform 7. Someone more familiar with the nooks and crannies of the language might want to see if it breaks under duress, though I don’t think I7 has any ridiculous things that lead to stupid corner cases. It supports auto-detection by looking for some common I7 keywords, but it only highlights (with a default CSS) what the IDE highlights, which is to say section headers, comments, strings, and string substitutions. Nested comments are supported.

I’ve made a question/answer on the site for updates: ifanswers.com/288/site-updates
I’ll try to keep that up to date

Okay, I’m going to do it, I’m going to ask the stupid question. Please excuse me.

I don’t use Stack Exchange or any similar sites, except insofar as they come up when I’m Googling for solutions to whatever weird problem I happen to have. What are the advantages over the forum? Someone said searchability, I think (and goodness knows searching a phpBB forum is a horrible experience).

I don’t use Stack Exchange either, but here are some advantages of this QA site:

Good answers are voted up, so if you’re searching the site for a previously-asked question, you don’t need to read an entire thread to find a good answer.

When you are asking a question, similar questions automatically pop up, which can help to cut down on duplicate questions.

Community members (who have enough reputation points) can edit questions and answers to make them clear, complete and accurate, so they will be more useful for people searching for answers in the future.

It’s not a discussion forum. It’s just plain questions and answers. If you want a discussion, forums are great. If you just want a quick answer, you can go to a QA site to sidestep the discussion.

@Sequitur I’ve tried to use your version of highlight.js but I can’t get it to work. I built it using the instructions at highlightjs.readthedocs.org/en/l … sting.html, but it seems the resulting highlight.pack.js it creates isn’t a drop-in replacement for the highlight.min.js included with Q2A’s Markdown plugin - it simply doesn’t highlight anything.

I’ve turned the syntax highlighting off for now as Inform code just looks weird with it, so I don’t think it’s helping much.

Yeah, hard to tell what’s going on. The addon might be using an older version of hl.js, or maybe it expects it to be built in some weird way, or maybe even it modifies it for some reason. Note that because Highlight.js is a client-side library, you don’t really need a server-side plugin at all to use it - all it needs is that code blocks be wrapped in

 tags or similar, and that the stylesheets and script be included in the  of the document, so you could just add it to the page template.

Does anything come up on the JS console when you use it and it doesn’t work? What command did you use to build hl.js?

Nothing came up in the JS console. I built it using

node tools/build.js

which I’m assuming builds the client-side version. Then I just dropped it in to replace the highlight.min.js that’s included with the plugin.

The Q2A Markdown plugin hasn’t been updated in a few years - it’s using a version of highlight.js from at least 3 years ago: github.com/svivian/q2a-markdown … r/pagedown

But from what you’ve said, it doesn’t sound like the problem is an API change, because there isn’t one. If it just automatically scans

 elements on the page it’s included in, then that should be fine. I guess I should test by embedding the version I built in a simple HTML page to see if that works.

OK I have had a bit more a play with a simple HTML page. It seems highlightjs requires a call to:

hljs.initHighlightingOnLoad();

and the code needs to be in

, not just 
.

Not sure if the Q2A plugin does this but I’ll take a look.

More importantly, in my test I used the I7 code block in ifanswers.com/216/how-organize-e … lay-begins, but the auto detection picks it up as VB.NET :frowning:

Yes, I would suggest building it with support only for the languages you want, for speed and consistency:

node tools/build.js inform7 python

The autodetect isn’t perfect (It runs through every file, counts the number of matching modes, weights them, and then uses whatever has the best score). VBNet has the keywords “of”, “when”, “do”, “nothing”, and “text”, all of which are also Inform7 keywords or names. When I’m able to use my PC, I’ll have a look at the source code to see if I can improve autodetection more, but until then I recommend building hl.js with support for only the languages you need; the detection algorithm is quite slow (Brute-force, really) and so it creates noticeable lag if you build it with support for every language (Which includes a lot of obscure ones we’re not interested in).

Which tags hl.js will look into and highlight depends on how it’s initialised. The hljs.initHighlightingOnLoad() function defaults to

 tags, but there’s nothing magical about that function. You can initialise it to work inside any arbitrary set of tags using JQuery (Which is what initHighlightingOnLoad() is doing):
$(document).ready(function() {
  $('pre').each(function(_, block) {
    hljs.highlightBlock(block);
  });
});

Edit: My fork now correctly detects that code snippet as Inform 7. By the way, I have an outstanding pull request to get that merged into mainline Highlight.js.

However, vbnet just has so many keywords defined that also crop up in I7 code that the conflict is hard to resolve without making the highlighter class for I7 hugely complicated and slow. I’m not including in the highlighter a comprehensive list of keywords, because we don’t actually want to visually highlight them (I’m trying to follow the look of the IDE). Instead, I have a list of keywords that are commonly-used and mostly unique to I7, which are very informative. Expanding the highlighter to improve detection is black magic, especially because the opposite issue of files that aren’t i7 being detected as such is actually possible.

But that’s a problem for the guy who decides to use it on his blog about parser IF and ASP.NET enterprise webapp development.

Further edit:

I’ve improved detection even further. While that snippet you posted still scores highly for vbnet, the score for I7 is now twice as much, so it should be safe.