-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Space handling at code
calls
#8
Comments
This is something that, I think, cannot be trivially handled by this library itself at the moment, but rather depends on the renderer (i.e. the text "foo" *> code "bar" The output is (sane):
But if we use it like this: paragraph (text "foo") *> paragraph (code "bar") The output is:
So the question that is arising is: How would the library know what to do? We could provide different primitives: A workaround could also be to provide the ability to explicitly insert spaces by adding a translate $ do
english [i|Stating|]
german [i|Die Angabe von|]
space
let ts = transitionPairShow findInitial
code $ show ts
space
translate $ do
let (t1, t2) = bimap show show ts
english [iii|
as answer would indicate that transitions #{t1} and #{t2}
are concurrently activated under the initial marking.
|]
[...]
space |
Another option would be to use the ADT For example glueing code blocks together could be done like this (of course this should rather be some fold function instead of the pattern matching) ghci> let run y = runLangMReport (pure ()) (>>) y >>= \(_, x) -> (x Control.OutputCapable.Blocks.English :: IO ())
ghci> let joinEntries = M.mergeWithKey (\_ x y-> Just $ x ++ y) id id
ghci> let sanitise [Code x, Code y] = [Code $ joinEntries x y]
ghci> join $ (run . Control.OutputCapable.Blocks.Generic.Type.toOutputCapable (\() -> pure ())) . sanitise <$> Control.OutputCapable.Blocks.Type.getSpecialOutputSequence (do {code "a" *> code "b"})
<ab> This would also not be part of the library, but the library could provide the sanitise function which should be used before using The most important question is:
?
There is no exception?! Anything else? |
Current use sites of
code
do seem to make different assumptions about whether or not spaces are added by the primitive itself.For example, there is this: https://github.com/fmidue/modelling-tasks/blob/88182aa38434bcfbfa457c22120bcb8bc3a5c737/src/Modelling/ActivityDiagram/EnterAS.hs#L193-L197 which explicitly adds a space before
code
but not after it.And this: https://github.com/fmidue/modelling-tasks/blob/88182aa38434bcfbfa457c22120bcb8bc3a5c737/src/Modelling/PetriNet/Concurrency.hs#L177-L187 which seems to go through a lot of pain (the
#{" "}
syntax) to really make sure that there is definitely a space aftercode
.But also this: https://github.com/fmidue/modelling-tasks/blob/88182aa38434bcfbfa457c22120bcb8bc3a5c737/src/Modelling/CdOd/SelectValidCd.hs#L224-L230 which doesn't seem to feel a need to do anything special about spaces surrounding
code
at all.I don't know whether this has some historical reason, or maybe has to do with different rendering routes (html vs. latex) that haven't yet been tried for all task types.
In any case, wouldn't it be better to have the
code
primitive itself do an "always sane thing", and relieve the users from thinking about spaces?Specifically, when rewriting existing code in terms of
code
, say here: https://github.com/fmidue/term-tasks/blob/c5410222ff7f84049bf0cc823c0508c0d3fd9c7a/src/TermTasks/Messages.hs#L30-L33 it would be nice to be able to not have to think about spaces and instead do the most simple rewriting at the use site.The text was updated successfully, but these errors were encountered: