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

custom HTML macros #55

Closed
wilzbach opened this issue May 13, 2016 · 10 comments
Closed

custom HTML macros #55

wilzbach opened this issue May 13, 2016 · 10 comments
Assignees
Labels

Comments

@wilzbach
Copy link
Member

I can think of four good examples

  1. Alert boxes

image

  1. Callouts infos

image

  1. Asides

image

  1. Tables

image

Probably 1,2,3 could be summarized into 2 categories only.

@stonemaster
Copy link
Collaborator

I think we should rely on standard markdown for defining the content. That way any normal editor will be able to format it locally as well as GitHub in the online editor. Special cases will just make it harder for everyone to understand what is going on. For VERY VERY important stuff (a table) HTML can be used directly. Also this feature would require changes to vibe.d's md parser (or a custom one). So I don't think the benefits outweigh the drawbacks.

@wilzbach
Copy link
Member Author

I reopen this as it seems that we need to find a simple way to have custom HTML macros/templates that allow us to separate HTML from the markdown text and make translations easier (see e.g. #248)

@wilzbach wilzbach added the UI label Jun 12, 2016
@stonemaster
Copy link
Collaborator

Agreed that this might be useful. Problem is that would need to either enhance the current vibe.d markdown filter or use another markdown processor that allows more customisation. There currently is just one other markdown parsed listed at code.dlang.org which basically is the vibe.d markdown parser but stripped out of the framework.

@wilzbach
Copy link
Member Author

Agreed that this might be useful. Problem is that would need to either enhance the current vibe.d markdown filter or use another markdown processor that allows more customisation.

Hmm do we really need to touch the Markdown engine? Basically we could apply our macros before converting the text to markdown?
A language that I like for it's simplicity is Liquid (known from Github Pages, Jekyll)

https://github.com/Shopify/liquid/wiki/Liquid-for-Designers
https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers

But basically for the beginning we only need to able to extend something like {{ download_icon, 'arch_linux' }}. We could use a simple, recursive regex's to find and replace such occurrences.

They could be defined in a template.yml

download_icon:
<img class="download-icon" src="{{ root }}/img/{{ $1 }}.png

I am still worried about rolling our own system here - @stonemaster do you have better ideas? :)

@stonemaster
Copy link
Collaborator

Unfortunately I have no better idea. But something that resembles liquid in some way is still better than cluttering the content md's with layout html. We should just make sure that we dont't make sure to not make use of those special features too often and try to achieve as much as possible with standard markdown..

@stonemaster
Copy link
Collaborator

An idea I just had: maybe we could use the Diet templating system? That way we don't need to roll our own system. I don't want to compile necessarily because that makes compilation of the dlang tour really slow. Maybe we can find a way to do that at runtime..
Unfortunately I didn't find any D solution we could use that fits our needs. So either we find something to integrate Diet or we have to roll our own..

@stonemaster
Copy link
Collaborator

Unfortunately the vibe.d and Diet way won't work. Will try to look into another solution. Currently still the own regex thingie is the best solution..

@stonemaster
Copy link
Collaborator

I found this one: https://github.com/repeatedly/mustache-d
Must have slipped me but seems to be the right direction for use. It uses the {{ }} syntax too and hopefully allows some more stuff than simply replacing text. I'll have a look at it.

@stonemaster
Copy link
Collaborator

Working on a solution using mustache. Looks promising so far. Should habe something weithin the next days.

@stonemaster stonemaster self-assigned this Jun 23, 2016
@stonemaster
Copy link
Collaborator

Vibe.d will support markdown tables soon!
vibe-d/vibe.d#1493

wilzbach added a commit that referenced this issue Jun 24, 2016
Implement HTML macros by using Mustache. Fixes #55.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants