When entering XML literals using E4X syntax in ActionScript the code highlighting can be broken:  package {  public class XMLTest {     public function XMLTest()     {        // here highlighting works ok        var aVariable:int = 0;        var aSprite:Sprite = new Sprite();          var xmlFragment:XML =          &lt;root&gt;            &lt;node /&gt;            &lt;node /&gt;            &lt;node /&gt;         &lt;/root&gt;;         // from now on all code highlighting is borked        var otherVariable:int = 0;        var yetAnother:Sprite = new Sprite();     } } }   There is a workaround:  package {  public class XMLTest {     public function XMLTest()     {        // here highlighting works ok        var aVariable:int = 0;        var aSprite:Sprite = new Sprite();          var xmlFragment:XML =          &lt;root&gt;            &lt;node /&gt;            &lt;node /&gt;            &lt;node /&gt;         &lt;/root&gt;; // / //&lt;-- resets the parser and code remains valid         var otherVariable:int = 0;        var yetAnother:Sprite = new Sprite();     } } }
1273
I noticed that sometimes my code gets highlighted in different colors when rendered.   What is syntax highlighting? How does it work? Why isn't my code being highlighted correctly? How do I report a bug or request a new language? How do I use syntax highlighting? What languages are currently available on Stack Exchange?
115313
I have some pseudo-code where I want to highlight some sections in a different color (this is why: in an assignment at university, I have some code given and have to adapt it. I want to highlight what I changed for enhanced readability).  \documentclass[english, a4paper, 11pt]{article} \usepackage{xcolor} \usepackage{listings} lstset(language=C)  //best for pseudo-code IMHO  \begin{document} \begin{lstlisting}[frame=single]    public class A&lt;T&gt; extends B&lt;T&gt; {       \textcolor{red} {Stack stack};  //how can I achive this? Nothing should change, except for the textcolor. This code just prints the \textcolor command though.         //ctor        public A() {};    } \end{lstlisting} \end{document}
6108
Why do I get compiler errors with this Java code?  1  public List&lt;? extends Foo&gt; getFoos() 2  { 3    List&lt;? extends Foo&gt; foos = new ArrayList&lt;? extends Foo&gt;(); 4    foos.add(new SubFoo()); 5    return foos; 6  }  Where 'SubFoo' is a concrete class that implements Foo, and Foo is an interface.  Errors I get with this code:   On Line 3: "Cannot instantiate ArrayList&lt;? extends Foo&gt;" On Line 4: "The method add(capture#1-of ? extends Foo) in the type List&lt;capture#1-of ? extends Foo&gt; is not applicable for the arguments (SubFoo)"   Update: Thanks to Jeff C, I can change Line 3 to say "new ArrayList&lt;Foo&gt;();".  But I'm still having the issue with Line 4.
74032
Is there a way to load every label data and every SObject description data using only Javascript without any Apex Server-side code?  How do I import * from @salesforce/schema or @salesforce/label?  I am looking for a way to get all labels or all SObject describe information details to retrieve in LWC at once.  I can see that such syntax is provided by ES6 and is used widely by Salesforce itself, however, it is not possible to use the following syntax in LWC:   import * as schema from '@salesforce/schema'   import * as label from '@salesforce/label'   or this syntax  import {label, schema} from '@salesforce';   since both versions generate error     LWC1512: Missing resource value for @salesforce"   or      LWC1512: Missing resource value for @salesforce/label   Is there a way to load every label data and every SObject description data using only Javascript without any Apex Server-side code?  By the way, if we look as Salesforce Playground we could notice that   the same syntax is used to import everything from lwc  import * as Engine from 'lwc';   however, if we try to insert such line into any of Lightning Web Component, we would receive the following error     LWC1001: Invalid import. Namespace imports are not allowed on "lwc",   instead use named imports "import { LightningElement } from 'lwc'"   or   LWC1517: Invalid LWC import
104904
I really should be able to get this, but I'm just to the point where I think it'd be easier to ask.  In the C# function:  public static T GetValue&lt;T&gt;(String value) where T:new() {    //Magic happens here }   What's a good implementation for the magic? The idea behind this is that I have xml to parse and the desired values are often primitives (bool, int, string, etc.) and this is the perfect place to use generics... but a simple solution is eluding me at the moment.  btw, here's a sample of the xml I'd need to parse  &lt;Items&gt;     &lt;item&gt;         &lt;ItemType&gt;PIANO&lt;/ItemType&gt;         &lt;Name&gt;A Yamaha piano&lt;/Name&gt;         &lt;properties&gt;             &lt;allowUpdates&gt;false&lt;/allowUpdates&gt;             &lt;allowCopy&gt;true&lt;/allowCopy&gt;         &lt;/properties&gt;        &lt;/item&gt;     &lt;item&gt;         &lt;ItemType&gt;PIANO_BENCH&lt;/ItemType&gt;         &lt;Name&gt;A black piano bench&lt;/Name&gt;         &lt;properties&gt;             &lt;allowUpdates&gt;true&lt;/allowUpdates&gt;             &lt;allowCopy&gt;false&lt;/allowCopy&gt;             &lt;url&gt;www.yamaha.com&lt;/url&gt;         &lt;/properties&gt;     &lt;/item&gt;     &lt;item&gt;         &lt;ItemType&gt;DESK_LAMP&lt;/ItemType&gt;         &lt;Name&gt;A Verilux desk lamp&lt;/Name&gt;         &lt;properties&gt;             &lt;allowUpdates&gt;true&lt;/allowUpdates&gt;             &lt;allowCopy&gt;true&lt;/allowCopy&gt;             &lt;quantity&gt;2&lt;/quantity&gt;         &lt;/properties&gt;     &lt;/item&gt; &lt;/Items&gt;
118769
I am looking for a LaTeX package that does syntax highlighting on code. For example, right now I use the verbatim block to write code:  \begin{verbatim}     &lt;html&gt;        &lt;head&gt;            &lt;title&gt;Hello&lt;/title&gt;        &lt;/head&gt;        &lt;body&gt;Hello&lt;/body&gt;     &lt;/html&gt; \end{verbatim}   And this works fine to display the code on my document. But, suppose I wanted to highlight the HTML markup the way an IDE would in the output document? Is there a package that could help?  I would like to do the same for various languages such as Java, C#, HTML, CSS and so on.
75057
Is there a way in C# to import everything inside a namespace like there is in Java with the wildcard character?  import java.awt.*;
73868
I need help. I am currently trying to test this code before uploading  public class CoreValuesExt { ApexPages.StandardController sc; public boolean readonly {get; set;} public Core_Values__c cv {get; set;} public integer countEdit = 1; public string buttonValue {get; set;} public integer recordScan;  public CoreValuesExt(ApexPages.StandardController sc) {     this.sc = sc;     cv = new Core_Values__c();     cv.Account__c = sc.getid();      readonly = true;     buttonValue = 'Edit';     recordScan = [SELECT COUNT() FROM Core_Values__c WHERE Account__c = :cv.Account__c];    if (recordScan != 0){    cv = [SELECT id, HSE__c, Professionalism_Integrity__c, Quality_Accuracy__c, Technology_Innovation__c, Timeliness__c, Value_for_money__c FROM Core_Values__c WHERE Account__c = :cv.Account__c];     }  }  public ApexPages.PageReference Save() {     return sc.Save(); }  public void ApplyAction() {     countEdit++;     Integer modolus = Math.mod(countEdit, 2);     String total = cv.HSE__c + cv.Professionalism_Integrity__c + cv.Quality_Accuracy__c + cv.Technology_Innovation__c + cv.Value_for_Money__c + cv.Timeliness__c;     if(modolus == 0)     {         readonly = false;         buttonValue = 'Save';     }     else     {         if(total != 'nullnullnullnullnullnull')            {         if (recordScan == 0){         insert cv;         readonly = true;         buttonValue = 'Edit';         }         else         {         update cv;         readonly = true;         buttonValue = 'Edit';         }         }     }    }   }  With this trigger.  trigger CoreValuesTrigger on Core_Values__c (before insert) {  Core_Values__c cvs = Trigger.new; CoreValuesExt.ApplyAction(cvs);  }   But when I try to save, I get a message saying:      Illegal assignment from List to   CoreValuesExt__Core_Values__c at line 3 column 1   "  How do I go through with this? I need help. Thanks
71261
Using TeXstudio's GUI, I would like to collapse the calls of \usepackage{} similar to what can be done for a \paragraph{}, a \section{} etc. The fact that some code can be collapsed in the GUI is identified with a little arrow pointing downward (if expanded) or to the right (if collapsed) next to the first line of code that can be collapsed (see below).    I've tried using  \documentclass[a4paper,12pt]{article} { % this allows collapsing in the GUI (1/2)     \usepackage{color} } % this allows collapsing in the GUI (2/2) \begin{document}     text \end{document}   which allows me to collapse the \usepackage{} calls but doesn't compile.   In short: I want code that compiles and allows me to collapse the code like show in the picture below (as identified by the gray arrow in line 4). So far, I can either get the code to compile (not using the { } around the \usepackage) or I am able to collapse the calls in the GUI.    Does anyone have a solution or idea?
75985
I am trying to paste Isabelle code into a LaTeX document using the listings package.  The nearest language= options seem to be ML and Haskell.  Some of the code contains blocks delineated by quotation marks ("...") within which there are keywords.    Specifying language=ML or language=Haskell does not embolden keywords within the "..." blocks (e.g. " ... if ... ").  On the other hand, setting otherkeywords={if} does embolden keywords within quotation blocks, but also picks up variable names like shift.  \documentclass{article} \usepackage{listings} \lstset{language=ML,         otherkeywords={if,then,else,return,"}         }  \begin{document}   \begin{lstlisting}     "if foo then bar * shift"    \end{lstlisting} \end{document}
45610
Often I see code blocks pasted into questions with no formatting, or terrible formatting.  It's sometimes quite a chore to fix these: you have to either manually space out each line, or paste the code into an IDE, format it there, and paste it back.  Could we have a button/function where you could highlight a code block, and it would turn this:  foreach (var i in stuff) { if (i==1) { Whatever(); } }   into this:  foreach (var i in stuff) {   if (i==1) {     Whatever();   } }   I realise the function would have to work differently based on the language in the code block. Perhaps  it could use the same rules as the prettify code.  Also, it wouldn't be a big deal if it gets the language wrong and breaks the code, since you can always just ctrl+z.
2293
Currently, Stack Exchange’s Markdown parser only allows four-space indents to represent code blocks:      // some code     // another line of code    and other Markdown implementations allow for an alternative syntax, that doesn’t require indenting each code line:  ``` // some code // another line of code ```   This is much more convenient to type out. It would be super useful if Stack Exchange could support this syntax.    By extension, this syntax also allow you to specify the source language right after the opening ```:  ```js // some code // another line of code ```   …which would then enable syntax highlighting for that specific language. Although it’s interesting metadata, I don’t think this feature is needed on Stack Overflow, as the syntax highlighting library works pretty well for various languages.  So, even if you would allow this syntax but ignore the ```language, this would greatly improve my productivity on Stack Exchange.  What do you think?  The moderators are currently collecting feedback regarding this feature, so please post a comment with your thoughts. Good idea? Bad idea? Don’t really care? What do you think are the benefits/drawbacks? Experiences? Let them know! Thanks!
38266
I just approved several edits from a user adding  to questions with the  tag. Apparently , Google Code Prettify has added support for Dart.  I suggest it's time to follow suit and update the default syntax highlighting associated with the  tag. Adding it manually to every question sounds like way too much work, even if I all I have to do is click the "Approve" button.
81767
How can I use bold text inside a code listing? I wanted to make some parts of the code bold.
44000
Actionscript 3.0 (and I assume Javascript and ECMAScript in general) lacks pass-by-reference for native types like ints. As a result I'm finding getting values back from a function really clunky.  What's the normal pattern to work around this?    For example, is there a clean way to implement swap( intA, intB ) in Actionscript?
78261
Is there any way that I can change how a Literal of a code snippet renders when it is used in the code that the snippet generates?  Specifically I'd like to know if I can have a literal called say, $PropertyName$ and then get the snippet engine to render "_$PropertyName$ where the first character is made lowercase.  I can't afford R#.  Please help :)
36880
Oftentimes, I want to include code samples in a list, for example:   Item One Item Two, for example: private bool ItemTwo() {     return this.IFeelLucky; } Item Three   The problem is that there isn't a good and intuitive way to do this using . It's doable, but you have to do some formatting black-magic to get it that way, which is just not "nice" to deal with.  Source that produces this:  1. Item One 2. Item Two, for example: &lt;br/>&lt;br/>&lt;pre>&lt;code>private bool ItemTwo()     {         return this.IFeelLucky;     }&lt;/code>&lt;/pre> 3. Item Three    I would love to just be able to do it this way:  1. Item One 2. Item Two, for example:      private bool Test()     {         return this.IFeelLucky;     }  3. Item Three  Which results in, well, this:   Item One Item Two, for example:  private bool Test() {     return this.IFeelLucky; } Item Three