Snow Flower Text Syntax Highlight

Snow Flower Text’s lightweight markup supports syntax highlighting of the source code. Syntax highlighting makes it easier to grasp the source code in a structured language such as a programming language or markup language by expressing it by color coding, making it easy to visually distinguish its structure. By highlighting the source code in the programming article, it becomes a document that is easy for the reader to read.

Source of Java language without syntax highlight
static int fibonacci(int n) {
    switch (n) {
        case 0: return 0;
        case 1: return 1;
        default: return fibonacci(n - 2) + fibonacci(n - 1);
    }
}
Source of syntax highlighted Java language
static int fibonacci(int n) {
switch (n) {
case 0: return 0;
case 1: return 1;
default: return fibonacci(n - 2) + fibonacci(n - 1);
}
}

In this article we will explain how to use the lightweight markup highlight function.

Snow Flower Text is a text editor that supports writing and programming.

1. Features

The syntax highlight function of Snow Flower Text has the following features.

Supports many programming languages

Snow Flower Text v1.7.x supports over 170 languages, including relatively new languages such as Go, Scala, TypeScript, CoffeeScript and others. For a list of supported languages, see “List of supported languages”.

Unified syntax highlight engine

Snow Flower Text is designed to minimize the difference in lightweight markup as much as possible. Snow Flower Text uses the unified highlight engine in AsciiDoc and MarkDown. Therefore, there is no difference in the spelling of the languages and languages supported by them.

It does not depend on setting of document viewing environment

The exported HTML file does not need to execute JavaScript for highlights. Highlighted HTML is output. Therefore, you do not need to specially load JavaScript files, you can easily post articles. Also, documents containing highlighted source code will work regardless of whether JavaScript on the Web browser is enabled or disabled.

2. How to use

AsciiDoc and Markdown enable syntax highlighting by specifying the language for the source code block. You can do it easily with the following procedure.

  1. Select the range of the source code.

  2. Select the menu Menu> Format > Code to mark up the selection as source code.

  3. By specifying the language according to the description format of the markup language, the source code is displayed with coloring according to the syntax classification. For languages that are not supported, it is simply ignored. Refer to “List of Support Languages” for specific language names that can be used.

    Descriptions in AsciiDoc

    Enclose the source code description in the [source] block and specify the programming language or markup language.

    [source, Language]
    ----------------------------------------
    Write source code here.
    ----------------------------------------

    or

    [source, language="Language"]
    ----------------------------------------
    Write source code here.
    ----------------------------------------

    Below is An example of highlighting C source code in AsciiDoc document.

    Example of using highlights in AsciiDoc document
    [source, c]
    ----------------------------------------
    #include <stdio.h>
    #include <stdlib.h>

    int main(void)
    {
    puts("Hello World!");
    return EXIT_SUCCESS;
    }
    ----------------------------------------
    Descriptions in MarkDown

    In the MarkDown document, specify the language following the backquote.

    ``` Language
    Write source code here.
    ```

    Below is An example of highlighting C source code in MarkDown document.

    Example of using highlights in MarkDown document
    ``` C
    #include <stdio.h>
    #include <stdlib.h>

    int main(void)
    {
    puts("Hello World!");
    return EXIT_SUCCESS;
    }
    ```

3. Syntax highlight usage example

The following is an example of actually highlighting using Snow Flower Text. The sample code is a simple program that outputs only “Hello, world” Extract languages that are considered to be relatively frequently used.

Since certain coloring rules are applied, you can see that it is easier to read even in unknown languages.

