The rule is effectively the same in all three codes. It is phrased most clearly in NFHS rules:
9-6-6
c. If a pitcher is removed for a pinch-hitter or a pinch-runner, the runs scored by his team during the inning of his removal are to be credited to his benefit to decide the pitcher of record.