Questions tagged [google-code-prettify]

Prettify is a JavaScript module and CSS file that allows syntax highlighting of source code snippets in an HTML page.

Google Code Prettify is a JavaScript module and CSS file that allows syntax highlighting of source code snippets in an HTML page.

Features

  • Works on HTML pages
  • Works even if code contains embedded links, line numbers, etc.
  • Simple API: Include some JavaScript code and CSS, and add an onload handler.
  • Lightweight: Small download and does not block page from loading while running.
  • Customizable styles via CSS. See the themes gallery
  • Supports all C-like, Bash-like, and XML-like languages. No need to specify the language
  • Extensible language handlers for other languages. You can specify the language.
  • Widely used with good cross-browser support.
103 questions
1
vote
1 answer

Google Prettify cutting my code- need fix

currently I have code that is being cut off at the < in the for loop because the browser treats it as a tag, does anyone have a fix for this?:
int count_simd(char *arr, int len, char key) {
    int count = 0;
    __m128i…
TheoretiCAL
  • 19,461
  • 8
  • 43
  • 65
1
vote
1 answer

Google Prettify with Lex tag Parser Code

It appears Google Prettify doesn't like lex parser tags. I've added the following to a blog post that uses prettify to format code:
{{ widgets:area slug="above-body" }} {{…
Dan Bough
  • 499
  • 1
  • 10
  • 23
1
vote
1 answer

Why does caja sanitization of Google Apps Script htmloutput fail on particular strings

I am trying to prepare GAS code samples for embedding in Google Sites and other web sites. I use the HtmlService.createHtmlOutput and HtmlService.createTemplateFromFile() and template.evaluate().getContent() to serve up an html version of the…
1
vote
1 answer

Google code prettify thinks css #id's are line comment. What am I doing wrong?

Example CSS #wrap{margin:20px} Code prettify wraps the whole line in .com #wrap{margin:20px} Somebody has a similar issue here. Where someone answers "Are you loading lang-css.js?". Here's what I'm loading in the…
any_h
  • 530
  • 3
  • 10
  • 27
1
vote
2 answers

Why does the google code prettifier refuse to work with XSLT?

The google code prettifier (which is also used here, on SO) parses the content of a .prettyprint and injects some s to allow highlighting via css. This works perfectly simple, unless I'm serving an XML file with an XSLT. Then, the prettifier…
bitmask
  • 32,434
  • 14
  • 99
  • 159
0
votes
1 answer

How auto justify codes with google code prettify?

I use code-prettify and work like a charm How can I justify codes? I add this code: But I want print this: remove extra space ?> //--> remove extra space
No NAME
  • 159
  • 1
  • 10
0
votes
1 answer

How to prettify dynamic code snippets in React?

I've looked into code prettifiers like google-code-prettify, beautify, etc. Unfortunately, I haven't been able to get any of these to work in my React app. I am currently using react-ace to display dynamically populated code snippets, but they are…
Hani Honey
  • 2,101
  • 11
  • 48
  • 76
0
votes
1 answer

Google prettifier line slicing and white background

When I add line numbers with more than 4 digit numbers it's lines are sliced out of the code box. When I use background-color: #eee; all works great but it works not for white colour background-color: #fff;. How to fix line numbers slicing out of…
Ivan Shelonik
  • 1,958
  • 5
  • 25
  • 49
0
votes
0 answers

Is there a way to auto scroll the page to a particular line number of code, formatted using google code-prettify?

I am writing a small application to display c++ code in the browser and using Google code-prettify for it. As a requirement, I have to scroll to a particular line number. After some searching, I found to select node, I can use the following…
0
votes
2 answers

Use code-prettify with rendered content reactjs

I am using reactjs to render post. In my post, I have some tag . So I want to display code for everyone easy to see. I render my post like this with reactjs.
Hai Tien
  • 2,929
  • 7
  • 36
  • 55
0
votes
1 answer

Use code-prettify in javascript using local pretty.css?

code-prettify seems to want to grab pretty.css from a cdn, rather than use a local copy - is it possible to configure things so that it uses the local version without a network call?
user655489
  • 1,316
  • 3
  • 14
  • 21
0
votes
1 answer

Accessing nth-child using id in angular

I am trying to color specific lines using code-prettify. I am getting data from my backend in terms of line numbers and want to highlight them. If I write this in my css file: #file2 li:nth-child(n+1):nth-child(-n+11) { background:…
0
votes
1 answer

Google Code Prettify doesnt syntax highlight on click

I use Google Code Prettify to syntax highlight my code. This is my HTML
        
Flo
  • 2,699
  • 4
  • 24
  • 46