Template talk:Hc

From ArchWiki
Jump to: navigation, search

Add named-parameters usage

This also works:

{{hc|head=main.h|output=#include <stdio.h>}}

renders as

main.h
#include <stdio.h>

I suggest adding this to the usage section. --Franklin Yu (talk) 08:15, 21 April 2017 (UTC)

Sure, added with [1], although I've never seen the named parameters used for this template; usually the numbered parameters are used when needed. – Kynikos (talk) 10:40, 21 April 2017 (UTC)

Formatted code in case of configuration files: hyperlinks

When showing an excerpt of a configuration file, I find that automatically generated links may be misleading or not proper.

One example is made by configuration entries that point to the localhost, often being not the machine where the wiki is viewed.

I used a nowiki block inside the output part of the hc parameter, which works (please see below). I wonder, though, if there would be any benefit in adding a parameter to disable automatic generation of links in the template. This may also help to avoid the extrac vertical space introduced by the "nowiki" tags.

/usr/share/webapps/parsoid/config.yaml

 uri: 'http://localhost/mediawiki/api.php'
 domain: 'localhost'

The block including the links would be shown as:

/usr/share/webapps/parsoid/config.yaml
 uri: 'http://localhost/mediawiki/api.php'
 domain: 'localhost'

And it makes no sense to follow that link in the machine where the wiki is being read.

Ezacaria (talk) 08:15, 17 August 2017 (UTC)

Such a parameter would be hard to implement, perhaps it could be done using parser functions, but a simpler option would be to just create a new series of nowiki'ed templates, say Template:nic, Template:nbc and Template:nhc. -- Kynikos (talk) 11:55, 17 August 2017 (UTC)
Thanks for the quick response! Since this case does not pop up that often, maybe we can live with the nowiki workaround. I will close this one until the need increases :) Ezacaria (talk) 12:12, 17 August 2017 (UTC)
You can get rid of the "extra vertical space" when using the <nowiki> tags by writing it this way:
/usr/share/webapps/parsoid/config.yaml
 uri: 'http://localhost/mediawiki/api.php'
 domain: 'localhost'
-- Lahwaacz (talk) 15:46, 17 August 2017 (UTC)
Thanks! For the record (since the markup is not visible without looking at the page source), this means the <nowiki> without any preceding line break, as in {{hc|/usr.../config.yaml|<nowiki>. I had inserted a line break after ".../config.yaml|" to keep things visually tidy -- Ezacaria (talk) 16:31, 17 August 2017 (UTC)