ActionScript – [source, actionscript]
package {
import flash.display.Sprite;
import flash.text.TextField;

public class HelloWorld extends Sprite {
public function HelloWorld():void {
var message:TextField = new TextField;
message.text = "Hello, World";
this.addChild(message);
}
}
}
AppleScript – [source, applescript]
display dialog "Hello, world"
AWK – [source, awk]
BEGIN { print "Hello, world" }
C – [source, c]
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
puts("Hello World!");
return EXIT_SUCCESS;
}
Bash – [source, bash]
echo 'Hello, world'
C++ – [source, cpp]
main()
{
cout << "Hello World!" << endl;
return 0;
}
Common Lisp – [source, commonlisp]
(print "Hello World")
Clojure – [source, clojure]
(javax.swing.JOptionPane/showMessageDialog nil "Hello World")
C# – [source, cs]
class HelloWorldApp {
public static void Main() {
System.Windows.Forms.MessageBox.Show("Hello, world");
}
}
Delphi – [source, delphi]
program HelloWorld;
uses
Dialogs;
begin
ShowMessage('Hello, World');
end.
Erlang – [source, erlang]
-module(hello).
-export([hello/0]).
hello() ->
io:format("Hello World~n", []).
f# – [source, fsharp]
printf "Hello World\n"
Go – [source, go]
package main
import "fmt"
func main() {
fmt.Printf("Hello World\n")
}
Groovy – [source, groovy]
println "Hello World"
Haskell – [source, haskell]
main = putStrLn "Hello World"
HTML – [source, html]
<HTML>
<!-- Hello World in HTML -->
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
Hello World
</BODY>
</HTML>
Java – [source, java]
import java.awt.*;
import java.awt.event.*;

public class HelloFrame extends Frame {
HelloFrame(String title) {
super(title);
}
public void paint(Graphics g) {
super.paint(g);
Insets ins = this.getInsets();
g.drawString("Hello, World", ins.left + 25, ins.top + 25);
}
public static void main(String[] args) {
HelloFrame fr = new HelloFrame("Hello");

fr.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
fr.setResizable(true);
fr.setSize(500, 100);
fr.setVisible(true);
}
}
Javascript – [source, js]
document.body.appendChild(document.createTextNode("Hello World"));
JSP – [source, jsp]
<%= "Hello, world" %>
Kotlin – [source, kotlin]
package hello

fun getHelloString() : String {
return "Hello, world!"
}

fun main(args : Array<String>) {
println(getHelloString())
}
Matlab – [source, matlab]
disp('Hello World');
Objective-C – [source, objc]
#include <stdio.h>
#include <objpak.h>
int main(int argc,char **argv)
{
id set = [Set new];
argv++;while (--argc) [set add:[String str:*argv++]];
[set do:{ :each | printf("hello, %s\n",[each str]); }];
return 0;
}
OCaml – [source, ocaml]
print_string "Hello World\n";;
Pascal – [source, pascal]
program HelloWorld(output);
begin
WriteLn('Hello World');
end.
Perl – [source, perl]
print "Hello World\n";
PHP – [source, php]
<?php
echo 'Hello, world';
exit;
?>
PL/SQL –
set serveroutput on
begin
dbms_output.enable(10000);
dbms_output.put_line('Hello World');
end;
/
Powershell – [source, powershell]
'Hello World'
Python – [source, python]
print "Hello World"
R – [source, r]
cat("Hello world\n")
Ruby – [source, ruby]
puts "Hello, world"
Rust – [source, rust]
fn main() {
io::println("hello, world");
}
Scala – [source, scala]
object HelloWorld extends Application {
println("Hello, world")
}
Scheme – [source, scheme]
(display "Hello, world")
(newline)
Smalltalk – [source, smalltalk]
'Hello, world' printOn: Transcript.
SQL – [source, sql]
select 'hello world' from dual;
select 'hello world';
Swift – [source, swift]
println("Hello World")
Tcl – [source, tcl]
puts "Hello, world"
TeX / LaTex – [source, tex]
\documentclass{article}
\begin{document}
Hello World
\end{document}
SVG – [source, svg]
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="6.4cm" height="4.8cm" viewBox="0 0 639 479"
xmlns="http://www.w3.org/2000/svg" version="1.1">

