如何在svg文件(Inkscape)中保留换行符?
我用Incskape创建了一个svg文件。 它包含一个文本元素是这样的:如何在svg文件(Inkscape)中保留换行符?
<text
[..]><tspan
[..]
style="font-style:normal;fill:#c913ff;fill-opacity:1">My Text</tspan></text>
我想使用git来跟踪我的变化。 由于git使用整行来查找更改,我使用文本编辑器编辑svg文件以将样式属性与文本本身分开。
<text
[..]><tspan
[..]
style="font-style:normal;fill:#c913ff;fill-opacity:1">
My Text
</tspan></text>
这样我就可以改变风格和文本在不同的提交而不影响其他。
不幸的是,Inkscape用每次保存重写svg文件,文本回到与样式相同的行。 :(
有没有一种方法,以防止从Inkscape的这样做?
我知道有可能是一种变通方法,通过使用某种的风格变量和更改另一部分OIF文件中变量的值。 但我并不想这样做。
以下的解决方法为我工作。
当我将文件保存为normal SVG
,而不是Inkscape SVG
文件的格式,因为我希望它是。
<text
transform="scale(0.97808647,1.0224045)"
id="text3779"
y="396.1929"
x="159.78862"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:0%;font-family:Corbel;-inkscape-font-specification:'Corbel Bold';letter-spacing:0px;word-spacing:0px;fill:#ff9715;fill-opacity:1;stroke:none"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:124.21698761px;line-height:1.25;font-family:Corbel;-inkscape-font-specification:'Corbel Bold';fill:#ff9715;fill-opacity:1"
y="396.1929"
x="159.78862"
id="tspan3781">My Text</tspan></text>
然而,这仅仅是一个解决办法,因为Inkscape的SVG的可能会超过正常SVG一定的优势。
你可以为Git编写一个clean
过滤器,这样你的svg文件在升级之前就会缩进。你会把这样的事情在你的.gitattributes
文件(在你的仓库根目录中创建它,如果你没有的话):
*.svg filter=indent
然后调整自己的混帐配置通知Git过滤器做什么。假设你已经在这里安装indent
:
git config filter.indent.clean indent
git config filter.indent.smudge cat
这将通过举办之前所谓的“缩进”程序运行所有SVG的文件,因此他们似乎很好地格式化您的回购和日志会看起来更好。当检查出文件,他们是通过cat
不修改文件跑去。
听起来像一个非常好的工作。 我会看看它,当我得到了一些时间。 –
我翻译自德国。 所以'普通的SVG'可能是'plain SVG'的英文。 –