mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-05 04:22:34 +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(),
|
||||
java: {
|
||||
hex_integer_literal: Table.create(
|
||||
[
|
||||
Table.create(
|
||||
[(node) -> MZTENv.tsn_actions.intToDec(this.tsna_helpers[untyped "node_text"](node))],
|
||||
{
|
||||
name: "Convert to Decimal",
|
||||
}
|
||||
)
|
||||
]
|
||||
),
|
||||
decimal_integer_literal: Table.create([Table.create([(node) ->
|
||||
MZTENv.tsn_actions.intToHex(this.tsna_helpers[untyped "node_text"](node))], {
|
||||
name: "Convert to Hexadecimal",
|
||||
})]),
|
||||
hex_integer_literal: Table.create([
|
||||
Table.create(
|
||||
[(node) -> MZTENv.tsn_actions.intToDec(this.tsna_helpers[untyped "node_text"](node))],
|
||||
{
|
||||
name: "Convert to Decimal",
|
||||
}
|
||||
)
|
||||
]),
|
||||
decimal_integer_literal: Table.create([
|
||||
Table.create([(node) -> MZTENv.tsn_actions.intToHex(this.tsna_helpers[untyped "node_text"](node))], {
|
||||
name: "Convert to Hexadecimal",
|
||||
})
|
||||
]),
|
||||
},
|
||||
c: {
|
||||
number_literal: toggle_int_action,
|
||||
|
@ -109,14 +108,16 @@ class PTSNActions implements IPlugin {
|
|||
}
|
||||
|
||||
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%$");
|
||||
if (sub1 == text) {
|
||||
// This assignment is necessary because haxe doesn't realize that gsub is a multireturn.
|
||||
var sub = text.gsub("^%$%s+(.*)%s+%$$", "%$%1%$");
|
||||
if (sub == text) {
|
||||
// haxe doesn't realize that gsub is a multireturn.
|
||||
// TODO: open issue about this
|
||||
final sub2 = text.gsub("^%$", "%$ ").gsub("%$$", " %$");
|
||||
return sub2;
|
||||
} else return sub1;
|
||||
sub = text.gsub("^%$", "%$ ").gsub("%$$", " %$");
|
||||
}
|
||||
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue