File tree Expand file tree Collapse file tree
app/services/import/jira_wiki_markup Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -535,7 +535,7 @@ def followed_by_word?(text, close_idx)
535535 def scan_subscript ( scanner , buffer , nodes )
536536 return unless scanner . rest [ 0 ] == "~"
537537
538- scanned = scanner . string [ 0 ... scanner . pos ]
538+ scanned = scanner . string . byteslice ( 0 , scanner . pos )
539539 return if ( scanned + buffer ) . end_with? ( "~" )
540540
541541 inner = extract_subscript_content ( scanner )
Original file line number Diff line number Diff line change 304304 expect ( described_class . new ( "*éé* and _öü_" ) . convert )
305305 . to eq ( "**éé** and *öü*" )
306306 end
307+
308+ it "handles Arabic inside bold" do
309+ expect ( described_class . new ( "*مرحبا*" ) . convert ) . to eq ( "**مرحبا**" )
310+ end
311+
312+ it "handles Chinese inside bold" do
313+ expect ( described_class . new ( "*你好*" ) . convert ) . to eq ( "**你好**" )
314+ end
315+
316+ it "handles Japanese inside italic" do
317+ expect ( described_class . new ( "_日本語_" ) . convert ) . to eq ( "*日本語*" )
318+ end
319+
320+ it "handles Cyrillic inside bold" do
321+ expect ( described_class . new ( "*Привет*" ) . convert ) . to eq ( "**Привет**" )
322+ end
323+
324+ it "handles Hebrew inside bold" do
325+ expect ( described_class . new ( "*שלום*" ) . convert ) . to eq ( "**שלום**" )
326+ end
327+
328+ it "handles 4-byte emoji inside bold" do
329+ expect ( described_class . new ( "*🎉*" ) . convert ) . to eq ( "**🎉**" )
330+ end
331+
332+ it "handles subscript after a macro preceded by a multi-byte character" do
333+ # Regression: scanner.string[0...scanner.pos] mixed byte-pos with char-slicing,
334+ # causing "é*x*~2~" to spuriously "see" the closing ~ in the already-scanned
335+ # prefix and skip subscript parsing.
336+ expect ( described_class . new ( "é*x*~2~" ) . convert ) . to eq ( "é**x**<sub>2</sub>" )
337+ expect ( described_class . new ( "🎉*x*~2~" ) . convert ) . to eq ( "🎉**x**<sub>2</sub>" )
338+ end
307339 end
308340 end
309341
You can’t perform that action at this time.
0 commit comments