File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
octoprint_mrbeam/static/js/helpers Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,34 @@ class WorkingAreaHelper {
211211 }
212212 }
213213
214+ // detect Microsoft Visio generated svg
215+ // <svg ... xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" ...>
216+ if (
217+ root_attrs [ "xmlns:v" ] &&
218+ root_attrs [ "xmlns:v" ] . value . search ( "microsoft.com/visio" ) > 0
219+ ) {
220+ let version = "unknown" ;
221+ const ns = root_attrs [ "xmlns:v" ] . value ;
222+ const regex = / m i c r o s o f t \. c o m \/ v i s i o \/ ( .+ ) \/ S V G E x t e n s i o n s / gm;
223+ let m ;
224+
225+ while ( ( m = regex . exec ( ns ) ) !== null ) {
226+ // This is necessary to avoid infinite loops with zero-width matches
227+ if ( m . index === regex . lastIndex ) {
228+ regex . lastIndex ++ ;
229+ }
230+
231+ // The result can be accessed through the `m`-variable.
232+ m . forEach ( ( match , groupIndex ) => {
233+ console . log (
234+ `Found match, group ${ groupIndex } : ${ match } `
235+ ) ;
236+ version = match ;
237+ } ) ;
238+ }
239+ return { generator : "Microsoft Visio" , version : version } ;
240+ }
241+
214242 // detect dxf.js generated svg
215243 // <!-- Created with dxf.js -->
216244 for ( var i = 0 ; i < children . length ; i ++ ) {
You can’t perform that action at this time.
0 commit comments