Introduction to programming with compile time sequences in D

data pulverizer data.pulverizer at gmail.com
Tue Sep 1 17:12:05 UTC 2020


On Tuesday, 1 September 2020 at 16:24:29 UTC, Petar Kirov 
[ZombineDev] wrote:
>
> Yeah, I think we should add the following feature:
> Whenever there's a snippet of code (fenced code block in 
> markdown), a button should appear under, which when clicked 
> would replace the content of the text editor with the code 
> snippet.
>
> There two challenges with this:
> 1. Many of the code snippets that appear throughout the 
> articles are not meant to be runnable, so we would need a way 
> to provide the necessary scaffolding (e.g. wrap them in `void 
> main() { /+ ... +/ }`)

I think there should be two kinds of code area.

i. The regular "dumb code" fences (as we already have) which is 
just for displaying code. I have lots of these throughout my 
text, the code they contain are in general not runnable because 
they are designed to show only part of it or some output for 
discussion.

ii. Runnable code areas for actual scripts, the same width and in 
line with the text like the "dumb code" fences but as you said 
with a few buttons on the top for running the code (I'm not 
really bothered if they can pop out to another window/tab and so 
on). They should be scrollable because you don't want a huge 
amount of code just pasted in going potentially over one or more 
pages long.

I wonder if that is doable?

> 2. It may surprising and inconvenient for users to have the 
> code they have potentially modified disappear. This could be 
> solved by adding proper support for multiple open files to the 
> editor (along the lines of commercial solutions like 
> codesandbox, github workspaces, etc.). What would happen is 
> that click [Edit] on a code-block would simply open another 
> file.

I leave that to your expertise. The main thing is that people 
should be able to run and/or modify the code, and that the 
original content comes back on reload. I'm not sure it needs to 
be super-robust in terms of storing everything from the user 
because it's not a proper development area, only for learning. 
[:shrug:]




More information about the Digitalmars-d-announce mailing list