cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
864 stars 84 forks source link

Indenting of tikz arrow specification #544

Closed jdujava closed 3 months ago

jdujava commented 3 months ago

Minimal Working Example

\tikzset{
    header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}

actual/given output

\tikzset{
header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}

desired or expected output

Same as initial one.

anything else

Problem seems to be in the syntax -{....}, which always results in omitting the indentation. On the other hand {...}- seems to be fine (leaving only the line with {...}- results in a correct indentation).

cmhughes commented 3 months ago

Thanks for this. Can you try

fineTuning:
  namedGroupingBracesBrackets:
    name: [0-9\.a-zA-Z@\*><-]+?
jdujava commented 3 months ago

With the proposed fineTuning

\tikzset{
    % header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
\tikzset{
    header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    % header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
\tikzset{
    header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    % leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}

ends up as

\tikzset{
    % header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
\tikzset{
header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
% header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
\tikzset{
header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
% leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}

Without fineTuning, all would be not indented.

cmhughes commented 3 months ago

Using

fineTuning:
  namedGroupingBracesBrackets:
    name: [0-9\.a-zA-Z@\*><-]+?
    follow: \h|\R|\{|\[|\$|\)|\(|,

gives

\tikzset{
    % header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
\tikzset{
    header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    % header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
\tikzset{
    header decor right/.style={gray,line width=1.0,-{Diamond[open]}},
    header decor left/.style={gray,line width=1.0,{Diamond[open]}-},
    % leadsto/.style={-{Stealth[length=0.7em,open,round]}},
}
jdujava commented 3 months ago

Nice, works for me! Thanks for looking into it.