seebk / LaTeXText

Inkscape extension to render text as Latex
GNU General Public License v3.0
141 stars 19 forks source link

Only render text that belongs to a layer #10

Open cossio opened 6 years ago

cossio commented 6 years ago

Instead of rendering all the text in the document, I think it would be more useful if this extension rendered all the text found in a specified layer.

seebk commented 6 years ago

That would indeed be a nice feature. Probably I won't have time to implement it soon, but if anyone is willing to work on this I would be glad to check and merge a patch.

cossio commented 6 years ago

I have no idea how to do it.

csorvagep commented 6 years ago

I'm really not used to python, but my guess is, the responsible line is at latextex.py:449 text_nodes = self.docroot.findall('.//{%s}text' % SVG_NS)

oliver-pola commented 5 years ago

Of course there are text elements that produce errors when processed by latex. You really need to specify a choice. I've just limited to search in a layer with the fixed name 'Latex'. Probably someone needs it to be in the options dialog?

I changed the line @csorvagep has mentioned to this:

        latex_layer = self.docroot.find("{%s}g[@{%s}label='Latex']" % (SVG_NS, INKSCAPE_NS))
        if latex_layer is None:
            text_nodes = self.docroot.findall('.//{%s}text' % SVG_NS)
        else:
            text_nodes = latex_layer.findall('.//{%s}text' % SVG_NS)

As I just need the problem solved, I'm fine with the fixed layer name. I will not dig into options. When someone thinks it would still be worth a pull request, I may be convinced to create one.

oliver-pola commented 5 years ago

Oh why did @csorvagep not mention here that he already made a pull request #13 … Searching for the problem I just found the issue not the PR. Sorry.