Re: [Rdkit-discuss] SVG BUG (Re: Fwd: 2D drawing with atoms labeled by index)
Indeed, when the file under discussion most recently named "svg2.html" is modified so that "xmlns:svg=" is replaced with "xmlns=", and the file is renamed "svg2.svg", double-clicking it opens it and correctly correctly displays the image in the browser. But trying this in the Jupyter notebook fails. the original code had the lines: svg = drawer.GetDrawingText().replace('svg:','') display(SVG(svg)) This succeeded. If i add Dimitri's latest sugesstion: svg = drawer.GetDrawingText().replace('svg:','').replace('xmlns:svg=','xmlns=') display(SVG(svg)) this also succeeds. If I only carry out the second replacement, this fails with an error several levels down. So apparently, SVG() can create an svg object out of the contents of a correctly formed svg file, but is insensitive to some constructs that make the such a file invalid for direct use in a browser. I'm still not sure why GetDrawingText() doesn't return a properly formatted svg string. Is there some use its output can be put to without these .replacements? -P On Tue, Oct 25, 2016 at 1:35 PM, Dimitri Maziukwrote: > On 10/25/2016 11:21 AM, Peter S. Shenkin wrote: > > Hi, Hongbin, > > > > Thanks. Indeed. svg2.svg, when renamed to svg2.html, shows the correct > > image in Chrome. svg.html shows garbage. > > > > Still, it would be good to be able to create a real .svg file from RDKit. > > OK, you made me look and I learned something today. > > Mozilla claims valid SVG must include the namespace declarations > (https://developer.mozilla.org/en-US/docs/Web/SVG/FAQ) citing this > document: https://jwatt.org/svg/authoring/#namespace-binding > > There it states > """ > http://www.w3.org/2000/svg; > ... > Be careful not to type xmlns:svg instead of just xmlns when you bind the > SVG namespace. This is an easy mistake to make, but one that can break > everything. Instead of making SVG the default namespace, it binds it to > the namespace prefix 'svg', and this is almost certainly not what you > want to do in an SVG file. A standards compliant browser will then fail > to recognise any tags and attributes that don't have an explicit > namespace prefix (probably most if not all of them) and fail to render > your document as SVG. > """ > > Sure enough, rdkit's files start with > """ >xmlns:svg='http://www.w3.org/2000/svg' > ... > """ > > With that declaration any standards-compliant viewer should only > recognize tags with "svg:" prefix, and removing svg:'s results in a > technically invalid file. Anything that displays it as an image is what > we "it professionals" call b0rk3d. > > According to this, what RDKit writes out is wrong: you actually *want > to* remove :svg from the root tag's "xmlns" attribute, then you *may* > remove the svg: prefixes from all tags (including the root one). > > Of course, that was last edited in 2007, maybe something changed in the > 10 years since. > > HTH, > -- > Dimitri Maziuk > Programmer/sysadmin > BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu > > > > -- > The Command Line: Reinvented for Modern Developers > Did the resurgence of CLI tooling catch you by surprise? > Reconnect with the command line and become more productive. > Learn the new .NET and ASP.NET CLI. Get your free copy! > http://sdm.link/telerik > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > > -- The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy! http://sdm.link/telerik___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] SVG BUG (Re: Fwd: 2D drawing with atoms labeled by index)
On 10/25/2016 11:21 AM, Peter S. Shenkin wrote: > Hi, Hongbin, > > Thanks. Indeed. svg2.svg, when renamed to svg2.html, shows the correct > image in Chrome. svg.html shows garbage. > > Still, it would be good to be able to create a real .svg file from RDKit. OK, you made me look and I learned something today. Mozilla claims valid SVG must include the namespace declarations (https://developer.mozilla.org/en-US/docs/Web/SVG/FAQ) citing this document: https://jwatt.org/svg/authoring/#namespace-binding There it states """ http://www.w3.org/2000/svg; ... Be careful not to type xmlns:svg instead of just xmlns when you bind the SVG namespace. This is an easy mistake to make, but one that can break everything. Instead of making SVG the default namespace, it binds it to the namespace prefix 'svg', and this is almost certainly not what you want to do in an SVG file. A standards compliant browser will then fail to recognise any tags and attributes that don't have an explicit namespace prefix (probably most if not all of them) and fail to render your document as SVG. """ Sure enough, rdkit's files start with """ http://www.bmrb.wisc.edu signature.asc Description: OpenPGP digital signature -- The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy! http://sdm.link/telerik___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] Fwd: 2D drawing with atoms labeled by index
Hi, Hongbin, Thanks. Indeed. svg2.svg, when renamed to svg2.html, shows the correct image in Chrome. svg.html shows garbage. Still, it would be good to be able to create a real .svg file from RDKit. Best, -P. On Tue, Oct 25, 2016 at 2:35 AM, 杨弘宾wrote: > Hi, Peter, > I don't know whether it can help you since I did not repeat your code. > But it acturally works in my computer: > change the extended name from .svg into .html and open it via > chrome. > It should be valid with svg2.svg (the namespace of svg were removed). > > -- > Hongbin Yang > > > *From:* Peter S. Shenkin > *Date:* 2016-10-25 13:27 > *To:* Dmitri Maziuk > *CC:* RDKit Discuss > *Subject:* Re: [Rdkit-discuss] Fwd: 2D drawing with atoms labeled by index > Hi, > > Dima wrote: >> >> Try saving the text (svg/svg2) to a file and opening it in chrome (if you >> can actually open a file in chrome) or some other application. > > > I actually did that, and in a second email I reported: > >> >>- Chrome thinks svg.svg is empty >> >> >>- When I load svg2.svg, Chrome complains, "This XML file does not >>appear to have any style information associated with it. The document tree >>is shown below" >> >> -P. > > On Tue, Oct 25, 2016 at 12:28 AM, Dmitri Maziuk > wrote: > >> OK, my turn: that went out too soon. >> >> It seems to me that jypiter, ipython, or whatever, has no idea how render >> MIME type image/svg+xml. It can display an "SVG" object, but the bit that >> turned image/svg+xml into "SVG" does not understand XML namespaces (that's >> been around since at least 2009). >> >> Try saving the text (svg/svg2) to a file and opening it in chrome (if you >> can actually open a file in chrome) or some other application. >> >> Dima >> >> > -- The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy! http://sdm.link/telerik___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] Fwd: 2D drawing with atoms labeled by index
Hi, Peter, I don't know whether it can help you since I did not repeat your code. But it acturally works in my computer: change the extended name from .svg into .html and open it via chrome. It should be valid with svg2.svg (the namespace of svg were removed). Hongbin Yang From: Peter S. ShenkinDate: 2016-10-25 13:27To: Dmitri MaziukCC: RDKit DiscussSubject: Re: [Rdkit-discuss] Fwd: 2D drawing with atoms labeled by indexHi, Dima wrote:Try saving the text (svg/svg2) to a file and opening it in chrome (if you can actually open a file in chrome) or some other application. I actually did that, and in a second email I reported:Chrome thinks svg.svg is emptyWhen I load svg2.svg, Chrome complains, "This XML file does not appear to have any style information associated with it. The document tree is shown below" -P. On Tue, Oct 25, 2016 at 12:28 AM, Dmitri Maziukwrote: OK, my turn: that went out too soon. It seems to me that jypiter, ipython, or whatever, has no idea how render MIME type image/svg+xml. It can display an "SVG" object, but the bit that turned image/svg+xml into "SVG" does not understand XML namespaces (that's been around since at least 2009). Try saving the text (svg/svg2) to a file and opening it in chrome (if you can actually open a file in chrome) or some other application. Dima -- The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy! http://sdm.link/telerik___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss