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
890 stars 84 forks source link

>= breaks parsing #565

Open NeilGirdhar opened 1 month ago

NeilGirdhar commented 1 month ago

Please provide the following when posting an issue:

original .tex code

\tikzset{
/Flow diagram/.style={
% Node placement
auto,
node distance=14mm and 14mm,
on grid,
% Edge style
thick,
->,
>=Stealthy[round],
% Node border styles
rectangle/.style={shape=rectangle, draw, rounded corners, minimum size=8mm},
state/.style={shape=circle, draw, inner sep=0pt, minimum size=6.8mm},
no_border/.style={shape=rectangle, inner sep=1pt},
% Node fill styles
unobserved/.style={},
intervention/.style={dcolorb, very thick, fill=dcolorb!30},
observation/.style={dcoloro, very thick, fill=dcoloro!30},
%
annotation_brace/.style={-,decoration={brace,amplitude=7pt},decorate,thick,color=ann_col},
%
roundline/.style={rounded corners=4mm}
},
}

yaml settings

onlyOneBackUp: 1
maxNumberOfBackUps: 1
logFilePreferences:
  showEveryYamlRead: 0

indentPreamble: 1
defaultIndent: "  "

actual/given output

(unchanged)

desired or expected output

\tikzset{
  /Flow diagram/.style={
    % Node placement
    auto,
    node distance=14mm and 14mm,
    on grid,
    % Edge style
    thick,
    ->,
    >=Stealthy[round],
    % Node border styles
    rectangle/.style={shape=rectangle, draw, rounded corners, minimum size=8mm},
    state/.style={shape=circle, draw, inner sep=0pt, minimum size=6.8mm},
    no_border/.style={shape=rectangle, inner sep=1pt},
    % Node fill styles
    unobserved/.style={},
    intervention/.style={dcolorb, very thick, fill=dcolorb!30},
    observation/.style={dcoloro, very thick, fill=dcoloro!30},
    %
    annotation_brace/.style={-,decoration={brace,amplitude=7pt},decorate,thick,color=ann_col},
    %
    roundline/.style={rounded corners=4mm}
  },
}

Does not get indented because >= breaks the parser.

NeilGirdhar commented 1 month ago

Similarly, this doesn't parse for some odd reason:

\tikzset{
/CMA tips/.style={
% blue: carries deduction and explanation signals.
% orange: carries selection-like signals.
% red: carries pooling-like signals.
% green: carries the GLN.
tip_explanation/.tip={Semicircle[dcolorb]},
tip_deduction/.tip={ProperCircle[dcolorb]},
tip_retro_deduction/.tip={ProperCircle[open, dcolorb]},
tip_screening/.tip={ReverseFlatInverted[dcolorb]},
tip_pooling/.tip={ProperSquare[dcoloro]},
tip_retro_pooling/.tip={ProperSquare[open, dcoloro]},
tip_control/.tip={Parenthesis[reversed, sep=1pt] tip_pooling},
tip_retro_control/.tip={Parenthesis[reversed, sep=1pt] tip_retro_pooling},
tip_reward/.tip={FlatInverted[dcoloro]},
tip_waking/.tip={Semicircle[dcoloro, reversed]},
tip_gln/.tip={Diamond[dcolorg]},
tip_variational/.tip={InvertedDiamond[dcolorr]},
% Cotangents:
tip_cotangent/.tip={Bar[sep=1pt]},
tip_co_explanation/.tip={tip_cotangent[dcolorb] tip_explanation},
},
}
cmhughes commented 1 month ago

Please use the issue template and I'll try to help

On Wed, 25 Sept 2024, 23:47 Neil Girdhar, @.***> wrote:

Similarly, this doesn't parse for some odd reason:

\tikzset{ /CMA tips/.style={% blue: carries deduction and explanation signals.% orange: carries selection-like signals.% red: carries pooling-like signals.% green: carries the GLN. tip_explanation/.tip={Semicircle[dcolorb]}, tip_deduction/.tip={ProperCircle[dcolorb]}, tip_retro_deduction/.tip={ProperCircle[open, dcolorb]}, tip_screening/.tip={ReverseFlatInverted[dcolorb]}, tip_pooling/.tip={ProperSquare[dcoloro]}, tip_retro_pooling/.tip={ProperSquare[open, dcoloro]}, tip_control/.tip={Parenthesis[reversed, sep=1pt] tip_pooling}, tip_retro_control/.tip={Parenthesis[reversed, sep=1pt] tip_retro_pooling}, tip_reward/.tip={FlatInverted[dcoloro]}, tip_waking/.tip={Semicircle[dcoloro, reversed]}, tip_gln/.tip={Diamond[dcolorg]}, tip_variational/.tip={InvertedDiamond[dcolorr]},% Cotangents: tip_cotangent/.tip={Bar[sep=1pt]}, tip_co_explanation/.tip={tip_cotangent[dcolorb] tip_explanation}, }, }

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/565#issuecomment-2375401424, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYHVWQILUTYXO7K2LDLZYM4P5AVCNFSM6AAAAABO3SXM2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZVGQYDCNBSGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

NeilGirdhar commented 1 month ago

Thank you. I've edited the issue.

cmhughes commented 1 month ago

Using the following

onlyOneBackUp: 1
maxNumberOfBackUps: 1
logFilePreferences:
  showEveryYamlRead: 0

indentPreamble: 1
defaultIndent: "  "

fineTuning:
  namedGroupingBracesBrackets:
    name: [0-9\.a-zA-Z@\*><=]+?            #<!---- NEW BIG

gives your desired output.

NeilGirdhar commented 1 month ago

Thanks! Will you be merging this change into master?