<desc>Hello, World</desc>
<text x="320" y="250" font-family="Verdana" font-size="1cm" text-anchor="middle">
Hello, world
</text>
</svg>
VB.NET – [source, vbnet]
Public Class HelloWorldApp
Shared Sub Main()
System.Windows.Forms.MessageBox.Show("Hello, World")
End Sub
End Class
Verilog – [source, verilog]
module main;
initial
begin
$display("Hello, World");
$finish ;
end
endmodule
VHDL – [source, vhdl]
ENTITY helloworld IS
END helloworld;

ARCHITECTURE hw OF helloworld IS

BEGIN

ASSERT FALSE
REPORT "HELLO, WORLD"
SEVERITY NOTE;

END hw;
XHTML – [source, xhtml]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<title>Hello, World</title>
</head>
<body>
<p>Hello, World</p>
</body>
</html>
XML – [source, xml]
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="HelloWorld.xsl" ?>
<!-- Hello World in XML -->
<text><string>Hello, World</string></text>

4. List of Support Languages

The following list is a syntax highlightable language supported by Snow Flower Text. It is specified as the highlight language of the source code. Case differences are ignored for language names.

  • 0-9

    • 1c

  • A

    • abnf

    • accesslog

    • actionscript

    • ada

    • apache

    • applescript

    • arduino

    • armasm

    • asciidoc

    • aspectj

    • autohotkey

    • autoit

    • avrasm

    • awk

    • axapta

  • B

    • bash

    • basic

    • bnf

    • brainfuck

  • C

    • cal

    • capnproto

    • ceylon

    • clean

    • clojure

    • clojure-repl

    • cmake

    • coffeescript

    • coq

    • cos

    • cpp

    • crmsh

    • crystal

    • cs

    • csp

    • css

  • D

    • d

    • dart

    • delphi

    • diff

    • django

    • dns

    • dockerfile

    • dos

    • dsconfig

    • dts

    • dust

  • E

    • ebnf

    • elixir

    • elm

    • erb

    • erlang

    • erlang-repl

    • excel

  • F

    • fix

    • flix

    • fortran

    • fsharp

  • G

    • gams

    • gauss

    • gcode

    • gherkin

    • glsl

    • go

    • golo

    • gradle

    • groovy

  • H

    • haml

    • handlebars

    • haskell

    • haxe

    • hsp

    • htmlbars

    • http

    • hy

  • I

    • inform7

    • ini

    • irpf90

  • J

    • java

    • javascript

    • jboss-cli

    • json

    • julia

    • julia-repl

  • K

    • kotlin

  • L

    • lasso

    • ldif

    • leaf

    • less

    • lisp

    • livecodeserver

    • livescript

    • llvm

    • lsl

    • lua

  • M

    • makefile

    • markdown

    • mathematica

    • matlab

    • maxima

    • mel

    • mercury

    • mipsasm

    • mizar

    • mojolicious

    • monkey

    • moonscript

  • N

    • n1ql

    • nginx

    • nimrod

    • nix

    • nsis

  • O

    • objectivec

    • ocaml

    • openscad

    • oxygene

  • P

    • parser3

    • perl

    • pf

    • php

    • pony

    • powershell

    • processing

    • profile

    • prolog

    • protobuf

    • puppet

    • purebasic

    • python

  • Q

    • q

    • qml

  • R

    • r

    • rib

    • roboconf

    • routeros

    • rsl

    • ruby

    • ruleslanguage

    • rust

  • S

    • scala

    • scheme

    • scilab

    • scss

    • shell

    • smali

    • smalltalk

    • sml

    • sqf

    • sql

    • stan

    • stata

    • step21

    • stylus

    • subunit

    • swift

  • T

    • taggerscript

    • tap

    • tcl

    • tex

    • thrift

    • tp

    • twig

    • typescript

  • V

    • vala

    • vbnet

    • vbscript

    • vbscript-html

    • verilog

    • vhdl

    • vim

  • X

    • x86asm

    • xl

    • xml

    • xquery

  • Y

    • yaml

  • Z

    • zephir

Download on the Mac App Store