Proof: By Euclid
(related to Proposition: Prop. 10.023: Segment Commensurable with Medial Segment is Medial)
 Let the rational (straight line) $CD$ be set out, and let the rectangular area $CE$, equal to the (square) on $A$, have been applied to $CD$, producing $ED$ as width.
 $ED$ is thus rational, and incommensurable in length with $CD$ [Prop. 10.22].
 And let the rectangular area $CF$, equal to the (square) on $B$, have been applied to $CD$, producing $DF$ as width.
 Therefore, since $A$ is commensurable with $B$, the (square) on $A$ is also commensurable with the (square) on on $B$.
 But, $EC$ is equal to the (square) on $A$, and $CF$ is equal to the (square) on $B$.
 Thus, $EC$ is commensurable with $CF$.
 And as $EC$ is to $CF$, so $ED$ (is) to $DF$ [Prop. 6.1].
 Thus, $ED$ is commensurable in length with $DF$ [Prop. 10.11].
 And $ED$ is rational, and incommensurable in length with $CD$.
 $DF$ is thus also rational [Def. 10.3] , and incommensurable in length with $DC$ [Prop. 10.13].
 Thus, $CD$ and $DF$ are rational, and commensurable in square only.
 And the square root of a (rectangle contained) by rational (straight lines which are) commensurable in square only is medial [Prop. 10.21].
 Thus, the square root of the (rectangle contained) by $CD$ and $DF$ is medial.
 And the square on $B$ is equal to the (rectangle contained) by $CD$ and $DF$.
 Thus, $B$ is a medial (straight line).
∎
Thank you to the contributors under CC BYSA 4.0!
 Github:

 nonGithub:
 @Fitzpatrick
References
Adapted from (subject to copyright, with kind permission)
 Fitzpatrick, Richard: Euclid's "Elements of Geometry"