잉여개발기 (SPDV) 2 лет назад
Родитель
Сommit
e65f1e8b03

BIN
route_go/bin/main.amd64.bin


BIN
route_go/bin/main.amd64.exe


BIN
route_go/bin/main.arm64.bin


BIN
route_go/bin/main.arm64.exe


+ 1 - 0
route_go/go.mod

@@ -19,6 +19,7 @@ require (
 	cloud.google.com/go/compute/metadata v0.2.3 // indirect
 	cloud.google.com/go/longrunning v0.5.2 // indirect
 	filippo.io/edwards25519 v1.1.0 // indirect
+	github.com/dlclark/regexp2 v1.11.0 // indirect
 	github.com/dustin/go-humanize v1.0.1 // indirect
 	github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
 	github.com/golang/protobuf v1.5.3 // indirect

+ 2 - 0
route_go/go.sum

@@ -17,6 +17,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
 github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
+github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
 github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
 github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=

+ 13 - 21
route_go/route/tool/namumark.go

@@ -3,9 +3,10 @@ package tool
 import (
 	"database/sql"
 	"html"
-	"regexp"
 	"strconv"
 	"strings"
+
+	"github.com/dlclark/regexp2"
 )
 
 type namumark struct {
@@ -40,7 +41,7 @@ func Namumark_new(db *sql.DB, db_set map[string]string, data map[string]string)
 	}
 }
 
-func (class namumark) func_temp_save(data string) string {
+func (class *namumark) func_temp_save(data string) string {
 	name := "<temp_save_" + strconv.Itoa(class.temp_data_count) + ">"
 
 	class.temp_data[name] = data
@@ -53,40 +54,31 @@ func (class namumark) func_temp_restore(data string) string {
 	string_data := data
 
 	for k, v := range class.temp_data {
-		string_data = strings.Replace(string_data, "<"+k+">", v, 1)
+		string_data = strings.Replace(string_data, k, v, 1)
 	}
 
 	return string_data
 }
 
-func (class namumark) render_text() {
+func (class *namumark) render_text() {
 	string_data := class.render_data
 
-	temp_name := ""
-	stack_idx := false
-
-	r := regexp.MustCompile(`'''`)
-	for idx := r.FindStringIndex(string_data); len(idx) != 0; idx = r.FindStringIndex(string_data) {
-		if !stack_idx {
-			temp_name = class.func_temp_save("<b>")
-			stack_idx = true
-			string_data = strings.Replace(string_data, "'''", "<temp>", 1)
+	r := regexp2.MustCompile(`&#39;&#39;&#39;((?:(?!&#39;&#39;&#39;).)+)&#39;&#39;&#39;`, 0)
+	for {
+		if m, _ := r.FindStringMatch(string_data); m != nil {
+			gps := m.Groups()
 
+			temp_name := class.func_temp_save("<b>" + gps[1].Captures[0].String() + "</b>")
+			string_data = strings.Replace(string_data, m.String(), temp_name, 1)
 		} else {
-			string_data = strings.Replace(string_data, "<temp>", temp_name, 1)
-
-			temp_name = class.func_temp_save("</b>")
-			stack_idx = false
-			string_data = strings.Replace(string_data, "'''", temp_name, 1)
+			break
 		}
 	}
 
-	string_data = strings.Replace(string_data, "<temp>", "", 1)
-
 	class.render_data = string_data
 }
 
-func (class namumark) render_last() {
+func (class *namumark) render_last() {
 	string_data := class.render_data
 
 	string_data = class.func_temp_restore(string_data)