diff --git a/docs/vfm.md b/docs/vfm.md
index 2715ae1..14527aa 100644
--- a/docs/vfm.md
+++ b/docs/vfm.md
@@ -12,6 +12,7 @@ Vivliostyle Flavored Markdown (VFM), a Markdown syntax optimized for book author
- [Image](#image)
- [with caption and single line](#with-caption-and-single-line)
- [Ruby](#ruby)
+ - [Escape pipe in ruby body](#escape-pipe-in-ruby-body)
- [Sectionization](#sectionization)
- [Plain section](#plain-section)
- [Raw HTML](#raw-html)
@@ -169,8 +170,6 @@ figure figcaption {
## Ruby
-
a|b
+``` + ## Sectionization Make the heading a hierarchical section. diff --git a/src/plugins/ruby.ts b/src/plugins/ruby.ts index 2777c62..b5fb73c 100644 --- a/src/plugins/ruby.ts +++ b/src/plugins/ruby.ts @@ -10,7 +10,8 @@ function locateRuby(value: string, fromIndex: number) { const tokenizer: Tokenizer = function (eat, value, silent) { const now = eat.now(); - const match = /^{(.+?)\|(.+?)}/.exec(value); + ///const match = /^{(.+?)\|(.+?)}/.exec(value); + const match = /^{(.+?)(?<=[^\\|])\|(.+?)}/.exec(value); if (!match) return; const [eaten, inlineContent, rubyText] = match; diff --git a/tests/ruby.test.ts b/tests/ruby.test.ts index 04c3019..7510fec 100644 --- a/tests/ruby.test.ts +++ b/tests/ruby.test.ts @@ -1,79 +1,36 @@ -import { stripIndent } from 'common-tags'; -import { buildProcessorTestingCode } from './utils'; +import { stringify } from '../src/index'; -it( - 'simple ruby', - buildProcessorTestingCode( - `{a|b}`, - stripIndent` - root[1] - └─0 paragraph[1] - └─0 ruby[1] - │ data: {"hName":"ruby","rubyText":"b"} - └─0 text "a" - `, - `a
`, - ), -); +const options = { + partial: true, + disableFormatHtml: true, +}; -it( - 'enables escape in ruby body', - buildProcessorTestingCode( - `{a\\|b|c}`, - stripIndent` - root[1] - └─0 paragraph[1] - └─0 ruby[1] - │ data: {"hName":"ruby","rubyText":"b|c"} - └─0 text "a\\\\" - `, - `a\\
`, - ), -); +it('Simple ruby', () => { + const received = stringify(`{a|b}`, options); + const expected = `a
`; + expect(received).toBe(expected); +}); -it( - 'disables any inline rule in