@@ -111,21 +111,28 @@ class GSYMarkdownWidget extends StatelessWidget {
111111 _getMarkDownData (String markdownData) {
112112 ///优化图片显示
113113 RegExp exp = new RegExp (r'!\[.*\]\((.+)\)' );
114+ RegExp expImg = new RegExp ("<img.*?(?:>|\/ >)" );
115+ RegExp expSrc = new RegExp ("src=[\'\" ]?([^\'\" ]*)[\'\" ]?" );
116+
114117 Iterable <Match > tags = exp.allMatches (markdownData);
115118 String mdDataCode = markdownData;
116119 if (tags != null && tags.length > 0 ) {
117120 for (Match m in tags) {
118121 String imageMatch = m.group (0 );
119122 if (imageMatch != null ) {
120123 String match = m.group (0 ).replaceAll ("\) " , "?raw=true)" );
124+ if (! match.contains (".svg" )) {
125+ ///增加点击
126+ String src = match.replaceAll (".replaceAll (")" , "" );
127+ String actionMatch = "[$match ]($src )" ;
128+ match = actionMatch;
129+ }
121130 mdDataCode = mdDataCode.replaceAll (m.group (0 ), match);
122131 }
123132 }
124133 }
125134
126135 ///优化img标签的src资源
127- RegExp expImg = new RegExp ("<img.*?(?:>|\/ >)" );
128- RegExp expSrc = new RegExp ("src=[\'\" ]?([^\'\" ]*)[\'\" ]?" );
129136 tags = expImg.allMatches (markdownData);
130137 if (tags != null && tags.length > 0 ) {
131138 for (Match m in tags) {
@@ -137,15 +144,16 @@ class GSYMarkdownWidget extends StatelessWidget {
137144 String srcString = srcMatch.group (0 );
138145 if (srcString != null && srcString.contains ("http" )) {
139146 String newSrc = srcString.substring (srcString.indexOf ("http" ), srcString.length - 1 ) + "?raw=true" ;
140- match = "" ;
147+
148+ ///增加点击
149+ match = "[]($newSrc )" ;
141150 }
142151 }
143152 }
144153 mdDataCode = mdDataCode.replaceAll (imageTag, match);
145154 }
146155 }
147156
148-
149157 return mdDataCode;
150158 }
151159
0 commit comments