@@ -746,6 +746,140 @@ escapedSpace=true
746746 c .Assert (got , qt .Contains , "<p>私は太郎です。\n プログラミングが好きです。運動が苦手です。</p>\n " )
747747}
748748
749+ func TestConvertCJKWithExtensionFriendlyEmphasisParametrized (t * testing.T ) {
750+ c := qt .New (t )
751+
752+ content := "Git **(ギット)**Hub\n ~~(真美好)~~"
753+
754+ tests := []struct {
755+ name string
756+ strikethrough bool
757+ friendlyEmphasis bool
758+ expect string
759+ }{
760+ {"noFriendly_noStrike" , false , false , "<p>Git **(ギット)**Hub\n ~~(真美好)~~</p>\n " },
761+ {"friendly_noStrike" , false , true , "<p>Git <strong>(ギット)</strong>Hub\n ~~(真美好)~~</p>\n " },
762+ {"noFriendly_strike" , true , false , "<p>Git **(ギット)**Hub\n <del>(真美好)</del></p>\n " },
763+ {"friendly_strike" , true , true , "<p>Git <strong>(ギット)</strong>Hub\n <del>(真美好)</del></p>\n " },
764+ }
765+
766+ for _ , tt := range tests {
767+ c .Run (tt .name , func (c * qt.C ) {
768+ confStr := fmt .Sprintf (`
769+ [markup]
770+ [markup.goldmark]
771+ [markup.goldmark.extensions]
772+ strikethrough=%v
773+ [markup.goldmark.extensions.CJK]
774+ enable=true
775+ friendlyEmphasis=%v
776+ ` , tt .strikethrough , tt .friendlyEmphasis )
777+
778+ cfg := config .FromTOMLConfigString (confStr )
779+ conf := testconfig .GetTestConfig (nil , cfg )
780+
781+ b := convert (c , conf , content )
782+ got := string (b .Bytes ())
783+
784+ c .Assert (got , qt .Contains , tt .expect )
785+ })
786+ }
787+ }
788+
789+ func TestConvertCJKWithExtensionFriendlyEmphasisTableDriven (t * testing.T ) {
790+ c := qt .New (t )
791+
792+ content := "a\\ **()**\\ a𩸽**()**𩸽~~(真美好)~~"
793+
794+ tests := []struct {
795+ name string
796+ strikethrough bool
797+ escapedSpace bool
798+ friendlyEmphasis bool
799+ expect string
800+ }{
801+ {
802+ name : "noFriendly_noStrike_noEscaped" ,
803+ strikethrough : false ,
804+ escapedSpace : false ,
805+ friendlyEmphasis : false ,
806+ expect : "<p>a\\ <strong>()</strong>\\ a𩸽**()**𩸽~~(真美好)~~</p>\n " ,
807+ },
808+ {
809+ name : "noFriendly_noStrike_escaped" ,
810+ strikethrough : false ,
811+ escapedSpace : true ,
812+ friendlyEmphasis : false ,
813+ expect : "<p>a<strong>()</strong>a𩸽**()**𩸽~~(真美好)~~</p>\n " ,
814+ },
815+ {
816+ name : "noFriendly_strike_noEscaped" ,
817+ strikethrough : true ,
818+ escapedSpace : false ,
819+ friendlyEmphasis : false ,
820+ expect : "<p>a\\ <strong>()</strong>\\ a𩸽**()**𩸽<del>(真美好)</del></p>\n " ,
821+ },
822+ {
823+ name : "noFriendly_strike_escaped" ,
824+ strikethrough : true ,
825+ escapedSpace : true ,
826+ friendlyEmphasis : false ,
827+ expect : "<p>a<strong>()</strong>a𩸽**()**𩸽<del>(真美好)</del></p>\n " ,
828+ },
829+ {
830+ name : "friendly_noStrike_noEscaped" ,
831+ strikethrough : false ,
832+ escapedSpace : false ,
833+ friendlyEmphasis : true ,
834+ expect : "<p>a\\ <strong>()</strong>\\ a𩸽<strong>()</strong>𩸽~~(真美好)~~</p>\n " ,
835+ },
836+ {
837+ name : "friendly_noStrike_escaped" ,
838+ strikethrough : false ,
839+ escapedSpace : true ,
840+ friendlyEmphasis : true ,
841+ expect : "<p>a<strong>()</strong>a𩸽<strong>()</strong>𩸽~~(真美好)~~</p>\n " ,
842+ },
843+ {
844+ name : "friendly_strike_noEscaped" ,
845+ strikethrough : true ,
846+ escapedSpace : false ,
847+ friendlyEmphasis : true ,
848+ expect : "<p>a\\ <strong>()</strong>\\ a𩸽<strong>()</strong>𩸽<del>(真美好)</del></p>\n " ,
849+ },
850+ {
851+ name : "friendly_strike_escaped" ,
852+ strikethrough : true ,
853+ escapedSpace : true ,
854+ friendlyEmphasis : true ,
855+ expect : "<p>a<strong>()</strong>a𩸽<strong>()</strong>𩸽<del>(真美好)</del></p>\n " ,
856+ },
857+ }
858+
859+ for _ , tt := range tests {
860+ c .Run (tt .name , func (c * qt.C ) {
861+ confStr := fmt .Sprintf (`
862+ [markup]
863+ [markup.goldmark]
864+ [markup.goldmark.extensions]
865+ strikethrough=%v
866+ [markup.goldmark.extensions.CJK]
867+ enable=true
868+ escapedSpace=%v
869+ friendlyEmphasis=%v
870+ ` , tt .strikethrough , tt .escapedSpace , tt .friendlyEmphasis )
871+
872+ cfg := config .FromTOMLConfigString (confStr )
873+ conf := testconfig .GetTestConfig (nil , cfg )
874+
875+ b := convert (c , conf , content )
876+ got := string (b .Bytes ())
877+
878+ c .Assert (got , qt .Contains , tt .expect )
879+ })
880+ }
881+ }
882+
749883type tableRenderer int
750884
751885func (hr tableRenderer ) RenderTable (cctx context.Context , w hugio.FlexiWriter , ctx hooks.TableContext ) error {
0 commit comments