Bangladesh started the day positively as they only lost one wicket in the first session when Tamin Igbal departed for 39 to become the first victim of Andile Phehlukwayo in test cricket.
South Africa strengthened their hold on the first Test with Bangladesh by securing a substantial first-innings lead on day three in Potchefstroom. Neither batsman was able to go on to the century that Bangladesh needed. Shafiul soon edged Keshav Maharaj to give the left-arm spinner his third wicket and close Bangladesh's innings on 320.
But South Africa made sure neither of those two batsmen went on to a big score.
Maharaj was given reason to cheer after lunch when Markram showed superb reflexes at forward short-leg to end Mominul's 150-ball innings.
Rahman played a lifting ball from Duanne Olivier onto his stumps and Mahmudullah fell to the first delivery with the second new ball when an attempted cut against Morkel crashed into his stumps off an inside edge.
Once Mahmudullah was gone, Bangladesh collapsed as they went from 304/7 to being bowled out for 320, which gave South Africa a 176-run lead.
Three overs later Markram had an opportunity to take a review himself when he was given out caught behind off Mustafizur Rahman. From Bangladesh's perspective it would be optimism of a foolhardy bent to mention the obscure stat that it was the first time that Bangladesh strung together four consecutive half-century partnerships, but the reality is that none of those passed 69 and that Bangladesh are now 230 runs behind with eight wickets to get or a declaration.
South Africa eventually declared on 496 for three, then reducing Bangladesh to 127 for three - still 369 adrift and 170 shy of avoiding the follow-on.
Dean Elgar and Aiden Markram, who scored 296 runs between them in the first innings, were out early in the second but the home side were still firmly in command with Hashim Amla (17) and Temba Bamuva on three at the crease at stumps.