[inline code] Enable an inline code template

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

[inline code] Enable an inline code template

Post by vocx »

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.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [inline code] Enable an inline code template

Post by NormandC »

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
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [inline code] Enable an inline code template

Post by NormandC »

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

Re: [inline code] Enable an inline code template

Post by Kunda1 »

I played around with the css and think this could look cool if we tweaked the wiki to show codeblocks:
Image
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [inline code] Enable an inline code template

Post by yorik »

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

Re: [inline code] Enable an inline code template

Post by chrisb »

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.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [inline code] Enable an inline code template

Post by Kunda1 »

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
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: [inline code] Enable an inline code template

Post by vocx »

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.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [inline code] Enable an inline code template

Post by Kunda1 »

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?
-------------------------------------------------------------------
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
kkremitzki
Veteran
Posts: 2519
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: [inline code] Enable an inline code template

Post by kkremitzki »

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.
Post Reply