How to recognize a configuration file's syntax and its equivalent Markdown language identifier?

Viewed 2246

Introduction

When configuring software packages, you encounter a variety of configuration files with a variety of different syntaxes used.

In addition to .json, .xml, .yml and .properties, below are a few examples of common syntaxes I am unable to find the name for.

White-space separation

# comment
value11 value12
value21 value22 value23 value24

You may find this syntax in "/etc/hosts" and also embedded under Apache2 configuration tags (e.g. <VirtualHost>), among other places. Seems to be used often for listing aliases.

White-space separation and nesting by indentation

Key1 value1 value2 value3
    Key2 value4 value5
    Key3 value6

Key4 value7
    Key5 value8

You may find this syntax in "~/.ssh/config". Nesting ties nested values to the parent values. Looks like yaml without symbols.

Apache2 config

You may have values separated by whitespace, and also XML-tags to separate blocks of configuration.

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
    DocumentRoot "/www/example1"
    ServerName www.example.com

    # Other directives here
</VirtualHost>

Dovecot config

You start a block with specific keywords and curly braces, then you use = assignment like in .properties files.

protocol imap {
  ssl_cert = </etc/ssl/certs/imap.pem
  ssl_key = </etc/ssl/private/imap.pem
}
protocol pop3 {
  ssl_cert = </etc/ssl/certs/pop3.pem
  ssl_key = </etc/ssl/private/pop3.pem
}

Question

Although many software packages have their own configuration syntaxes, these syntaxes often have many similarities. It seems to me .config, .conf or .cf doesn't really say much about the syntax used.

My question is: Do the above code-block syntaxes have names, and if they do, which language identifiers could be used for markdown code-blocks to apply proper syntax highlighting?

For more sophisticated and custom configuration syntaxes, I am simply looking for a base-syntax language identifier which could apply most of the highlighting to the code-block.

```which-language-identifier-goes-here?
# comment
127.0.0.1 localhost example.com
```
```or-here?
# comment
Host remote-server
    HostName example.com
    User johndoe
```
1 Answers

This link has a helpful list of available supported languages (note that your markdown editor also needs to support each language, for coloring/syntax).

For example, you should be able to use apacheconf for Apache conf (eg/ .htaccess, apache.conf', apache2.conf).

For example:

```apacheconf
# Change the PHP version of this directory
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
    SetHandler application/x-httpd-alt-php74___lsphp
</FilesMatch>
Related