altium-to-circuit-json 0.0.63 → 0.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2730,6 +2730,39 @@ function selectCircuitJsonSymbol({
2730
2730
  )[0];
2731
2731
  }
2732
2732
 
2733
+ // lib/schematic/components/parseAltiumPinLabel.ts
2734
+ function parseAltiumPinLabel(name) {
2735
+ if (!name.includes("\\")) return { displayText: name };
2736
+ if (name.startsWith("\\")) {
2737
+ const displayText = name.replaceAll("\\", "");
2738
+ return {
2739
+ displayText,
2740
+ textParts: [{ is_overlined: true, text: displayText }]
2741
+ };
2742
+ }
2743
+ const textParts = [];
2744
+ const characters = [...name];
2745
+ for (let index = 0; index < characters.length; index += 1) {
2746
+ const character = characters[index] ?? "";
2747
+ if (character === "\\") continue;
2748
+ const isOverlined = characters[index + 1] === "\\";
2749
+ if (isOverlined) index += 1;
2750
+ const previousTextPart = textParts.at(-1);
2751
+ if (previousTextPart && Boolean(previousTextPart.is_overlined) === isOverlined) {
2752
+ previousTextPart.text += character;
2753
+ } else {
2754
+ textParts.push({
2755
+ ...isOverlined ? { is_overlined: true } : {},
2756
+ text: character
2757
+ });
2758
+ }
2759
+ }
2760
+ return {
2761
+ displayText: textParts.map((textPart) => textPart.text).join(""),
2762
+ textParts
2763
+ };
2764
+ }
2765
+
2733
2766
  // lib/schematic/components/parsePinNumber.ts
2734
2767
  function parsePinNumber(pinDesignator) {
2735
2768
  const parsed = Number(pinDesignator);
@@ -2760,6 +2793,7 @@ function convertComponentPin({
2760
2793
  const designator = pin.designator ?? `${pinIndex + 1}`;
2761
2794
  const pinNumber = parsePinNumber(designator);
2762
2795
  const name = pin.name ?? designator;
2796
+ const parsedPinLabel = parseAltiumPinLabel(name);
2763
2797
  const sourcePortId = `source_port_altium_${recordIndex}`;
2764
2798
  const schematicPortId = `schematic_port_altium_${recordIndex}`;
2765
2799
  const sourcePort = {
@@ -2781,7 +2815,10 @@ function convertComponentPin({
2781
2815
  const schematicPort = {
2782
2816
  type: "schematic_port",
2783
2817
  center: scalePoint(terminalPoint, options.scale),
2784
- ...showName && name ? { display_pin_label: name } : {},
2818
+ ...showName && name ? {
2819
+ display_pin_label: parsedPinLabel.displayText,
2820
+ ...parsedPinLabel.textParts ? { display_pin_label_text_parts: parsedPinLabel.textParts } : {}
2821
+ } : {},
2785
2822
  distance_from_component_edge: scaleLength(pinLength, options.scale),
2786
2823
  facing_direction: direction,
2787
2824
  is_connected: false,