Skip to content
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

Highlight commands in descriptions #545

Closed
xsebek opened this issue Jul 4, 2022 · 10 comments · Fixed by #1106
Closed

Highlight commands in descriptions #545

xsebek opened this issue Jul 4, 2022 · 10 comments · Fixed by #1106
Labels
C-Project A larger project, more suitable for experienced contributors. L-Pretty-printing Pretty-printing ASTs or values into a string representation. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-UI Involves the user interface. Z-Feature A new feature to be added to the game. Z-User Experience This issue seeks to make the game more enjoyable to play.

Comments

@xsebek
Copy link
Member

xsebek commented Jul 4, 2022

I want the commands in descriptions (entities, goal) to be highlighted instead of surrounded with ticks.

For shorter descriptions, it does not matter, but with longer ones like the goal or grabber device, I find it hard to read.

This would also be a good opportunity to use backticks to disambiguate them from normal ticks that English uses and be compatible with Markdown syntax.

As a small code refactoring, we could call the attribute "highlight" instead of using the robot attribute. 😅

update, 15 May 23: Collecting some related links here for easy access: #309, #574, jtdaugherty/brick#400, #1106

@xsebek xsebek added Z-User Experience This issue seeks to make the game more enjoyable to play. Z-Feature A new feature to be added to the game. C-Low Hanging Fruit Ideal issue for new contributors. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. L-Pretty-printing Pretty-printing ASTs or values into a string representation. T-UI Involves the user interface. labels Jul 4, 2022
@byorgey
Copy link
Member

byorgey commented Jul 4, 2022

Related: #309 .

@xsebek
Copy link
Member Author

xsebek commented Jul 4, 2022

Just to be clear about the higlight attribute, there is a highlightAttr that means cyan foreground and robotAttr that means bold white foreground, which is used as bold for some table headers. I think it is funny, but not very readable. 😅

@byorgey
Copy link
Member

byorgey commented Jul 4, 2022

Yeah, we should add a new bold attribute or something. Agree we should not use robot attribute for so many things!

@byorgey
Copy link
Member

byorgey commented Jul 4, 2022

Note, the difficulty with applying attributes to things in descriptions is that we have to give text to a function that does the text wrapping and constructs a widget. So we have no opportunity to apply formatting to individual words. This might require some kind of upstream PR to brick to give us the functionality we need.

@xsebek
Copy link
Member Author

xsebek commented Jul 4, 2022

Well at least the triple backtick examples should be doable with separate widgets.

I wonder if we could compose widgets so that they would still look like text and create our markdownTxt function to do it where relevant. That might be useful enough to publish as an open-source library. 😄

@byorgey
Copy link
Member

byorgey commented Jul 4, 2022

Well at least the triple backtick examples should be doable with separate widgets.

Maybe? I am not 100% sure how easy that will be.

I wonder if we could compose widgets so that they would still look like text and create our markdownTxt function to do it where relevant.

I'm not sure I understand what you mean.

@xsebek
Copy link
Member Author

xsebek commented Jul 4, 2022

I thought we could layout parts of the text to look like one text.

But looking at str it might be necessary to create a custom rendering function for the widget - some bit more complicated version of Text -> Image. But we should look through the brick projects if someone did not figure this out already. 🤔

@byorgey byorgey added C-Project A larger project, more suitable for experienced contributors. and removed C-Low Hanging Fruit Ideal issue for new contributors. labels Jul 7, 2022
@xsebek
Copy link
Member Author

xsebek commented Jul 20, 2022

I split out the easier part for highlighting code blocks.

As a prerequisite, we should change the inline code to use backticks, so that we can at least find it and get markdown support for free. AFAIK we only use it for valid swarm commands, but in case we wanted to support more languages, Pandoc has an Extension: inline_code_attributes that looks like this:

Try typing `build {}`{.swarm} - ...

@byorgey
Copy link
Member

byorgey commented Oct 22, 2022

I think at this point most (all?) of the inline code in entity descriptions, tutorial goal text, etc. has been converted to use backticks.

@xsebek
Copy link
Member Author

xsebek commented Oct 22, 2022

@byorgey thanks for updating on this. 👍

Next up, we need new data structure to represent text that has parts of it code.


After that we have to wrap that type by lines (not widgets). Once we have lines those can be turned into widgets.

Or we wait a little while until brick/other library makes the wrapping and assigning attributes easier for us.


This is mostly a TLDR of the discussion in jtdaugherty/brick#400.

xsebek added a commit that referenced this issue Feb 13, 2023
xsebek added a commit that referenced this issue Aug 2, 2023
- closes #309
- part of #545 and #574

Restyled by fourmolu (#1107)

Co-authored-by: Restyled.io <commits@restyled.io>
@mergify mergify bot closed this as completed in #1106 Aug 5, 2023
mergify bot pushed a commit that referenced this issue Aug 5, 2023
* use CommonMark to parse simple markdown AST parametrised on inline/block code
* validate swarm code (`Document Text -> Document Syntax`)
* update descriptions to use markdown with following conventions:
  - `move` - valid swarm code (the easy to write default)
  - `wedge`{=entity} - for swarm entities
  - `unit`{=type} - for swarm types
  - `require <a> <b>`{=snippet} - raw snippets for invalid code
  - **Alt-G** - bold for keyboard shortcuts
- highlight code in brick widgets
- closes #309
- closes #545
- precedes #574
- precedes #1406
- precedes #1407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Project A larger project, more suitable for experienced contributors. L-Pretty-printing Pretty-printing ASTs or values into a string representation. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-UI Involves the user interface. Z-Feature A new feature to be added to the game. Z-User Experience This issue seeks to make the game more enjoyable to play.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants