dotER :: ER -> G.DotGraph L.Text
dotER er = graph' $ do
  graphAttrs (graphTitle $ title er)
  graphAttrs [A.RankDir A.FromLeft]
  nodeAttrs [shape PlainText] -- recommended for HTML labels
  edgeAttrs [ A.Color [A.toWC $ A.toColor C.Gray50] -- easier to read labels
            , A.MinLen 2 -- give some breathing room
            , A.Style [A.SItem A.Dashed []] -- easier to read labels, maybe?
            ]
  forM_ (entities er) $ \e ->
    node (name e) [toLabel (htmlEntity e)]
  forM_ (rels er) $ \r -> do
    let opts = roptions r
    let rlab = A.HtmlLabel . H.Text . htmlFont opts . L.pack . show
    let (l1, l2) = (A.TailLabel $ rlab $ card1 r, A.HeadLabel $ rlab $ card2 r)
    let label = A.Label $ A.HtmlLabel $ H.Text $ withLabelFmt " %s " opts []
    edge (entity1 r) (entity2 r) [label, l1, l2]

-- | Converts a single entity to an HTML label.
dotER :: ER -> G.DotGraph L.Text
dotER er = graph' $ do
  graphAttrs (graphTitle $ title er)
  graphAttrs [A.RankDir A.FromLeft]
  nodeAttrs [shape PlainText] -- recommended for HTML labels
  edgeAttrs [ A.Color [A.toWC $ A.toColor C.Gray50] -- easier to read labels
            , A.MinLen 2 -- give some breathing room
            , A.Style [A.SItem A.Dashed []] -- easier to read labels, maybe?
            ]
  forM_ (entities er) $ \e ->
    node (name e) [toLabel (htmlEntity e)]
  forM_ (rels er) $ \r -> do
    let opts = roptions r
    let rlab = A.HtmlLabel . H.Text . htmlFont opts . L.pack . show
    let (l1, l2) = (A.TailLabel $ rlab $ card1 r, A.HeadLabel $ rlab $ card2 r)
    let label = A.Label $ A.HtmlLabel $ H.Text $ withLabelFmt " %s " opts []
    edge (entity1 r) (entity2 r) [label, l1, l2]

-- | Converts a single entity to an HTML label.
dotER er = graph' $ do
  graphAttrs (graphTitle $ title er)
  graphAttrs [A.RankDir A.FromLeft]
  nodeAttrs [shape PlainText] -- recommended for HTML labels
  edgeAttrs [ A.Color [A.toWC $ A.toColor C.Gray50] -- easier to read labels
            , A.MinLen 2 -- give some breathing room
            , A.Style [A.SItem A.Dashed []] -- easier to read labels, maybe?
            ]
  forM_ (entities er) $ \e ->
    node (name e) [toLabel (htmlEntity e)]
  forM_ (rels er) $ \r -> do
    let opts = roptions r
    let rlab = A.HtmlLabel . H.Text . htmlFont opts . L.pack . show
    let (l1, l2) = (A.TailLabel $ rlab $ card1 r, A.HeadLabel $ rlab $ card2 r)
    let label = A.Label $ A.HtmlLabel $ H.Text $ withLabelFmt " %s " opts []
    edge (entity1 r) (entity2 r) [label, l1, l2]

-- | Converts a single entity to an HTML label.