Fix: number highlight

main
Leonid Maslakov 5 months ago
parent d4ba8aacb8
commit 66e9071240
  1. 2
      README.md
  2. 1
      highlight_c.go
  3. 2
      highlight_c_test.go
  4. 1
      highlight_golang.go
  5. 2
      highlight_gomod.go
  6. 1
      highlight_python.go
  7. 10
      highlight_share_nums.go
  8. 2
      highlight_sql.go

@ -14,7 +14,7 @@ Supported Go versions:
Add to `go.mod` file:
```go.mod
require github.com/lcomrade/highlight v1.0.2
require github.com/lcomrade/highlight v1
```

@ -122,6 +122,7 @@ package highlight
// Single-line comments (//)
// Multi-line comments (/* */)
// Single-line brackets (", ')
// Numbers (100, 1.2, 1.25)
func C(code string) string {
// Shild HTML
code = shieldHTML(code)

@ -40,7 +40,7 @@ int main() {
<span class='` + StyleKeyword + `'>int</span> main() {
printf(<span class='` + StyleBrackets + `'>"Hello, world!"</span>);
<span class='` + StyleKeyword + `'>return</span> 0;
<span class='` + StyleKeyword + `'>return</span> <span class='` + StyleNumber + `'>0</span>;
}
`,
},

@ -99,6 +99,7 @@ package highlight
// Multi-line comments (/* */)
// Single-line brackets (", ')
// Multi-line brackets (` `)
// Numbers (100, 1.2, 1.25)
func Golang(code string) string {
// Shild HTML
code = shieldHTML(code)

@ -32,7 +32,7 @@ package highlight
// Supported operators (const StyleOperator):
// =>
//
// Single-line comments (//) are also supported.
// Single-line comments (//) and numbers (100, 1.2, 1.25) are also supported.
func GoMod(code string) string {
// Shild HTML
code = shieldHTML(code)

@ -168,6 +168,7 @@ package highlight
// Multi-line comments (''' ''')
// Single-line brackets (", ')
// Multi-line brackets (""" """)
// Numbers (100, 1.2, 1.25)
func Python(code string) string {
// Shild HTML
code = shieldHTML(code)

@ -57,6 +57,8 @@ func formatNumber(text string, cmdStartChars []string, cmdEndChars []string) str
// Check
if otherSpanTagOpen == 0 {
ignoreNow := false
// Close buffer
if bufferOpen == true && isNumber(charRune) == false {
// Good close
@ -68,22 +70,18 @@ func formatNumber(text string, cmdStartChars []string, cmdEndChars []string) str
result = result + buffer
}
// Save
result = result + char
buffer = ""
bufferOpen = false
continue
}
// Open buffer
if bufferOpen == false && isInStrList(cmdStartChars, char) {
result = result + char
bufferOpen = true
continue
ignoreNow = true
}
// Continue read
if bufferOpen == true {
if bufferOpen == true && ignoreNow == false {
buffer = buffer + char
} else {

@ -55,7 +55,7 @@ package highlight
// WHERE
// WORK
//
// Brackets (", ') are also supported.
// Brackets (", ') and numbers (100, 1.2, 1.25) are also supported.
func SQL(code string) string {
// Shild HTML
code = shieldHTML(code)

Loading…
Cancel
Save