coleslaw-org / coleslaw

Flexible Lisp Blogware
BSD 2-Clause "Simplified" License
553 stars 82 forks source link

Code blocks should be able to have default language set #97

Open Ferada opened 8 years ago

Ferada commented 8 years ago

3bmd apparently has the *code-blocks-default-colorize* setting to supply a default language to use for code blocks. It would be great if we can set this from the meta data of a post (or even the global blog settings?). The same would also apply to other settings - I'd even say that having some place to include custom code would be nice, e.g. in the blog settings and in the post meta data.

The other option I see would be modifying 3bmd with additional syntax to set variables, but that seems messier and less general.

Ferada commented 8 years ago

I'm proposing https://github.com/Ferada/coleslaw/commit/5b20c4dc08f84a006768027f76a4281a437d8ac6, or a variant of it. It's at the moment not how I'd ideally want to write it, specifically I'd rather use let: name value and also collect multiple lines into a list of bindings, rather than having to squeeze all of it into a single line.

Also, I haven't found a good justification for running completely arbitrary code, so I left that part out for now.

libre-man commented 8 years ago

Would it be an idea to change the metadata parser to implement white space sensitive newlines? So that

tags: foo, bar, next
    fooz, baz

would be parsed the same way tags: foo, bar, next, fooz, baz would be parsed. I would propose that using four spaces to indent a line would be mean it is a continuation of the previous and that trailing comma's are not necessary, but should be possible.

libre-man commented 8 years ago

So I made a little proof of concept (libre-man@7cdd3e2ce13c3b6deb36d7a131163129a7716c1c) for parsing multiple-lines. The indentation is configurable and everything seems to work. If we would combine this with Ferada's commit we would be almost done with this feature if I'm not mistaking.

Ferada commented 8 years ago

I'd rather have "one or more whitespace characters" as a condition for continuation lines, otherwise that seems sensible. If you really want that configurable maybe just specify that condition with a regex instead.