GFM Codefence

textediting
markdown

#1

Hello Agenda,

I’ll write everything below, but I wanted to say thanks for this forum. It’s refreshing to see it well tended!

Feature — Add format type “Code Fence”

In addition to “Preformatted” as a format, I would like to see “Code Fence” as an additional area made available within notes. I’m aware everything gets converted to JSON, but if this is implemented, you have several advantages.

Fences should be able to be stored as a single string.

It’s something that can be implemented in the same way you see it in GFM; by invoking ``` [opt_lang]

As a feature, a Code Fence is not just about code. As a unique, plain-text environment, users can call for emphasis, ensure that specific coding is preserved, and formatting is explicit.

My hope is that it will not only be convenient, but a major selling point. Having a project of notes that allows code snips to be pasted would make sense as it doesn’t force formatting on text that shouldn’t have it. You’ll surely know how handy they are. While Agenda is not intended to be a Markdown editor, it would pay to offer the format as that can later be augmented to improve the product.

Finally, Preformatting doesn’t survive the Enter key. A fence creates a section that would continue to provide a code reference over multiple lines.

Thank you for your consideration.


#2

An addendum…

Please consider adding Cloud9 as the “code editor” within a code fenced area.


#3

Thanks for the feedback.

We want to improve preformatted blocks in future, perhaps with code syntax highlighting. The preformatted style should certainly survive hitting enter (don’t confuse with the inline fixed width style).

Usually, when we have some code, we choose preformatted style, and then paste the code in. It should maintain it’s styling, and avoid substitutions.

If this isn’t working for you, perhaps you can explain what is going wrong in a bit more detail.


#4

A bit more specific…

One instance is that when you start a note, you cannot set Preformatted until there’s text.

Another instance is that when you go ahead and type multiple lines, or if you paste in a code block, you have to instantiate preformat prior to the paste in order to not get carriage returns. Once the returns are in there, preformat doesn’t remove them (nor should it), but the damage is done.

But all that aside… start a note, and type starstarboldstarstar and you have a bolded line. What I would really like to see is that this same concept be applied. If you start a new note, and Cmd-Ctrl-5, you get Preformatted even though you can’t get it in the UI (cool!). What I think should occur is that when you do ``` it should get you in preformat same as cmd-ctrl-5, and out of it cmd-ctrl-0.

Eventually I’d like to see a ``` drop you into a code editor like Cloud9, but that’s maybe even a debate about product philosophy, so I’ll leave that one.

Hope that helps.


#5

You should definitely be able to choose preformatted in an empty note. There was a bug in 2.2 that may have prevented this, but it should be fixed in the latest. (I just checked to make sure.)

We have considered the ``` for preformatted. We could consider doing that. It would drop you straight into that style, like # does for headings.

But in the meantime, the key shortcut should work, at least in 2.2.1.

Drew


#6

I would like to second the feature request for MultiMarkdown compliant code fencing.

Besides the use cases already mentioned it would make it easier for us to use TaskPaper formatted task lists in Agenda notes, which in turn would greatly enhance compatibility with other apps, e.g. literally all task/todo/GTD-apps.

It could also help Agenda at a later stage to detect any such lists, i.e. fenced code blocks starting with ```taskpaper, to do some magic with them.