mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-05 03:42:33 +01:00
mzte-nv: tsn-actions: don't try typst math toggle with multiple lines
This commit is contained in:
parent
65ff33b213
commit
7ab1832bd8
1 changed files with 22 additions and 21 deletions
|
@ -66,20 +66,19 @@ class PTSNActions implements IPlugin {
|
||||||
});
|
});
|
||||||
}].toTable(),
|
}].toTable(),
|
||||||
java: {
|
java: {
|
||||||
hex_integer_literal: Table.create(
|
hex_integer_literal: Table.create([
|
||||||
[
|
Table.create(
|
||||||
Table.create(
|
[(node) -> MZTENv.tsn_actions.intToDec(this.tsna_helpers[untyped "node_text"](node))],
|
||||||
[(node) -> MZTENv.tsn_actions.intToDec(this.tsna_helpers[untyped "node_text"](node))],
|
{
|
||||||
{
|
name: "Convert to Decimal",
|
||||||
name: "Convert to Decimal",
|
}
|
||||||
}
|
)
|
||||||
)
|
]),
|
||||||
]
|
decimal_integer_literal: Table.create([
|
||||||
),
|
Table.create([(node) -> MZTENv.tsn_actions.intToHex(this.tsna_helpers[untyped "node_text"](node))], {
|
||||||
decimal_integer_literal: Table.create([Table.create([(node) ->
|
name: "Convert to Hexadecimal",
|
||||||
MZTENv.tsn_actions.intToHex(this.tsna_helpers[untyped "node_text"](node))], {
|
})
|
||||||
name: "Convert to Hexadecimal",
|
]),
|
||||||
})]),
|
|
||||||
},
|
},
|
||||||
c: {
|
c: {
|
||||||
number_literal: toggle_int_action,
|
number_literal: toggle_int_action,
|
||||||
|
@ -109,14 +108,16 @@ class PTSNActions implements IPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function toggleTypstMath(node:Dynamic):String {
|
private function toggleTypstMath(node:Dynamic):String {
|
||||||
final text:String = this.tsna_helpers[untyped "node_text"](node);
|
final nodetext = this.tsna_helpers[untyped "node_text"](node);
|
||||||
|
final text = Std.isOfType(nodetext, AnyTable) ? return nodetext : (cast nodetext : String);
|
||||||
|
|
||||||
final sub1 = text.gsub("^%$%s+(.*)%s+%$$", "%$%1%$");
|
var sub = text.gsub("^%$%s+(.*)%s+%$$", "%$%1%$");
|
||||||
if (sub1 == text) {
|
if (sub == text) {
|
||||||
// This assignment is necessary because haxe doesn't realize that gsub is a multireturn.
|
// haxe doesn't realize that gsub is a multireturn.
|
||||||
// TODO: open issue about this
|
// TODO: open issue about this
|
||||||
final sub2 = text.gsub("^%$", "%$ ").gsub("%$$", " %$");
|
sub = text.gsub("^%$", "%$ ").gsub("%$$", " %$");
|
||||||
return sub2;
|
}
|
||||||
} else return sub1;
|
|
||||||
|
return sub;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue