Template talk:Syntaxhighlight

wiki code

edit

| suggest using simple space heading delimiter as syntax delimiter for frameing the sentence/group of sentences intead using a hidden a template ending out.

<wiki>
sample

</wiki>

To do it now | should input wiki language or nowiki language contender, but it doesn`t work

<source lang="nowiki"> sample </source> 188.25.109.59 (talk) 22:29, 16 March 2011 (UTC)Reply

line numbering and highlight

edit

I was thinking that line numbering and highlight might be useful, but it is seriously broken under MW 1.18. The examples at mw:Extension:SyntaxHighlight GeSHi look good, but they are running 1.19. ---— Gadget850 (Ed) talk 16:47, 18 February 2012 (UTC)Reply

1.19 is just around the corner. Let's test it here:
<!--This is a comment. Comments are not displayed in the browser-->
<table align=center style="background: ivory;color:maroon;font-style:italic;font-family:arial;font-weight:bold;font-size:10pt;"> 
<tr><th> Heading 1 </th><th> Heading 2 </th></tr>
<tr>
<td style="padding:10px;"> This is cell 1 text </td>
<td style="padding:10px;"> This is cell 2 text </td>
</tr>
</table>
Looks OK to me, but the left padding may need some tweaking, or numbers > 999 may break out. Edokter (talk) — 17:28, 18 February 2012 (UTC)Reply
I do have trouble making the template respond to {{{line}}}, as #tag: does not seem to like embedded parser functions. Edokter (talk) — 17:50, 18 February 2012 (UTC)Reply
That's odd— when I copied the same sample, each line was formatted in a separate dashed box. Works now. ---— Gadget850 (Ed) talk 22:11, 18 February 2012 (UTC)Reply

Languages

edit

A number of languages were added and the Meta list was not as up to date as I had hoped. I have the code columns updated, but the language columns need a lot of work. This list is helpful in identifying the languages. --— Gadget850 (Ed) talk 19:34, 21 March 2013 (UTC)Reply

@Gadget850: and the list is now incorrect again, due to the change from geshi to pygments (phab:T85794). John Vandenberg (chat) 03:46, 13 July 2015 (UTC)Reply

Source code wrapping

edit
code1a:
  mov (X), %eax  // read from address X
  mov (Y), %ebx  // read from address Y
  clflush (X)    // flush cache for address X
  clflush (Y)    // flush cache for address Y
  jmp code1a
A snippet of x86 assembly code that induces the row hammer effect (memory addresses X and Y must map to different DRAM rows in the same memory bank)

Hello! Is there a way to make the source code displayed by <syntaxhighlight> not to wrap if it doesn't fit in the avaiable space? More specifically, I'd need the inner <pre> element to have white-space: pre; instead of white-space: pre-wrap; which is the default. Is that possible? Any help would be appreciated! — Dsimic (talk | contribs) 22:04, 6 August 2015 (UTC)Reply

There is no parameter, if that's what you're looking for. You can however set some personal CSS to make it nowrap:
.mw-highlight pre {
    white-space: pre;
}
-- [[User:Edokter]] {{talk}} 22:17, 6 August 2015 (UTC)Reply
Actually, I'm trying to solve a layout issue in one of our articles, please have a look at the table on the right. The source code gets wrapped in some browsers with some monospaced fonts, despite the fact that in other browsers it fits comfortably within the specified width, so I'd need the formatted code to "stretch" the table instead of wrapping itself. Is that doable, or is there a better way to do the whole thing? I've intentionally set the width value too low in the example to simulate the wrapping issue. — Dsimic (talk | contribs) 22:27, 6 August 2015 (UTC)Reply
(And then Chrome rears its ugly head with a current table width bug...) I see. There is no current solution inplace, but I can expand the .nowrap class in Common.css to make pre behave in these conditions. That should also eliminate the need to hardcode a width (which is bad). -- [[User:Edokter]] {{talk}} 20:32, 7 August 2015 (UTC)Reply
Can't expand .nowrap without side effects, so I need to hink about this. -- [[User:Edokter]] {{talk}} 20:38, 7 August 2015 (UTC)Reply
Oh, I know very well how painful it is to make something CSS-related work in all major web browsers. Hopefully you'll find a good solution, and I'd love to get rid of the hardcoded width value – having it in that place is simply wrong, but unfortunately I had no other way to make the whole thing. Thank you for all your hard work! — Dsimic (talk | contribs) 21:01, 7 August 2015 (UTC)Reply
@Edokter: Any updates on this, please? — Dsimic (talk | contribs) 15:20, 27 September 2015 (UTC)Reply
I think I got it. I can ammend .nowrap to include <pre>. But, the reason it failed before is because you appied the width to the table cell, and not the table; I fixed that above (either that, or give all cells a width). So, in short: 1) Apply the widht to the table 2) give the cell the nowrap class. -- [[User:Edokter]] {{talk}} 18:26, 27 September 2015 (UTC)Reply
Works great. Thank you very much! — Dsimic (talk | contribs) 18:43, 27 September 2015 (UTC)Reply

How can I display <ref name="xxx"/> as XML element?

edit

Hello. When I input <ref name="xxx"/> in this template, the <ref name="xxx"/> element is interpreted as a reference tag. How can I display it as a raw XML element?

<someelem attr="val">
    <anotherelem name="xxx"/> 
    '"`UNIQ--ref-00000012-QINU`"' 
</someelem>

In other hand, inside <syntaxhighlight> tag, the <ref name="xxx"/> element is interpreted as raw XML element.

<someelem attr="val">
    <anotherelem name="xxx"/> <!-- ← This element show as raw XML element, of course -->
    <ref name="xxx"/> <!-- ← This element doesn’t show as raw XML element. -->
</someelem>


--CmplstofB (talk) 13:16, 20 August 2019 (UTC)Reply

  1. ^ Cite error: The named reference xxx was invoked but never defined (see the help page).