diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e1e031a2..7017f6ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Fixed a bug that was causing the focus info popup to appear blank - Fixed a bug on the generate page causing extraneous ellipses to appear when hovering over a course to highlight its prerequisites - Fixed a bug on the generate page where an extraneous info popup would appear when hovering over the top left corner of the graph viewing window +- Fixed a bug that led code to crash when parsing all pre-generated graphs from svg (i.e., program graphs) ### 🔧 Internal changes diff --git a/app/Svg/Parser.hs b/app/Svg/Parser.hs index c57a146de..e93b86395 100644 --- a/app/Svg/Parser.hs +++ b/app/Svg/Parser.hs @@ -182,26 +182,31 @@ parseTextHelper :: GraphId -- ^ The Text's corresponding graph identifier. -> [Text] parseTextHelper _ _ _ _ [] = [] parseTextHelper key styles' trans globalTrans (headTag:restTags) = - let [[a, c, e], [b, d, f], _] = completeTrans - in [Text key - (fromAttrib "id" headTag) -- TODO: Why are we setting an id? - (readAttr "x" headTag, readAttr "y" headTag) - (TS.escapeHTML $ trim $ TS.innerText (headTag:restTags)) - align - fill - [a, b, c, d, e, f] - ] + if not $ any (TS.isTagOpenName "tspan") restTags + then + let [[a, c, e], [b, d, f], _] = completeTrans + in [Text key + (fromAttrib "id" headTag) -- TODO: Why are we setting an id? + (readAttr "x" headTag, readAttr "y" headTag) + (TS.escapeHTML $ trim $ TS.innerText (headTag:restTags)) + align + fill + [a, b, c, d, e, f] + ] + else + let tspanTags = TS.partitions (TS.isTagOpenName "tspan") (headTag:restTags) + in + concatMap (parseTextHelper key newStyle newTrans globalTrans) tspanTags where - newStyle = styles headTag ++ styles' - currTrans = getTransform headTag - newTrans = matrixMultiply trans currTrans - completeTrans = matrixMultiply globalTrans newTrans - alignAttr = styleVal "text-anchor" newStyle - align = if T.null alignAttr - then "start" - else alignAttr - fill = styleVal "fill" newStyle - + newStyle = styles headTag ++ styles' + currTrans = getTransform headTag + newTrans = matrixMultiply trans currTrans + completeTrans = matrixMultiply globalTrans newTrans + alignAttr = styleVal "text-anchor" newStyle + align = if T.null alignAttr + then "start" + else alignAttr + fill = styleVal "fill" newStyle -- | Create a rectangle from a list of attributes. parseRect :: Matrix