The trick to winning elections, old political warhorses say, is to rally the enthusiasm of the young, the idealistic, and the angry crazies, without getting stuck with a presidential candidate who cannot be stomached by the voters in the middle, the persuadables who decide elections.

The Democrats found such a candidate in 2008 in Barack Obama. The Republicans did the trick with Ronald Reagan in 1980.

But those successes are rare. More often, when a party’s presidential candidate is out of the mainstream, many of that party’s candidates in North Carolina and other states lose races they would otherwise have won.

The Republicans got clobbered in 1964 when the wild enthusiasm for Barry Goldwater’s super conservative platform won the nomination, but frightened away moderate voters in the general election.

The same thing happened to the Democrats in 1972 when youthful, idealistic, and anti-war activists won the nomination for George McGovern, whose views were too far left for many moderates to stomach.

Democrats won recent presidential elections when they ran moderate candidates like Jimmy Carter, Bill Clinton, and even Al Gore, who won the popular vote in 2000.

They lost with candidates like McGovern, and Michael Dukakis, whose campaigns attracted enthusiasm from progressives in the primaries, but whose views were too far left for many middle-of-the-road voters in the general election.

Old-time North Carolina Democrats still remember the price they paid down the ticket in the McGovern loss to Nixon in 1972. Republicans elected their first in the 20th Century governor, Jim Holshouser, and senator, Jesse Helms.

More recently, in 1988, Dukakis’s loss to George H.W. Bush took away whatever chance popular Lt. Gov. Bob Jordan had to beat incumbent Governor Jim Martin.

Republicans won with moderates like Nixon and the Bushes and lost with Goldwater.

Strong conservative Republicans point out that they lost with moderate candidates John McCain in 2008 and Mitt Romney in 2012. It is a fair point, but they lost to Obama, the rare exceptional candidate whose program of change drew enthusiasm from progressives without threatening middle-of-the-road voters. If McCain and Romney had been running against McGovern or Dukakis, each of them would probably have won the presidency.

What do these lessons mean for North Carolina politicians today? How can they capture the enthusiasm and voter turnout for an inspiring party primary candidate and still avoid the likely November loss if their candidate is too far out of the mainstream?

It will not be easy for either party.

For the Republicans, the challenge will be to convert and keep the supporters of candidates like Donald Trump and Ted Cruz without nominating either. That task will be difficult because of the disdain Trump and Cruz and their supporters have for moderate Republicans.

Democrats have a similar challenge: How to convert and keep the supporters of Bernie Sanders without nominating him, assuming that his self-identification as a socialist and his strong progressive views would lose many middle-of-the-road persuadable voters in November.

Republicans have the more complicated challenge because Trump is an unscripted, unattached phenomenon. So are many of his supporters.

Cruz presents another challenge because he is not a team player. But if Trump and Cruz, assuming neither will be the nominee, become willing and able to bring their supporters to get behind a more moderate nominee, Republicans might have the ingredients to win.

The Democrats’ challenge is less complicated, but perhaps more difficult. It is for Hillary Clinton to defeat Bernie Sanders without moving too far to the left, and remembering that she will need massive help from Sanders’s supporters in the fall.

Finally, individual voters in both parties will have to decide whether they will vote to make a statement or vote to select a nominee with the broad appeal necessary to win.