Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google prettify: ada syntax

I am currently trying to highlight Ada code on my website using google prettify and a file I have found here. However, I am not able to use the later file with prettify, and the automatic language detection messes up attributes with ' characters (such as Array'first or integer'image), and highlights them as string delimiters.

for instance, I have the following sample code, and I would like to have it formatted correctly in my page:

procedure mergesort (V: in out TV_integer; iterations: in out integer) is
-- {} => {V is sorted}
    m : integer := (V'first + V'last) / 2;
begin -- mergesort
    if V'length > 1 then
        mergesort(V(V'first..m), iterations);
        mergesort(V(m+1..V'last), iterations);
        merge(V(V'first..m),V(m+1..V'last),V,iterations);
    end if;
end mergesort;

Any help would be appreciated.

EDIT: I tried using a pre class="prettyprint lang-ada" tag so that it would use the lang-ada custom script, but without success.

like image 420
Siapran Avatar asked Dec 19 '22 21:12

Siapran


2 Answers

I'm the author of the Ada lexer for google code prettify. To use it, add this to your page:

<head>
    <!-- ... -->

    <link href="css/prettify.css" media="screen" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/prettify.js"></script>
    <script type="text/javascript" src="js/lang-ada.js"></script>
</head>

<body onload="prettyPrint()">

Do not use the auto-loader, it won't use custom lexers (change the paths to where you put the files of google code prettify). After you have done that, you can highlight code on your website like this:

<pre class="prettyprint lang-ada"><code>
-- Ada code
</code></pre>

or if you're using markdown or something else that prevents you from adding classes to your tags:

<?prettify lang=ada?>
<pre><code>
-- here goes your Ada code
</code></pre>

By the way, the Ada lexer will mark Ada attributes with the class atn (which is colored violet by default). If you want them to have the same color as other code, just edit prettify.css.

like image 53
flyx Avatar answered Jan 31 '23 10:01

flyx


Ada is not supported. A lexer has been submitted by fordprefect86, but has not (yet) been included. See Issue 312 for more information

like image 37
egilhh Avatar answered Jan 31 '23 10:01

egilhh