Prepare desired amount of pasta according to package instructions, or fill a large saucepan about half full of water and add salt. Cover and bring to a boil over high heat. Add pasta and lower heat to keep at a gentle boil about 7 to 9 minutes, or until al dente.
Remove 1/2 cup of the pasta cooking liquids and set aside for use later. Drain pasta then return to saucepan and cover to keep warm.
While pasta cooks, chop onion. Heat oil in a large skillet over medium-low heat, then add onion. Cook and stir occasionally while you continue.
Remove stalk ends of Swiss chard and any thick center spines. Chop chard and rinse. Add to skillet and continuing cooking.
Chop garlic and add to chard, along with diced tomatoes (do not drain) and tomato paste. Cook and stir until chard is tender, about 5 to 10 minutes.
Drain and rinse beans. Stir into vegetables, along with reserved pasta cooking liquids, dill, rosemary, salt, pepper, and red pepper flakes. Cook another 2 minutes, then remove from heat.
Add vegetable mixture to pasta and stir gently. Stir in Parmesan cheese.
Garnish each serving with extra cheese if desired.