Enter your email Address

  • Home
  • Home
Expand All Collapse All
  • Testing New Updates
  • Code Samples
  • Adding a User
  • New Blocks Testing
  • About Infinity
    • Features in Infinity
    • Why Infinity?
  • Getting Started with Infinity
    • Contacting Infinity
  • Authoring Environment
    • How do Infinity features work?
      • Using Columns
      • Using Anchor Links
      • Using Tabs
      • Shortcode Testing
      • Image Zoom
      • Using Notes, Tips, Warnings
      • Using Audio and Video
      • Using Bullet Icons
      • Using Code Blocks
      • Using Collapsible Panels
      • Using Tables
      • Using File Attachment
    • Adding a new topic
    • Block Editor
      • Paragraph Block
      • Header Block
      • List Block
      • Image Block
      • Media and Text Block
      • Notices Block
      • File Block
      • Video Block
      • Code Block
      • Table Block
    • Adding links
      • Creating links to sections within a topic
    • Opening a topic in Edit mode
    • Quick Editing Topic Parameters
    • Adding Special Characters
    • Topic Content Statistics
    • Publishing a Topic
    • Updating a published topic
      • Updating a published topic for a later release
    • Public and Private Topics
      • Password Protecting a Topic
      • Role Based Access to Topic
    • Creating Table of Contents (TOC)
    • Categories
      • Creating a New Category
  • Reviews and Commenting
    • Comments Panel
    • Adding Review Comments
    • Editorial Comments Column
  • Media Library
    • About Media Library
    • Adding a Media to the Library
    • Inserting Media to the Topic
  • PDF Creation
    • Creating PDF of Single Topic
    • Creating PDF of Multiple Topics
  • Tools
    • Broken Link Check
  • Topic Revisions
    • Viewing Topic Revisions
    • Comparing Topic Revisions
    • Restoring the Topic Revision
  • FAQs
    • Managing FAQs
  • About Auth Armor API

Using Code Blocks

120 views 0

Export Pdf

Infinity provides different options to add code blocks in the documentation. The code blocks also provides syntax highlighting facility based on the code language selected.

Option 1: Simple Code Block

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Iterators
{
    public static class ForeachExamples
    {
        public static void ExampleOne()
        {
            var collection = new List<string>
            {
                "Hello",
                "World",
                "Iterators",
                "are",
                "awesome"
            };
            foreach (var item in collection)
            {
                Console.WriteLine(item.ToString());
            }
        }
    }
}

Code Blocks in Horizontal Tabs

    .NET
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    namespace Iterators
    {
        public static class ForeachExamples
        {
            public static void ExampleOne()
            {
                var collection = new List<string>
                {
                    "Hello",
                    "World",
                    "Iterators",
                    "are",
                    "awesome"
                };
                foreach (var item in collection)
                {
                    Console.WriteLine(item.ToString());
                }
            }
        }
    }
    Java
    import java.util.Scanner;  
    public class DiamondCharacterPattern  {  
    	public static void main(String[] args)   {  
    		char[] alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };  
    		int alphabet _number = 0;  
    		String[] diamond = new String[26]; // array of strings  
    		System.out.print("Enter a Character between A to Z : ");  
    		Scanner reader = new Scanner(System.in);  
    		try {  
    			char user_ alphabet = reader.next("[A-Z]").charAt(0);  
    			// search for letter number in the array letter  
    			for (int i = 0; i < alphabet.length; i++)  {  
    				if (letter[i] == user_ alphabet) {  
    					alphabet _number = i;  
    					break;  
    				}  
    			}  
    			//construct diamond  
    			for (int i = 0; i <= alphabet _number; i++) {  
    				diamond[i] = "";  
    				//add initial spaces  
    				for (int j = 0; j < alphabet _number - i; j++) {  
    					diamond[i] += " ";  
    				}  
    				// add alphabet  
    				diamond[i] += alphabet  
    				//add space between letters  
    				if (alphabet[i] != 'A') {  
    					for (int j = 0; j < 2 * i - 1; j++) {   
    						diamond[i] += " ";   	
    					}   
    					// add alphabet  
    					diamond[i] += alphabet[i];   
    				}   
    				// Draw the first part of the diamond   
    				System.out.println(diamond[i]);   
    			}   
    			for (int i = alphabet _number - 1; i >= 0; i--) {  
    				// Draw the second part of the diamond  
    				// prints the diamondArray in the reverse order  
    				System.out.println(diamond[i]);  
    			}  
    		}  
    		catch (Exception e) {  
    			e.printStackTrace();  
    		}  
    		finally {  
    			reader.close();  
    		}  
    	}  
    }
    PHP
    <?php
    // PHP program to prepend a string 
      
      
    // Function to prepend a string 
    function prepend_string ($str1, $str2){
          
        // Using concatenation operator (.)
        $res = $str1 . $str2;
          
        // Returning the result 
        return $res;
        }
      
    // Given string
    $str1 = "Geeksforgeeks"; 
    $str2 = "Example"; 
      
    // Function Call
    $str = prepend_string ($str1, $str2); 
      
    // Printing the result
    echo $str; 
    ?>

    Was this helpful?

    Yes  No

    Didn't find your answer? Contact Us

    Previously
    Using Bullet Icons
    Up Next
    Using Collapsible Panels
    Recent Topics
    • Testing New Updates
    • Code Samples
    • New Blocks Testing
    • Adding a User
    • Using Code Blocks
    Popular Topics
    • New Blocks Testing
    • About Infinity
    • About Auth Armor API
    • Testing New Updates
    • Block Editor
    Tags
    column column with image publishing single column
    Infinity, a simple yet powerful cloud based authoring environment for technical writers to prepare technical documentation collaboratively.
    Categories
    • Video tutorials
    • Knowledge base
    • FAQs
    Support
    • Documentation
    • Forum
    Need Support?
    If you need any further help, don't hesitate to send contact us usign any of the following options:
    contact@quickdraft.pro
    +91 9922113311 | +91 7588623823
    • Privacy Policy
    • Terms of Use
    • Copyright © 2022 by QuickDraft LLP. All Rights Reserved.