SVG的代码格式在IntelliJ IDEA中不起作用

我有以下由inkscape生成的SVG文件。正如你所看到的,XML的格式非常混乱。首先,在我的设置中,我选择了“使用选项卡字符”,但该文件不包含制表符。许多其他事情也是错误的,例如/><g><path。SVG的代码格式在IntelliJ IDEA中不起作用

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 

<svg

xmlns:dc="http://purl.org/dc/elements/1.1/"

xmlns:cc="http://creativecommons.org/ns#"

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns="http://www.w3.org/2000/svg"

xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"

xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"

version="1.1"

x="0px"

y="0px"

width="105.83467"

height="105.83467"

viewBox="0 0 99.220001 99.220001"

enable-background="new 0 0 100 100"

xml:space="preserve"

id="svg2"

inkscape:version="0.92.1 r15371"

sodipodi:docname="activity_template.svg"><metadata

id="metadata13"><rdf:RDF><cc:Work

rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type

rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs

id="defs11" /><sodipodi:namedview

pagecolor="#ffffff"

bordercolor="#666666"

borderopacity="1"

objecttolerance="10"

gridtolerance="10"

guidetolerance="10"

inkscape:pageopacity="0"

inkscape:pageshadow="2"

inkscape:window-width="1676"

inkscape:window-height="1117"

id="namedview9"

showgrid="false"

inkscape:zoom="5.7699913"

inkscape:cx="2.3719576"

inkscape:cy="60.109287"

inkscape:window-x="0"

inkscape:window-y="298"

inkscape:window-maximized="0"

inkscape:current-layer="svg2"

fit-margin-top="0"

fit-margin-left="0"

fit-margin-right="0"

fit-margin-bottom="0" /><g

id="Background"

transform="translate(-0.4542549,-0.33174549)" /><g

id="Pictograms"

transform="translate(-0.4542549,-0.33174549)"><path

d="M 99.167833,18.811353 81.549745,0.77689213 c -0.19,-0.19 -0.501274,-0.36095895 -0.771274,-0.36127448 L 2.1282745,0.32370588 C 1.5682749,0.32305146 0.392628,1.5090001 0.39298039,2.059 l 0.0612745,95.634902 c 3.5239e-4,0.55 1.05274521,1.857486 1.61274511,1.857843 l 96.053823,0.06128 c 0.55,3.5e-4 1.613083,-1.001471 1.612746,-1.857843 l -0.03064,-77.84554 c -1.02e-4,-0.259999 -0.345098,-0.918284 -0.535096,-1.098289 z m -4.04848,-0.222549 -13.773431,-0.06127 0.06127,-13.7347055 z M 96.937,96.939 H 3.067 V 3.059 h 75.85 v 17.02 c 0,0.55 0.45,1 1,1 h 17.02 z"

id="path6"

inkscape:connector-curvature="0"

sodipodi:nodetypes="ccsssssssscccccccccsscc" /></g><g

id="Guides"

transform="translate(-0.4542549,-0.33174549)" /><path

id="path3021"

