@@ -775,11 +775,11 @@ fn assert_no_errors(
775775fn markdown_parsing ( ) {
776776 assert_eq ! (
777777 assert_no_errors( parse_interpolated:: <& [ _] >( "hello *world*" , & [ ] ) ) ,
778- [ StyledTextParagraph {
778+ [ ParagraphBlock :: Text ( RichText {
779779 text: "hello world" . into( ) ,
780780 formatting: alloc:: vec![ FormattedSpan { range: 6 ..11 , style: Style :: Emphasis } ] ,
781781 links: alloc:: vec:: Vec :: new( )
782- } ]
782+ } ) ]
783783 ) ;
784784
785785 assert_eq ! (
@@ -791,16 +791,16 @@ fn markdown_parsing() {
791791 & [ ]
792792 ) ) ,
793793 [
794- StyledTextParagraph {
794+ ParagraphBlock :: Text ( RichText {
795795 text: "• line 1" . into( ) ,
796796 formatting: alloc:: vec:: Vec :: new( ) ,
797797 links: alloc:: vec:: Vec :: new( )
798- } ,
799- StyledTextParagraph {
798+ } ) ,
799+ ParagraphBlock :: Text ( RichText {
800800 text: "• line 2" . into( ) ,
801801 formatting: alloc:: vec:: Vec :: new( ) ,
802802 links: alloc:: vec:: Vec :: new( )
803- }
803+ } )
804804 ]
805805 ) ;
806806
@@ -814,21 +814,21 @@ fn markdown_parsing() {
814814 & [ ]
815815 ) ) ,
816816 [
817- StyledTextParagraph {
817+ ParagraphBlock :: Text ( RichText {
818818 text: "1. a" . into( ) ,
819819 formatting: alloc:: vec:: Vec :: new( ) ,
820820 links: alloc:: vec:: Vec :: new( )
821- } ,
822- StyledTextParagraph {
821+ } ) ,
822+ ParagraphBlock :: Text ( RichText {
823823 text: "2. b" . into( ) ,
824824 formatting: alloc:: vec:: Vec :: new( ) ,
825825 links: alloc:: vec:: Vec :: new( )
826- } ,
827- StyledTextParagraph {
826+ } ) ,
827+ ParagraphBlock :: Text ( RichText {
828828 text: "3. c" . into( ) ,
829829 formatting: alloc:: vec:: Vec :: new( ) ,
830830 links: alloc:: vec:: Vec :: new( )
831- }
831+ } )
832832 ]
833833 ) ;
834834
@@ -841,7 +841,7 @@ new *line*
841841 & [ ]
842842 ) ) ,
843843 [
844- StyledTextParagraph {
844+ ParagraphBlock :: Text ( RichText {
845845 text: "Normal italic strong strikethrough code" . into( ) ,
846846 formatting: alloc:: vec![
847847 FormattedSpan { range: 7 ..13 , style: Style :: Emphasis } ,
@@ -850,12 +850,12 @@ new *line*
850850 FormattedSpan { range: 35 ..39 , style: Style :: Code }
851851 ] ,
852852 links: alloc:: vec:: Vec :: new( )
853- } ,
854- StyledTextParagraph {
853+ } ) ,
854+ ParagraphBlock :: Text ( RichText {
855855 text: "new line" . into( ) ,
856856 formatting: alloc:: vec![ FormattedSpan { range: 4 ..8 , style: Style :: Emphasis } , ] ,
857857 links: alloc:: vec:: Vec :: new( )
858- }
858+ } )
859859 ]
860860 ) ;
861861
@@ -870,78 +870,78 @@ new *line*
870870 & [ ]
871871 ) ) ,
872872 [
873- StyledTextParagraph {
873+ ParagraphBlock :: Text ( RichText {
874874 text: "• root" . into( ) ,
875875 formatting: alloc:: vec:: Vec :: new( ) ,
876876 links: alloc:: vec:: Vec :: new( )
877- } ,
878- StyledTextParagraph {
877+ } ) ,
878+ ParagraphBlock :: Text ( RichText {
879879 text: " ◦ child" . into( ) ,
880880 formatting: alloc:: vec:: Vec :: new( ) ,
881881 links: alloc:: vec:: Vec :: new( )
882- } ,
883- StyledTextParagraph {
882+ } ) ,
883+ ParagraphBlock :: Text ( RichText {
884884 text: " ▪ grandchild" . into( ) ,
885885 formatting: alloc:: vec:: Vec :: new( ) ,
886886 links: alloc:: vec:: Vec :: new( )
887- } ,
888- StyledTextParagraph {
887+ } ) ,
888+ ParagraphBlock :: Text ( RichText {
889889 text: " • great grandchild" . into( ) ,
890890 formatting: alloc:: vec:: Vec :: new( ) ,
891891 links: alloc:: vec:: Vec :: new( )
892- } ,
892+ } ) ,
893893 ]
894894 ) ;
895895
896896 assert_eq ! (
897897 assert_no_errors( parse_interpolated:: <& [ _] >( "hello [*world*](https://example.com)" , & [ ] ) ) ,
898- [ StyledTextParagraph {
898+ [ ParagraphBlock :: Text ( RichText {
899899 text: "hello world" . into( ) ,
900900 formatting: alloc:: vec![
901901 FormattedSpan { range: 6 ..11 , style: Style :: Emphasis } ,
902902 FormattedSpan { range: 6 ..11 , style: Style :: Link }
903903 ] ,
904904 links: alloc:: vec![ ( 6 ..11 , "https://example.com" . into( ) ) ]
905- } ]
905+ } ) ]
906906 ) ;
907907
908908 assert_eq ! (
909909 assert_no_errors( parse_interpolated:: <& [ _] >( "<u>hello world</u>" , & [ ] ) ) ,
910- [ StyledTextParagraph {
910+ [ ParagraphBlock :: Text ( RichText {
911911 text: "hello world" . into( ) ,
912912 formatting: alloc:: vec![ FormattedSpan { range: 0 ..11 , style: Style :: Underline } , ] ,
913913 links: alloc:: vec:: Vec :: new( )
914- } ]
914+ } ) ]
915915 ) ;
916916
917917 assert_eq ! (
918918 assert_no_errors( parse_interpolated:: <& [ _] >(
919919 r#"<font color="blue">hello world</font>"# ,
920920 & [ ]
921921 ) ) ,
922- [ StyledTextParagraph {
922+ [ ParagraphBlock :: Text ( RichText {
923923 text: "hello world" . into( ) ,
924924 formatting: alloc:: vec![ FormattedSpan {
925925 range: 0 ..11 ,
926926 style: Style :: Color ( 0xff_00_00_ff )
927927 } , ] ,
928928 links: alloc:: vec:: Vec :: new( )
929- } ]
929+ } ) ]
930930 ) ;
931931
932932 assert_eq ! (
933933 assert_no_errors( parse_interpolated:: <& [ _] >(
934934 r#"<u><font color="red">hello world</font></u>"# ,
935935 & [ ]
936936 ) ) ,
937- [ StyledTextParagraph {
937+ [ ParagraphBlock :: Text ( RichText {
938938 text: "hello world" . into( ) ,
939939 formatting: alloc:: vec![
940940 FormattedSpan { range: 0 ..11 , style: Style :: Color ( 0xff_ff_00_00 ) } ,
941941 FormattedSpan { range: 0 ..11 , style: Style :: Underline } ,
942942 ] ,
943943 links: alloc:: vec:: Vec :: new( )
944- } ]
944+ } ) ]
945945 ) ;
946946
947947 // Invalid color: text still renders, error is reported
@@ -950,14 +950,14 @@ new *line*
950950 parse_interpolated :: < & [ _ ] > ( r#"<u><font color="\#a">hello world</font></u>"# , & [ ] ) ;
951951 assert_eq ! (
952952 paragraphs,
953- [ StyledTextParagraph {
953+ [ ParagraphBlock :: Text ( RichText {
954954 text: "hello world" . into( ) ,
955955 formatting: alloc:: vec![
956956 FormattedSpan { range: 0 ..11 , style: Style :: Color ( 0 ) } ,
957957 FormattedSpan { range: 0 ..11 , style: Style :: Underline } ,
958958 ] ,
959959 links: alloc:: vec:: Vec :: new( )
960- } ]
960+ } ) ]
961961 ) ;
962962 assert_eq ! ( errors. len( ) , 1 ) ;
963963 assert_eq ! ( errors[ 0 ] . to_string( ) , r"Invalid color value '\#a'" ) ;
@@ -973,33 +973,33 @@ fn markdown_parsing_interpolated() {
973973 & format!( "Text: *{MARKDOWN_INTERPOLATION_PLACEHOLDER}*" ) ,
974974 & [ & [ paragraph_from_plain_text( "italic" . into( ) ) ] ]
975975 ) ) ,
976- [ StyledTextParagraph {
976+ [ ParagraphBlock :: Text ( RichText {
977977 text: "Text: italic" . into( ) ,
978978 formatting: alloc:: vec![ FormattedSpan { range: 6 ..12 , style: Style :: Emphasis } ] ,
979979 links: alloc:: vec![ ]
980- } ]
980+ } ) ]
981981 ) ;
982982 assert_eq ! (
983983 assert_no_errors( parse_interpolated(
984984 & format!( "Escaped text: {MARKDOWN_INTERPOLATION_PLACEHOLDER}" ) ,
985985 & [ & [ paragraph_from_plain_text( "*bold*" . into( ) ) ] ]
986986 ) ) ,
987- [ StyledTextParagraph {
987+ [ ParagraphBlock :: Text ( RichText {
988988 text: "Escaped text: *bold*" . into( ) ,
989989 formatting: alloc:: vec![ ] ,
990990 links: alloc:: vec![ ]
991- } ]
991+ } ) ]
992992 ) ;
993993 assert_eq ! (
994994 assert_no_errors( parse_interpolated(
995995 & format!( "Code block text: `{MARKDOWN_INTERPOLATION_PLACEHOLDER}`" ) ,
996996 & [ & [ paragraph_from_plain_text( "*bold*" . into( ) ) ] ]
997997 ) ) ,
998- [ StyledTextParagraph {
998+ [ ParagraphBlock :: Text ( RichText {
999999 text: "Code block text: *bold*" . into( ) ,
10001000 formatting: alloc:: vec![ FormattedSpan { range: 17 ..23 , style: Style :: Code } ] ,
10011001 links: alloc:: vec![ ]
1002- } ]
1002+ } ) ]
10031003 ) ;
10041004 assert_eq ! (
10051005 assert_no_errors( parse_interpolated(
@@ -1011,60 +1011,64 @@ fn markdown_parsing_interpolated() {
10111011 parse_interpolated:: <& [ _] >( "*World*" , & [ ] ) . 0
10121012 ]
10131013 ) ) ,
1014- [ StyledTextParagraph {
1014+ [ ParagraphBlock :: Text ( RichText {
10151015 text: "Hello World" . into( ) ,
10161016 formatting: alloc:: vec![
10171017 FormattedSpan { range: 0 ..5 , style: Style :: Strong } ,
10181018 FormattedSpan { range: 6 ..11 , style: Style :: Emphasis }
10191019 ] ,
10201020 links: alloc:: vec![ ]
1021- } ]
1021+ } ) ]
10221022 ) ;
10231023 assert_eq ! (
10241024 assert_no_errors( parse_interpolated(
10251025 & format!( "<u>{MARKDOWN_INTERPOLATION_PLACEHOLDER}</u>" ) ,
10261026 & [ parse_interpolated:: <& [ _] >( "*underline_and_italic*" , & [ ] ) . 0 ]
10271027 ) ) ,
1028- [ StyledTextParagraph {
1028+ [ ParagraphBlock :: Text ( RichText {
10291029 text: "underline_and_italic" . into( ) ,
10301030 formatting: alloc:: vec![
10311031 FormattedSpan { range: 0 ..20 , style: Style :: Emphasis } ,
10321032 FormattedSpan { range: 0 ..20 , style: Style :: Underline } ,
10331033 ] ,
10341034 links: alloc:: vec![ ]
1035- } ]
1035+ } ) ]
10361036 ) ;
10371037 // Empty paragraph list might be caused by a StyledText::default()
10381038 assert_eq ! (
10391039 assert_no_errors( parse_interpolated(
10401040 & format!( "{MARKDOWN_INTERPOLATION_PLACEHOLDER}" ) ,
10411041 & [ [ ] ]
10421042 ) ) ,
1043- [ StyledTextParagraph { text: "" . into( ) , formatting: alloc:: vec![ ] , links: alloc:: vec![ ] } ]
1043+ [ ParagraphBlock :: Text ( RichText {
1044+ text: "" . into( ) ,
1045+ formatting: alloc:: vec![ ] ,
1046+ links: alloc:: vec![ ]
1047+ } ) ]
10441048 ) ;
10451049 // Interpolation in link URL
10461050 assert_eq ! (
10471051 assert_no_errors( parse_interpolated(
10481052 & format!( "[Click here]({MARKDOWN_INTERPOLATION_PLACEHOLDER})" ) ,
10491053 & [ & [ paragraph_from_plain_text( "https://example.com" . into( ) ) ] ]
10501054 ) ) ,
1051- [ StyledTextParagraph {
1055+ [ ParagraphBlock :: Text ( RichText {
10521056 text: "Click here" . into( ) ,
10531057 formatting: alloc:: vec![ FormattedSpan { range: 0 ..10 , style: Style :: Link } ] ,
10541058 links: alloc:: vec![ ( 0 ..10 , "https://example.com" . into( ) ) ]
1055- } ]
1059+ } ) ]
10561060 ) ;
10571061 // Interpolation in link URL with surrounding text
10581062 assert_eq ! (
10591063 assert_no_errors( parse_interpolated(
10601064 & format!( "[link](https://{MARKDOWN_INTERPOLATION_PLACEHOLDER}/path) after" ) ,
10611065 & [ & [ paragraph_from_plain_text( "example.com" . into( ) ) ] ]
10621066 ) ) ,
1063- [ StyledTextParagraph {
1067+ [ ParagraphBlock :: Text ( RichText {
10641068 text: "link after" . into( ) ,
10651069 formatting: alloc:: vec![ FormattedSpan { range: 0 ..4 , style: Style :: Link } ] ,
10661070 links: alloc:: vec![ ( 0 ..4 , "https://example.com/path" . into( ) ) ]
1067- } ]
1071+ } ) ]
10681072 ) ;
10691073}
10701074
0 commit comments