From 974b8b5068b688258dbe1ffcc37d0ce0f3f4b4c7 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 18 Feb 2026 11:12:44 +0700 Subject: all: fix parsing inline format with escaped character If the text inside the inline format contains escaped character, the parsing failed to find the closed character which cause the format is not rendered as expected. --- asciidoctor.go | 2 +- inline_parser.go | 5 ++++- inline_parser_test.go | 2 +- testdata/inline_parser/inline_parser_test.txt | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/asciidoctor.go b/asciidoctor.go index 3c89afa..a762b9c 100644 --- a/asciidoctor.go +++ b/asciidoctor.go @@ -14,7 +14,7 @@ import ( ) // Version of this module. -const Version = `0.7.3` +const Version = `0.7.4` const _lf = "\n" diff --git a/inline_parser.go b/inline_parser.go index 84fae21..9a33b56 100644 --- a/inline_parser.go +++ b/inline_parser.go @@ -1,5 +1,5 @@ -// SPDX-FileCopyrightText: 2020 M. Shulhan // SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2020 M. Shulhan package asciidoctor @@ -1074,6 +1074,9 @@ func indexByteUnescape(in []byte, c byte) (out []byte, idx int) { } return out, x } + if isEsc { + isEsc = false + } out = append(out, in[x]) } return nil, -1 diff --git a/inline_parser_test.go b/inline_parser_test.go index a468975..1e051be 100644 --- a/inline_parser_test.go +++ b/inline_parser_test.go @@ -1,5 +1,5 @@ -// SPDX-FileCopyrightText: 2020 M. Shulhan // SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2020 M. Shulhan package asciidoctor diff --git a/testdata/inline_parser/inline_parser_test.txt b/testdata/inline_parser/inline_parser_test.txt index b40465d..8057970 100644 --- a/testdata/inline_parser/inline_parser_test.txt +++ b/testdata/inline_parser/inline_parser_test.txt @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2022 M. Shulhan + Various tests for inlineParser. >>> @@ -45,6 +48,7 @@ _A _B `A` B `A `B A `/**/` *B* +`/\*` comment `\*/` <<< parseFormat _A_B @@ -57,6 +61,7 @@ _A _B A B `A `B A // B +/* comment */ >>> parseFormatUnconstrained __A__B -- cgit v1.3