Page MenuHomePhorge

Remarkup code blocks: guess the language from the "name" (if available)
Closed, ResolvedPublic

Description

Sometime you want to render a snippet of code with a name, like this one:

asd.php
$asd = 1;

The above is rendered with this Remarkup:

```name=asd.php
$asd = 1;
```

Note that there is not any syntax highlight since, for that, we should have an explicit additional lang=php - or - we should rely on a better auto-guesser.

So this is the desired situation:

asd.php
$asd = 1;

At the moment the above situation is created only with the following Remarkup code:

```name=asd.php,lang=php
$asd = 1;
```

Proposal

Only for Remarkup code blocks:

  • If the name is specified
  • If the lang is not specified
  • Then defaults the lang as file extension on the name (if any)

Extra considerations if implemented:

  • We could pay extra attention (or not) to avoid to parse a silly file extension from interesting "descriptive names" like name=And yes. This is the file! and so avoiding to inherit a file extension that would be . This is the file! since indeed it's not a very meaningful extension like .lua or .js etc.
  • Or, somebody can say to just consider as "don't care" case since it's probably already double-checked later and ignored and it already triggers (or not?) the auto-guesser. So yes, maybe better to have some early cleanup to avoid nonsense defaults passed to our implementations (that could change in the future and maybe scream if an invalid language is passed).