diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8021d8e..e05d7c8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -102,6 +102,7 @@ jobs: release_tag: ${{steps.tag.outputs.tag}} goos: ${{ matrix.goos }} goarch: ${{ matrix.goarch }} + goversion: 1.21 md5sum: FALSE extra_files: LICENSE README.md assets/* #将这些文件一并打包 ldflags: -X "github.com/ludoux/ngapost2md/nga.DEBUG_MODE=0" -X "github.com/ludoux/ngapost2md/nga.BUILD_TS=${{ env.BUILD_TS }}" -X github.com/ludoux/ngapost2md/nga.GIT_REF=${{ github.ref }} -X github.com/ludoux/ngapost2md/nga.GIT_HASH=${{ github.sha }} diff --git a/README.md b/README.md index a9e4625..2ad7e76 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ngapost2md ver.[NEO_1.5.1] +# ngapost2md ver.[NEO_1.5.2] ngapost2md 是一个将 NGA 论坛帖子转换为 Markdown 格式的工具。它支持快速爬楼并存储回复人、时间和内容,同时支持保存正文图片。 diff --git a/nga/nga.go b/nga/nga.go index ff99e12..495cd7f 100644 --- a/nga/nga.go +++ b/nga/nga.go @@ -37,7 +37,7 @@ var ( // 这里配置文件和传参都没法改 var ( - VERSION = "1.5.1" //需要手动改 + VERSION = "1.5.2" //需要手动改 BUILD_TS = "1691664141" //无需,GitHub actions会自动填写 GIT_REF = "" //无需,GitHub actions会自动填写 GIT_HASH = "" //无需,GitHub actions会自动填写 @@ -457,7 +457,13 @@ func (tiezi *Tiezi) fixContent(floor_i int) { for i := 0; i < quoteCount; i++ { //最内层的quote下标 quoteStartIndex := strings.LastIndex(cont, "[quote]") + if quoteStartIndex < 0 { + break + } quoteEndIndex := quoteStartIndex + strings.Index(cont[quoteStartIndex:], "[/quote]") + if quoteEndIndex < 0 || quoteStartIndex >= quoteEndIndex+8 { + break + } clip := cont[quoteStartIndex : quoteEndIndex+8] reg_str := `(?s)\[quote\]\[pid=(\d+?),.+?Post by \[uid.*?\](.+)\[\/uid\].*?\((\d{4}.+?)\):(.+?)\[/quote\]((?:\n){0,2})` @@ -562,6 +568,11 @@ func (tiezi *Tiezi) fixFloorContent(startFloor_i int) { wg.Wait() elapsedTime := time.Since(startTime) / time.Millisecond log.Printf("修正楼层总耗时: %dms\n", elapsedTime) + // 如果为了调试取消并行的话,上述代码均注释,换成下面的 + // for i := startFloor_i; i < len(tiezi.Floors); i++ { + // log.Printf("开始修正第 %02d 楼层", i) + // tiezi.fixContent(cast.ToInt(i)) + // } }