diff --git a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs index a97c90a794..9099b6ac48 100644 --- a/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs +++ b/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs @@ -243,13 +243,13 @@ dimlessLoad = vc "dimlessLoad" (nounPhraseSP "dimensionless load") (hat lQ) Real gTF = dqdNoUnit glTyFac (variable "GTF") Real isSafePb = vc "isSafePb" (nounPhraseSP "probability of glass breakage safety requirement") - (variable "is-safePb") Boolean + (variable "isSafePb") Boolean isSafeProb = vc "isSafeProb" (nounPhraseSP "probability of failure safety requirement") - (variable "is-safeProb") Boolean + (variable "isSafeProb") Boolean isSafeLR = vc "isSafeLR" (nounPhraseSP "3 second load equivalent resistance safety requirement") - (variable "is-safeLR") Boolean + (variable "isSafeLR") Boolean isSafeLoad = vc "isSafeLoad" (nounPhraseSP "load resistance safety requirement") - (variable "is-safeLoad") Boolean + (variable "isSafeLoad") Boolean lDurFac = vc'' loadDurFactor (variable "LDF") Real loadSF = dqdNoUnit loadShareFac (variable "LSF") Real diff --git a/code/drasil-printers/lib/Language/Drasil/TeX/Print.hs b/code/drasil-printers/lib/Language/Drasil/TeX/Print.hs index 5b8772238d..6c2424abfd 100644 --- a/code/drasil-printers/lib/Language/Drasil/TeX/Print.hs +++ b/code/drasil-printers/lib/Language/Drasil/TeX/Print.hs @@ -10,7 +10,6 @@ import Numeric (showEFloat) import Control.Arrow (second) import qualified Language.Drasil as L -import qualified Language.Drasil.ShortHands as LD (cDelta) import qualified Language.Drasil.Display as LD import Utils.Drasil (checkValidStr, foldNums) @@ -79,32 +78,6 @@ lo (Cell _) _ = empty print :: PrintingInformation -> [LayoutObj] -> D print sm = foldr (($+$) . (`lo` sm)) empty ------------------- Symbol ---------------------------- --- | Converts a symbol into a printable document form. -symbol :: LD.Symbol -> D -symbol (LD.Variable s) = pure $ text s -symbol (LD.Label s) = pure $ text s -symbol (LD.Integ n) = pure $ text $ show n -symbol (LD.Special s) = pure $ text $ unPL $ L.special s -symbol (LD.Concat sl) = foldl (<>) empty $ map symbol sl --- --- handle the special cases first, then general case -symbol (LD.Corners [] [] [x] [] s) = br $ symbol s <> pure hat <> br (symbol x) -symbol (LD.Corners [] [] [] [x] s) = br $ symbol s <> pure unders <> br (symbol x) -symbol (LD.Corners [_] [] [] [] _) = error "rendering of ul prescript" -symbol (LD.Corners [] [_] [] [] _) = error "rendering of ll prescript" -symbol LD.Corners{} = error "rendering of Corners (general)" -symbol (LD.Atop f s) = sFormat f s -symbol LD.Empty = empty - --- | Converts a decorated symbol into a printable document form. -sFormat :: L.Decoration -> L.Symbol -> D -sFormat LD.Hat s = commandD "hat" (symbol s) -sFormat LD.Vector s = commandD "symbf" (symbol s) -sFormat LD.Prime s = symbol s <> pure (text "'") -sFormat LD.Delta s = symbol LD.cDelta <> symbol s -sFormat LD.Magnitude s = fence Open Norm <> symbol s <> fence Open Norm - -- | Determine wether braces and brackets are opening or closing. data OpenClose = Open | Close @@ -113,6 +86,17 @@ data OpenClose = Open | Close ----------------------------------------------------------------- -- (Since this is all implicitly in Math, leave it as String for now) +-- | Escape all special TeX characters. +-- TODO: This function should be improved. It should escape all special +-- TeX symbols that would affect rendering. For example, `_` +-- turns the RHS of text into subscript, and `^` would turn it +-- into superscript. This will need to be much more comprehensive. +-- e.g., `%`, `&`, `#`, etc +escapeIdentSymbols :: String -> String +escapeIdentSymbols ('_':ss) = '\\' : '_' : escapeIdentSymbols ss +escapeIdentSymbols (s:ss) = s : escapeIdentSymbols ss +escapeIdentSymbols [] = [] + -- | Print an expression to a document. pExpr :: Expr -> D pExpr (Dbl d) = pure . text $ showEFloat Nothing d "" @@ -123,7 +107,8 @@ pExpr (Case ps) = mkEnv "cases" (cases ps) pExpr (Mtx a) = mkEnv "bmatrix" (pMatrix a) pExpr (Row [x]) = br $ pExpr x -- FIXME: Hack needed for symbols with multiple subscripts, etc. pExpr (Row l) = foldl1 (<>) (map pExpr l) -pExpr (Ident s) = pure . text $ s +pExpr (Ident s@[_]) = pure . text . escapeIdentSymbols $ s +pExpr (Ident s) = commandD "mathit" (pure . text . escapeIdentSymbols $ s) pExpr (Label s) = command "text" s pExpr (Spec s) = pure . text $ unPL $ L.special s --pExpr (Gr g) = unPL $ greek g @@ -334,7 +319,7 @@ pUnit (L.US ls) = formatu t b pow (n,p) = toMath $ superscript (p_symb n) (pure $ text $ show p) -- printing of unit symbols is done weirdly... FIXME? p_symb (LD.Concat s) = foldl (<>) empty $ map p_symb s - p_symb n = let cn = symbolNeeds n in switch (const cn) $ symbol n + p_symb n = let cn = symbolNeeds n in switch (const cn) $ pExpr $ I.symbol n ----------------------------------------------------------------- ------------------ DATA DEFINITION PRINTING----------------- diff --git a/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html b/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html index 43739dfeaf..17f07b32cb 100644 --- a/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html +++ b/code/stable/glassbr/SRS/HTML/GlassBR_SRS.html @@ -247,22 +247,22 @@

Table of Symbols

-- - is-safeLoad + isSafeLoad Load resistance safety requirement -- - is-safeLR + isSafeLR 3 second load equivalent resistance safety requirement -- - is-safePb + isSafePb Probability of glass breakage safety requirement -- - is-safeProb + isSafeProb Probability of failure safety requirement -- @@ -884,7 +884,7 @@

Theoretical Models

Equation - \[is-safeProb={P_{\text{f}}}\lt{}{P_{\text{f}\text{tol}}}\] + \[\mathit{isSafeProb}={P_{\text{f}}}\lt{}{P_{\text{f}\text{tol}}}\] @@ -892,7 +892,7 @@

Theoretical Models