Documentation
¶
Index ¶
- Constants
- func ByName(code string, language string) (string, error)
- func C(code string) string
- func Dockerfile(code string) string
- func GoMod(code string) string
- func Golang(code string) string
- func INI(code string) string
- func JSON(code string) string
- func Java(code string) string
- func Python(code string) string
- func RobotsTxt(code string) string
- func SQL(code string) string
Constants ¶
const ( StyleKeyword = "code-keyword" StyleOperator = "code-operator" StyleVarType = "code-var-type" StyleBuildInVar = "code-build-in-var" StyleBuildInFunc = "code-build-in-func" StyleComment = "code-comment" StyleBrackets = "code-brackets" StyleKey = "code-key" StyleValue = "code-value" )
These constants describe the name of the class that will be assigned to the HTML tag '<span>'.
Examples:
<span style='code-keyword'>User-Agent:</span> <span style='code-comment'># My comment</span>
Variables ¶
This section is empty.
Functions ¶
func ByName ¶
ByName helps to highlight code based on the language name. This can be useful for Markdown and some other cases. The name of the language is not case sensitive.
| Function name | Language name | |---------------|-----------------| | C | c | | Dockerfile | dockerfile | | Golang | go, golang | | GoMod | go.mod | | INI config | ini | | Java | java | | JSON | json | | Python | python, python3 | | RobotsTxt | robots.txt | | SQL | sql |
func C ¶
C processes C source code (*.c files).
Supported preprocessor directives (const StyleKeyword):
#define #elif #else #endif #error #if #ifdef #ifndef #import #include #line #pragma #undef #using
Supported keywords (const StyleKeyword):
auto break case char const continue default do double else enum extern float for goto if inline int long register restrict return short signed sizeof static struct switch typedef union unsigned void volatile while _Alignas _Alignof _Atomic _Bool _Complex _Decimal128 _Decimal32 _Decimal64 _Generic _Imaginary _Noreturn _Static_assert _Thread_local
Supported operators (const StyleOperator):
-> == != <=> <<= =>> << >> <= < >= > = ^ && & || ?: %= &= ^= |= ++ -- + - ! ~ * / %
Also supported:
Single-line comments (//) Multi-line comments (/* */) Single-line brackets (", ') Numbers (100, 1.2, 1.25)
func Dockerfile ¶
Dockerfile processes Docker builder files. Read more: https://docs.docker.com/engine/reference/builder/
Supported commands (const StyleKeyword):
FROM RUN CMD LABEL MAINTAINER EXPOSE ENV ADD COPY ENTRYPOINT VOLUME USER WORKDIR ARG ONBUILD STOPSIGNAL HEALTHCHECK SHELL
Comments (#) are also supported.
func GoMod ¶ added in v1.0.2
GoMod processes go.mod files. Read more: https://go.dev/ref/mod#go-mod-file-module
Supported keywords (const StyleKeyword):
module go require exclude replace retract
Supported operators (const StyleOperator):
=>
Single-line comments (//) and numbers (100, 1.2, 1.25) are also supported.
func Golang ¶
Golang processes go source code (*.go files). Read more: https://go.dev/ref/spec
Supported keywords (const StyleKeyword):
break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var
Supported values (const StyleValue):
true false nil All numbers (100, 1.3, 2.25)
Supported operators (const StyleOperator):
! != % & && &^ * + - / < <- << <= == > >= >> ^ | || = :=
Supported variable types (const StyleVarType):
bool uint uint8 uint16 uint32 uint64 uintptr int int8 int16 int32 int64 float32 float64 complex64 complex128 byte rune string
Supported built-in functions (const StyleBuildInFunc):
append cap close complex copy delete imag len make new panic print println real recover
Also supported:
Single-line comments (//) Multi-line comments (/* */) Single-line brackets (", ') Multi-line brackets (` `)
func INI ¶ added in v1.0.4
INI processes .INI configuration files. Read more: https://en.wikipedia.org/wiki/INI_file
Supported:
Sections ([....]) Single-line comments (# and ;)
func JSON ¶ added in v1.0.4
JSON processes JSON config files (*.json files). Read more: https://en.wikipedia.org/wiki/JSON
Supported values (const StyleValue):
true false null All numbers (100, 1.3, 2.25)
Also supported:
Single-line comments (//) Multi-line comments (/* */) Single-line brackets (", ')
func Java ¶ added in v1.0.4
Java processes Java source code (*.java files). Read more: https://en.wikipedia.org/wiki/Java_(programming_language)
Supported keywords (const StyleKeyword):
abstract assert break case catch class const continue default do else enum extends final finally for goto if implements import instanceof interface native new package private protected public return static strictfp super switch synchronized this throw throws transient try void volatile while
Supported values (const StyleValue):
true false null All numbers (100, 1.3, 2.25)
Supported operators (const StyleOperator):
! != % %= && &= */ *= + ++ += - -- -= /= < <<= <= = == > >= >>= ^= |= ||
Supported variable types (const StyleVarType):
boolean byte char double float int long short String
Also supported:
Single-line comments (//) Multi-line comments (/* */) Single-line brackets (", ') Multi-line brackets (""" """)
func Python ¶
Python processes python source code (*.py files). Read more: https://docs.python.org/3/reference/index.html
Supported keywords (const StyleKeyword):
and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield
Supported values (const StyleValue):
True False None All numbers (100, 1.3, 2.25)
Supported operators (const StyleOperator):
+ - * ** / // % @ << >> & | ^ ~ := < > <= >= == !=
Supported import-related module attributes (const StyleBuildInVar):
__name__ __loader__ __package__ __spec__ __path__ __file__ __cached__
Supported built-in functions (const StyleBuildInFunc):
abs() aiter() all() any() anext() ascii() bin() bool() breakpoint() bytearray() bytes() callable() chr() classmethod() compile() complex() delattr() dict() dir() divmod() enumerate() eval() exec() filter() float() format() frozenset() getattr() globals() hasattr() hash() help() hex() id() input() int() isinstance() issubclass() iter() len() list() locals() map() max() memoryview() min() next() object() oct() open() ord() pow() print() property() range() repr() reversed() round() set() setattr() slice() sorted() staticmethod() str() sum() super() tuple() type() vars() zip() __import__()
Also supported:
Single-line comments (#) Multi-line comments (''' ''') Single-line brackets (", ') Multi-line brackets (""" """)
func RobotsTxt ¶
RobotsTxt processes robots.txt files (Robots exclusion standard). Read more: https://en.wikipedia.org/wiki/Robots_exclusion_standard
Supports standard directives (const StyleKeyword):
User-agent Disallow
And nonstandard extensions (const StyleKeyword):
Allow Crawl-delay Sitemap Host
Comments (#) are also supported.
func SQL ¶ added in v1.0.2
SQL processes Structured Query Language. Read more: https://en.wikipedia.org/wiki/SQL
Supported keywords (const StyleKeyword):
ALTER AND AS BEGIN COMMIT CONNECT BY CREATE DELETE DENY DROP FROM GRANT GROUP BY HAVING IN INSERT INTO JOIN OR ORDER BY RELEASE REVOKE ROLLBACK ROLLBACK TO SAVEPOINT SELECT SET TRANSACTION UPDATE VALUES WHERE WORK
Brackets (", ') and numbers (100, 1.2, 1.25) are also supported.
Types ¶
This section is empty.