d="m 88.804011,52.081722 c -4.779066,-1.280811 -5.862105,-12.487045 -1.941764,-14.749867 1.285092,-0.744856 2.281658,-1.801354 2.940042,-3.019664 -1.019682,-3.718289 -4.499102,-9.07526 -6.46227,-11.457944 -1.434918,-0.06678 -2.90237,0.261128 -4.237975,1.032525 -4.276503,2.470868 -13.117176,-4.137805 -11.800407,-9.056426 0.411811,-1.536801 0.194348,-3.400653 -0.141266,-4.489685 -2.430628,-1.2568381 -8.186569,-2.9477474 -12.461359,-3.366408 -0.921224,0.6703706 -1.976009,2.2910752 -2.386965,3.83815 -1.394679,5.201152 -12.431394,5.957139 -14.798666,1.85786 -0.790233,-1.36985 -2.245699,-2.645524 -3.251684,-3.0650415 -2.765385,0.8381785 -8.774749,4.3218805 -11.205378,6.3329915 0.167807,1.424646 0.200341,3.079596 1.017115,4.492254 2.36556,4.100135 -4.04106,13.217346 -9.10009,11.862051 -1.664368,-0.445202 -3.410928,-0.318491 -4.835572,0.267977 -1.1737914,2.599291 -2.9503161,9.454537 -3.1181228,12.219923 0.3356134,0.754274 2.3364504,2.078748 3.9366088,2.506826 6.886067,1.845874 6.940006,11.944241 1.95118,14.824352 -1.409233,0.814205 -2.616414,1.944332 -3.1189784,3.369833 0.8381784,2.681482 4.2062984,8.576976 6.3852174,11.091508 1.424644,0.166951 3.079595,-0.198628 4.49311,-1.016258 4.455438,-2.574462 13.366317,3.479421 11.860337,9.101802 -0.391264,1.463171 -0.174656,3.002541 0.0762,4.511946 3.352709,1.424644 9.417722,3.42891 12.770432,3.345007 1.089031,-1.005988 1.761115,-2.407516 2.143816,-3.838154 1.318481,-4.921188 12.202801,-6.49138 14.774695,-2.035941 0.718316,1.245708 1.724299,2.428061 2.897234,3.098431 3.51966,-1.005984 9.707103,-4.468281 11.804687,-6.6472 0.08219,-1.591595 -0.517119,-2.921206 -1.261975,-4.214002 -2.77994,-4.810744 3.714008,-13.23447 9.053857,-11.802976 1.462316,0.390408 3.054767,0.258559 4.396364,-0.0762 1.172934,-2.93405 3.118121,-8.175441 3.452022,-12.533277 -1.172933,-1.340742 -2.285937,-1.970016 -3.830443,-2.384396 z m -16.2704,3.250826 C 69.274222,67.504527 56.765774,74.725351 44.595508,71.465108 32.426953,68.203151 25.206129,55.692134 28.466373,43.521011 31.726618,31.349889 44.235066,24.128208 56.40362,27.389309 c 12.169409,3.2611 19.391091,15.770404 16.129991,27.943239 z"

inkscape:connector-curvature="0"

style="clip-rule:evenodd;fill-rule:evenodd" /></svg>

所以,我想重新格式化我.svg文件,但是当我在的IntelliJ IDEA做 “重新格式化代码”(按Ctrl + Shift + L),没有任何反应。

我试着去“文件类型”并重新分配.svg文件到XML文件类型,没有区别。

我试过将.svg文件重命名为.xml,没有什么区别。

如果我做“自动缩进线”(Ctrl + Alt + I),当前行实际上是用制表符正确缩进的,所以如果我为每行执行此操作,我至少可以正确缩进整个文件,但没有其他格式化问题是固定的。

我该如何让IntelliJ IDEA重新格式化我的.svg文件?

回答:

事实证明,在这个特定的.svg文件中,<svg>标签包含一个鬼鬼祟祟的xml:space="preserve"属性。并且事实证明IntelliJ IDEA关注这个属性,所以“重新格式化代码”命令什么也不做。

删除此属性可以正确重新格式化.svg文件。

(所以,在光,事实的IntelliJ IDEA的“缩进线”命令不注重xml:space="preserve"属性实际上可能是一个错误。)

显然有些.svg文件包含这个属性,一些不要,其存在或缺席似乎不会以任何其他方式影响.svg文件。附答案为后人

有用的意见:

ccprog说:Inkscape中增加了这个属性的所有文本元素。这是一种行为,我没有找到任何可能改变。尽管如此,这是我第一次看到它的根源。您可能需要查看Inkscape的配置文件夹(查看设置 - >系统以查找用户/全局配置的位置)。有一些文件templates/default..svg用于在启动时初始化空文件。也许这个属性已经潜入其中。你需要编辑它们/手动设置一个本地的。

Robert Longson说:w3.org/TR/SVG/struct.html#XMLSpaceAttribute

以上是 SVG的代码格式在IntelliJ IDEA中不起作用 的全部内容, 来源链接: utcz.com/qa/258216.html

回到顶部