[inline code] Enable an inline code template

Discussions about the wiki documentation of FreeCAD and its translation.
vocx
Posts: 1062
Joined: Thu Oct 18, 2018 9:18 pm

[inline code] Enable an inline code template

Postby vocx » Sat Oct 27, 2018 4:41 am

The wiki has a {{Code|code=something here}} template to display blocks of code like this

Code: Select all

something here
But there doesn't seem to have a template for inline pieces of code, for example, {{incode|import FreeCAD}} should display it like import FreeCAD.

There is a pair of tags <code>import FreeCAD</code>, but it isn't as convenient as a template.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [inline code] Enable an inline code template

Postby NormandC » Sun Oct 28, 2018 2:49 pm

I have no objection to it, but is it even possible?

All examples of short templates I've seen so far seem to force a carriage return after use of the template.

This is the case with our Version template. Test it and you will see. In this case the line below is even preformatted.

This has prevented me from creating templates to change the colour and size of text.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [inline code] Enable an inline code template

Postby NormandC » Sun Oct 28, 2018 9:21 pm

Silly me, the KEY template can already be used inline. I guess it means an inline code template would be possible.
User avatar
Kunda1
Posts: 5226
Joined: Thu Jan 05, 2017 9:03 pm

Re: [inline code] Enable an inline code template

Postby Kunda1 » Mon Oct 29, 2018 2:03 pm

I played around with the css and think this could look cool if we tweaked the wiki to show codeblocks:
Image
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: [inline code] Enable an inline code template

Postby yorik » Mon Oct 29, 2018 2:12 pm

I kind of like the black background personally, but then we need a special rule for print...
chrisb
Posts: 17593
Joined: Tue Mar 17, 2015 9:14 am

Re: [inline code] Enable an inline code template

Postby chrisb » Mon Oct 29, 2018 4:22 pm

To me black signals immediately that it's on console, so it's great here. For other code I would like to have some grey background.
User avatar
Kunda1
Posts: 5226
Joined: Thu Jan 05, 2017 9:03 pm

Re: [inline code] Enable an inline code template

Postby Kunda1 » Mon Oct 29, 2018 6:06 pm

chrisb wrote:
Mon Oct 29, 2018 4:22 pm
To me black signals immediately that it's on console, so it's great here. For other code I would like to have some grey background.
Yea, I thought about that. I wonder how we can distinguish console code from other code ?
Maybe what @vocx proposes?
vocx wrote:
Sat Oct 27, 2018 4:41 am
The wiki has a {{Code|code=something here}} template to display blocks of code
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
vocx
Posts: 1062
Joined: Thu Oct 18, 2018 9:18 pm

Re: [inline code] Enable an inline code template

Postby vocx » Mon Oct 29, 2018 6:18 pm

Kunda1 wrote:
Mon Oct 29, 2018 6:06 pm
chrisb wrote:
Mon Oct 29, 2018 4:22 pm
To me black signals immediately that it's on console, so it's great here. For other code I would like to have some grey background.
Yea, I thought about that. I wonder how we can distinguish console code from other code ?
Maybe what @vocx proposes?
vocx wrote:
Sat Oct 27, 2018 4:41 am
The wiki has a {{Code|code=something here}} template to display blocks of code
Don't use black blocks. It's too much ink on screen. Current {{Code|code=}} template works fine, with that slight gray background. Besides, as mentioned, when you print it, it shouldn't print the entire black block, should it?

I already implemented the {{incode|something}} template, which is just a pair of <code>something</code> tags, https://www.freecadweb.org/wiki/Template:Incode

Now, what would be more useful is color highlighting, as explained in https://www.freecadweb.org/wiki/Template:Code
Using color highlight in the website is fine, but again, when you print it, it probably should default to black.

It seems color highlighting was disabled before, but why? Maybe when FreeCAD was using other type of wiki? There is a lot of old, confusing information on the wiki, this needs deep review.
User avatar
Kunda1
Posts: 5226
Joined: Thu Jan 05, 2017 9:03 pm

Re: [inline code] Enable an inline code template

Postby Kunda1 » Sun Jun 02, 2019 1:22 pm

There are also other parameters for <syntaxhighlight> tag.
For example:
  • highlight: The highlight attribute specifies one or more lines that should be marked (by highlighting those lines with a different background color). You can specify multiple line numbers separated by commas (for example, highlight="1,4,8") or ranges using two line numbers and a hyphen (for example, highlight="5-7"). Note that the line number specification ignores any renumbering of the displayed line numbers with the start attribute.
  • start: The start attribute (in combination with line) defines the first line number of the code block. For example, line start="55" will make line numbering start at 55.
  • line: The line attribute enables line numbers.
Source: https://www.mediawiki.org/wiki/Extensio ... Parameters
------------------------------------------------------------------
Edit: I'm confused, does our mediawiki support <syntaxhighlighting> tag or not? According to the code template, @mario52 (i think?) wrote:
'''Warning:''' The Extension:SyntaxHighlight was disabled because it didn't work anymore on our host.
So what's the status of that?
-------------------------------------------------------------------
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
kkremitzki
Posts: 1679
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: [inline code] Enable an inline code template

Postby kkremitzki » Sun Jun 02, 2019 5:51 pm

https://freecadweb.org/wiki/Special:Version says SyntaxHighlight version 2.0 is turned on.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.