Recently Apple announced the Swift language to be open sourced later this year. I noticed that google prettifier, which is used in eg. stack overflow to post code snippets, is not yet been adapted with Swift language specification. I checked the GitHub project  and it seems not present in the source sections. I posted an issue to ask for this extensions   I don't know if any one out there already worked on a prettifier extension for Swift but I think it would be nice to have this new language integrated in the prettifier to post correctly coloured Swift snippets. Not only for stack overflow but also as use of personal sites, blogs,...    Just got mail today on 04/08/2015 so this can't be duplicated anymore ;-)  [code-prettify] Add Swift Support (#383)  This pull request adds Swift to the list of languages that can be prettyprinted. It should be noted that it does not support highlighting the contents of string interpolation expressions, due to the high complexity of correctly classifying such structures with just a lexer.  You can view, comment on, or merge this pull request online at:    Commit Summary  Add a file for the Swift language lexer definition. Add support for whitespace and comments Add highlighting for Swift keywords Add highlighting for string literals Add shortcut for string literal detection to Swift Add integer literal support for Swift Fixes and improvements for Swift Add floating point literal support for Swift. Add punctuation support for Swift Add punctuation support for Swift Merge branch 'master' of github.com:chrisrecher/code-prettify Add type support for Swift, to the fullest extent possible in a lexer Remove unnecessary comments File Changes  A src/lang-swift.js (59) Patch Links:
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?
111508
I just saw in this posting:  the note: "the TeX Gyre Pagella font, which includes glyphs for cyrillic.". There is an MWE there, which apparently worked in 2009; here it is (I just moved the fontenc line before the babel line, because pdflatex complained):  \listfiles \documentclass{article}  \usepackage[utf8]{inputenc} \usepackage[T1,T2A]{fontenc} % before babel! \usepackage[ngerman,russian]{babel} \usepackage{tgpagella}  \begin{document}  Добро пожаловать!  \selectlanguage{ngerman}  Some german umlauts: ÄÖÜ, äöü, ß  \end{document}   I build this with pdflatex test.tex, and it fails on Texlive 2014 with:  ... This is METAFONT, Version 2.7182818 (TeX Live 2014) (preloaded base=mf)   kpathsea: Running mktexmf larm1000 ! I can't find file `larm1000'. &lt;*&gt; ...ljfour; mag:=1; nonstopmode; input larm1000  Please type another input file name ! Emergency stop. &lt;*&gt; ...ljfour; mag:=1; nonstopmode; input larm1000  Transcript written on mfput.log. grep: larm1000.log: No such file or directory mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000' failed to make larm1000.tfm. kpathsea: Appending font creation commands to missfont.log.  ! Font T2A/cmr/m/n/10=larm1000 at 10.0pt not loadable: Metric (TFM) file not fo und. &lt;to be read again&gt;                     relax  l.100 \fontencoding\encodingdefault\selectfont  ?    Apparently I may be missing some package, but I have no idea which one.  Is it possible to get this example working with pdflatex, and if so - how?    EDIT: Just found , and so I managed to fix the problem by installing the TexLive lh package, then I got the document to compile:  tlmgr install lh                      # passes, font not really tgpagella? tlmgr install collection-langcyrillic # installs 36 packages, like babel-bulgarian,... lcyw, lhcyr...   With that, the output is:    ... and the cyrillic font doesn't look like tgpagella. So I installed collection-langcyrillic, but that didn't change the output either; still getting in the transcipt:  LaTeX Font Warning: Font shape `T2A/qpl/m/n' undefined (Font)              using `T2A/cmr/m/n' instead on input line 3.   ... so apparently, the output shows the cyrillic of "Computer Modern". Now, if just the cyrillic font could be made like tgpagella, that would be great...
101421
Is there a reason that inline-code (with ``, of course) in answers is excluded from the prettify-process?   Sometimes a piece of code is a bit too small to be blessed with its own blockquote, and so it's merely streamed inline with the rest of a paragraph, but having syntax-highlighting on it would still help to break up the different parts of the code.  (For the record, I don't think this should be included in comments — which has already been discussed here.)  Or does there already exist a way to prettify inline code? (The language of code blocks can be explicitly set with &lt;!-- language: ... --&gt;; could this also be allowed for inline code?)
45164
I'm using listings and I want to extend a language with additional keywords for highlightning. I know there is an option morekeywords available, but that only works for a particular lstset declaration and I don't want to have to copy-paste all keywords into all listings. I've tried declaring the keywords as part of a command but that doesn't work (probably because the command is not expanded and I don't know how to fix that).  So is there any way of declaring a new language by copying an existing one and just adding more keywords?
92186
I'm trying to typeset some python code, and I would like integer literals to be highlighted. I've come up, after about two hours of fighting with the documentation and various other questions here and on SO, with the following:  \lstset{ %     language=Python,     otherkeywords={1, 2, 3, 4, 5, 6, 7, 8, 9, 0},     morekeywords=[2]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},     keywordstyle=[2]{\color{orange}},     keywordstyle=\color{blue}\bfseries,     stringstyle=\color{red}, }   Unfortunately, that doesn't work. Numbers found in strings are also highlighted, which is rather annoying, and not only are they highlighted: they are highlighted in blue. Numerals in regular program text, on the other hand, are rightly highlighted in red.  Help?  EDIT: Thanks Peter Grill for your very nice solution. Is there a way to not break string colouring, though? When I use you code, the stringstyle=\color{red} doesn't seem to work anymore (strings are just plain black). Similarly, comments can be enclosed in triple quotes in python, and if I adapt your quote to detect """ blocks, then the corresponding  comments are not highlighted anymore.
82512
I've been looking at F# recently, and while I'm not likely to leap the fence any time soon, it definitely highlights some areas where C# (or library support) could make life easier.  In particular, I'm thinking about the pattern matching capability of F#, which allows a very rich syntax - much more expressive than the current switch/conditional C# equivalents. I won't try to give a direct example (my F# isn't up to it), but in short it allows:   match by type (with full-coverage checking for discriminated unions) [note this also infers the type for the bound variable, giving member access etc] match by predicate combinations of the above (and possibly some other scenarios I'm not aware of)   While it would be lovely for C# to eventually borrow [ahem] some of this richness, in the interim I've been looking at what can be done at runtime - for example, it is fairly easy to knock together some objects to allow:  var getRentPrice = new Switch&lt;Vehicle, int&gt;()         .Case&lt;Motorcycle&gt;(bike =&gt; 100 + bike.Cylinders * 10) // "bike" here is typed as Motorcycle         .Case&lt;Bicycle&gt;(30) // returns a constant         .Case&lt;Car&gt;(car =&gt; car.EngineType == EngineType.Diesel, car =&gt; 220 + car.Doors * 20)         .Case&lt;Car&gt;(car =&gt; car.EngineType == EngineType.Gasoline, car =&gt; 200 + car.Doors * 20)         .ElseThrow(); // or could use a Default(...) terminator   where getRentPrice is a Func&lt;Vehicle,int&gt;.  [note - maybe Switch/Case here is the wrong terms... but it shows the idea]  To me, this is a lot clearer than the equivalent using repeated if/else, or a composite ternary conditional (which gets very messy for non-trivial expressions - brackets galore). It also avoids a lot of casting, and allows for simple extension (either directly or via extension methods) to more-specific matches, for example an InRange(...) match comparable to the VB Select...Case "x To y" usage.  I'm just trying to gauge if people think there is much benefit from constructs like the above (in the absence of language support)?  Note additionally that I've been playing with 3 variants of the above:   a Func&lt;TSource,TValue&gt; version for evaluation - comparable to composite ternary conditional statements an Action&lt;TSource&gt; version - comparable to if/else if/else if/else if/else an Expression&lt;Func&lt;TSource,TValue&gt;&gt; version - as the first, but usable by arbitrary LINQ providers   Additionally, using the Expression-based version enables Expression-tree re-writing, essentially inlining all the branches into a single composite conditional Expression, rather than using repeated invocation. I haven't checked recently, but in some early Entity Framework builds I seem to recall this being necessary, as it didn't like InvocationExpression very much. It also allows more efficient usage with LINQ-to-Objects, since it avoids repeated delegate invocations - tests show a match like the above (using the Expression form) performing at the same speed [marginally quicker, in fact] compared to the equivalent C# composite conditional statement. For completeness, the Func&lt;...&gt; based-version took 4 times as long as the C# conditional statement, but is still very quick and is unlikely to be a major bottleneck in most use-cases.  I welcome any thoughts / input / critique / etc on the above (or on the possibilities of richer C# language support... here's hoping ;-p).
84066
I quite like the look of the font used in the code blocks that appear on Stack Overflow.    What, dear listener, is the font face used for such?
43759
I am trying to define an enviroment for a specific programming language, F#. Here's my code:  \definecolor{bluekeywords}{rgb}{0.13,0.13,1} \definecolor{greencomments}{rgb}{0,0.5,0} \definecolor{turqusnumbers}{rgb}{0.17,0.57,0.69} \definecolor{redstrings}{rgb}{0.5,0,0}  \lstdefinelanguage{FSharp}     {morekeywords={let, new, match, with, rec, open, module, namespace, type, of, member, and, for, in, do, begin, end, fun, function, try, mutable, if, then, else},     keywordstyle=\color{bluekeywords},     sensitive=false,     morecomment=[l][\color{greencomments}]{///},     morecomment=[l][\color{greencomments}]{//},     morecomment=[s][\color{greencomments}]{{(*}{*)}},     morestring=[b]",     stringstyle=\color{redstrings}     }  \newenvironment{fslisting}   {     \lstset{         language=FSharp,         basicstyle=\ttfamily,         breaklines=true,         columns=fullflexible}     \begin{lstlisting}   }   {     \end{lstlisting}   }   Then I'm trying to use it as such:  \begin{fslisting} type 'a Process = 'a Signal IObservable \end{fslisting}   But it doesn't work. The output log says that the listing is not terminated - or is terminated by the document. So the rest of the document is also formatted as a listing, which is of course not the intention.  What am I doing wrong here?
15704
I know it's of course a dispute whether or not to support foreign languages on StackOverflow. However, my question is a bit different.  is in English, but has code with comments and identifiers in a foreign language. This limits the ability for people to leave answers.  Despite the fact that the example question I linked is poor regardless of language barrier, how should we [the users] handle such questions? Should we...   Accept them into StackOverflow and try to translate them? Cast close votes because we cannot understand to answer? Ask the OP to translate it to English for us? Wait for someone else to come translate it for us?   The same also applies when the code its self includes identifiers in a foreign language. In case this original question I linked gets deleted, here's the source from that question:  procedure TForm1.Button1Click(Sender: TObject); var   X: Integer; begin   for x := 1 to 5 do     if Sender = Botones[x] then //Valida el Boton que provoco el evento     begin       Codigo := x;   //Captura la posicion donde se eonctro el objeto que generó el evento       // ShowMessage(IntToStr(x));       Exit; //sale del bucle     end; end;
14732
Here on the StackExchange framework we have a nice feature, which is apparently called "Keyboard Glyphs" (cf. ):     CTRL+Z   Is there a way (e.g. with an Add-On) to do the same in Google Docs? I browsed the Add-Ons but did not find anything, maybe it's hidden somewhere different (e.g. in a Code Formatting Plugin).
33585
I'm looking for a programmers' editor. I know Xcode and I use it for application programming but I'm looking for something that will:   Syntax highlight PHP, SQL, Javascript (including jQuery) and CSS not required but would be nice; also Lua, Python, and Perl    IntelliSense type stuff, start typing and get all the functions/objects/variables it could be and any parameters. Xcode does this well for C/C++/Objective-C but looking for languages that are listed above. Would be nice if it worked with projects and not just files    Integrated with SVN, CVS, or GIT Had upload-to-server functionality built in   I am aware of  but am looking for other options before I drop 100 bucks.
579
I have defined my own language whose syntax is very close to the one of Pascal. I would like to type the following program for instance. Many people use the packages algorithmicx or algorithm2e to print programs, but it seems that we have to use their specific keywords of its syntax like procedure, end while.  I just want to indent spaces when needed, and bold some words when I want (sorry that I could not bold letters in the following figure). Do I have to use  texttt for each line? Also, with verbatim, I could not bold words...  Also, as the program is not large, I would need to put it on the left side of the page, and leave space for some explanasion text on its right hand side. So I  guss I need to get them all together, and use multicols.  Could anyone help?  program test                                      some text here var   i : integer;                                    ...    b : boolean; begin    i := 1;                                        ...    b := true;    while i &lt; 15 do       i := i  + 1;       b := not b                                  some text here    od end   Edit1: Following @Werner's tabbing solution, I have made the code a minipage:  \begin{minipage}[t]{0.48\linewidth}% \begin{tabbing} Werner's solution \end{tabbing} \end{minipage}\hfill \begin{minipage}[t]{0.48\linewidth} a paragraph \end{minipage}   Actually as the code shows, I want the texts to be another separated minipage on the right hand side of the code. I have then 2 questions:   is it reasonable to make 0.48\linewidth instead of 0.5\linewidth? 0.48\linewidth is a conventional choice? is it possible to make a frame around the code, and use \caption and \label to make it a reference (I prefer figures)?
48644
What Delphi coding standards document(s) do you follow?  Our company is looking at putting some better coding standards in place, to improve our code’s readability, reviewability, and maintainability.  We’ve come across CodeGear’s “Object Pascal Style Guide”, but it hasn’t been touched in quite a while and I imagine a number of people have made some local improvements or additions.  I’ve come across some published variations and other documents, which I will list, below.  NB: I do not want to start a style war.  I just want to know what standards you follow, and why.  Thanks.   UPDATE:  Well, the "JCL Delphi Language Style Guide" seems to be the clear winner!  Thanks!
49879
Currently when you search for a combination of tags in localized Stack Overflow you get some text in English. For example in Stack Overflow en español:       Etiquetadas con [python] or [php]        Etiquetadas con [python-3.x] not [python] not [bla]   Same in SOru:     С метками: [python-3.x] not [python] not [bla]   Looking for the text in traducir.win I could not find it, so I assume it is somehow hardcoded. Could you include it in Transifex?
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!
24253
I'm a programmer, and I find Mac's QuickLook a really great feature for quickly becoming familiar with a particular code base.  Basically, I open up a Finder window in the directory where my code files are, I push the spacebar (to evoke QuickLook), and then I arrow key up/down/left/right through all the files and scroll within QuickLook as needed.  The problem that I run into are files with no extension and files with unknown extension.  How can I convince the Mac to attempt to QuickLook these files as text files (which they usually are).  Also, it's really nice how QuickLook automatically colors the code based upon the type of code it thinks it is.  How can I extend the types of code files that the Mac recognizes?  For instance, I want to be able to QuickLook the code in a *.html.erb file or a *.js.erb file.
65937
When reviewing Suggested Edits on Stack Overflow, I often come across "fixed formatting" suggestions that use  to place emphasis on certain keywords, but isn't actual code.  For example:     I am having a difficult time with a background task in iOS. The problem I seem to be facing is that iOS is silently terminating the App if my background task runs for too long. What can I do to increase time iOS will wait for my background task to complete?   Gets edited to:     I am having a difficult time with a background task in iOS. The problem I seem to be facing is that iOS is silently terminating the App if my background task runs for too long. What can I do to increase time iOS will wait for my background task to complete?   This seems like an invalid use of an inline code span because, well, it isn't code, and it is distracting. There are a    of these edits being made. Often enough they get approved, which reinforces the behavior.  Is this a valid use of inline code spans? If not, should it be edited and corrected? Should edits suggesting these changes be rejected?