phino 0.0.0.41 → 0.0.0.42
raw patch · 3 files changed
+27/−15 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- phino.cabal +1/−1
- src/LaTeX.hs +20/−12
- test/CLISpec.hs +6/−2
phino.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: phino-version: 0.0.0.41+version: 0.0.0.42 license: MIT synopsis: Command-Line Manipulator of 𝜑-Calculus Expressions description: Please see the README on GitHub at <https://github.com/objectionary/phino#readme>
src/LaTeX.hs view
@@ -3,23 +3,31 @@ module LaTeX (explainRules, programToLaTeX) where +import Ast (Program) import Data.List (intercalate) import Data.Maybe (fromMaybe)+import Pretty (Encoding (ASCII), PrintMode, prettyProgram') import qualified Yaml as Y-import Ast (Program)-import Pretty (PrintMode, prettyProgram', Encoding (ASCII)) +escapeUnprintedChars :: String -> String+escapeUnprintedChars [] = []+escapeUnprintedChars (ch : rest) = case ch of+ '$' -> "\\char36{}" ++ escapeUnprintedChars rest+ '@' -> "\\char64{}" ++ escapeUnprintedChars rest+ '^' -> "\\char94{}" ++ escapeUnprintedChars rest+ _ -> ch : escapeUnprintedChars rest+ programToLaTeX :: Program -> PrintMode -> String-programToLaTeX prog mode = unlines- [- "\\documentclass{article}",- "\\usepackage{eolang}",- "\\begin{document}",- "\\begin{phiquation}",- prettyProgram' prog mode ASCII,- "\\end{phiquation}",- "\\end{document}"- ]+programToLaTeX prog mode =+ unlines+ [ "\\documentclass{article}",+ "\\usepackage{eolang}",+ "\\begin{document}",+ "\\begin{phiquation}",+ escapeUnprintedChars (prettyProgram' prog mode ASCII),+ "\\end{phiquation}",+ "\\end{document}"+ ] -- @todo #114:30min Implement LaTeX conversion for rules. -- Convert Rule data structure to LaTeX inference rule format.
test/CLISpec.hs view
@@ -166,7 +166,7 @@ ["<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "<object", " <o base=\"Q.y\" name=\"x\"/>"] it "rewrites as LaTeX" $- withStdin "Q -> [[ x -> QQ.z(y -> 5), q -> T ]]" $+ withStdin "Q -> [[ x -> QQ.z(y -> 5), q -> T, w -> $, ^ -> Q, @ -> 1, y -> \"H$@^M\"]]" $ testCLI ["rewrite", "--output=latex", "--sweet"] [ "\\documentclass{article}",@@ -177,7 +177,11 @@ " x -> QQ.z(", " y -> 5", " ),",- " q -> T",+ " q -> T,",+ " w -> \\char36{},",+ " \\char94{} -> Q,",+ " \\char64{} -> 1,",+ " y -> \"H\\char36{}\\char64{}\\char94{}M\"", "]]}", "\\end{phiquation}", "\\end{document}"